From 024f57985035cf467a719c34017c3167a5b08b07 Mon Sep 17 00:00:00 2001 From: Ivan X Date: Fri, 18 Dec 2015 00:45:01 -0500 Subject: [PATCH 1/3] macipgw installed; a2serverc created (macipgw tested on Wheezy and Jessie; works on Raspbian only, not Debian x86) --- README.md | 5 +++-- scripts/a2server-1-storage.txt | 2 +- scripts/a2server-2-tools.txt | 16 ++++++++++--- scripts/a2server-3-sharing.txt | 36 +++++++++++++++++++++++++++++- scripts/a2server-6-samba.txt | 8 ++++++- scripts/tools/a2server-aliases.txt | 8 +++---- scripts/tools/a2serverrc.txt | 4 ++++ scripts/tools/afpsync.txt | 4 ++-- scripts/tools/cppo.txt | 3 ++- scripts/tools/mkvolinfo.txt | 2 +- setup/index.txt | 4 ++-- 11 files changed, 74 insertions(+), 18 deletions(-) create mode 100755 scripts/tools/a2serverrc.txt diff --git a/README.md b/README.md index 36d532a..b4effd8 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ wget -O a2server-setup ${A2SERVER_SCRIPT_URL}setup/index.txt; source a2server-se ~~~ A simple method for installing from a local subdirectory is to `cd` to it and -then type `python -m SimpleHTTPServer`. Then export A2SERVER_SCRIPT_URL to -"http://localhost:8000/" or use the IP address of the host machine on your LAN. +then type `python -m SimpleHTTPServer`. Then +`export A2SERVER_SCRIPT_URL="http://localhost:8000/"` +or use the IP address of the host machine on your LAN instead of localhost. You should probably export A2SERVER_SCRIPT_URL in your .bashrc or whatever file configures your development environment. Also be advised that as of diff --git a/scripts/a2server-1-storage.txt b/scripts/a2server-1-storage.txt index 4f5b91c..cd1818d 100755 --- a/scripts/a2server-1-storage.txt +++ b/scripts/a2server-1-storage.txt @@ -24,7 +24,7 @@ else echo "A2SERVER: Preparing the shared files volume..." - sudo mkdir /srv/A2SERVER + sudo mkdir -p /srv/A2SERVER sudo chown $USER:$USER /srv/A2SERVER diff --git a/scripts/a2server-2-tools.txt b/scripts/a2server-2-tools.txt index b7142f8..42cc69a 100755 --- a/scripts/a2server-2-tools.txt +++ b/scripts/a2server-2-tools.txt @@ -121,7 +121,12 @@ fi if ! command -v unzip >/dev/null; then echo "A2SERVER: Installing unzip..." -sudo apt-get -y install unzip + if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then + # prepare for installing packages + sudo apt-get -y update + touch /tmp/a2server-packageReposUpdated + fi + sudo apt-get -y install unzip else echo "A2SERVER: unzip has already been installed." fi @@ -138,9 +143,14 @@ sudo wget -q -O /usr/local/bin/cppo "${scriptURL}scripts/tools/cppo.txt" sudo chmod ugo+x /usr/local/bin/cppo sudo wget -q -O /usr/local/etc/a2server-help.txt "${scriptURL}scripts/tools/a2server-help.txt" sudo wget -q -O /usr/local/etc/a2server-aliases "${scriptURL}scripts/tools/a2server-aliases.txt" +sudo wget -q -O /usr/local/etc/a2serverrc "${scriptURL}scripts/tools/a2serverrc.txt" -grep a2server-aliases /etc/bash.bashrc > /dev/null || \ -echo "source /usr/local/etc/a2server-aliases" | sudo tee -a /etc/bash.bashrc > /dev/null +# 1.3.0: a2serverrc is now called from /etc/bash.bashrc, +# which in turn calls a2server-aliases +grep 'a2server-aliases' /etc/bash.bashrc > /dev/null && \ +sudo sed -i 's/a2server-aliases/a2serverrc/' /etc/bash.bashrc +grep 'a2serverrc' /etc/bash.bashrc > /dev/null || \ +echo "source /usr/local/etc/a2serverrc" | sudo tee -a /etc/bash.bashrc > /dev/null motd="/etc/motd" if [[ ! $(grep A2SERVER $motd) ]]; then diff --git a/scripts/a2server-3-sharing.txt b/scripts/a2server-3-sharing.txt index 1625220..4de7331 100755 --- a/scripts/a2server-3-sharing.txt +++ b/scripts/a2server-3-sharing.txt @@ -177,6 +177,34 @@ else rm -rf /tmp/netatalk fi fi + +# --- Install MacIPgw +if ! command -v macipgw > /dev/null; then + echo "A2SERVER: Installing TCP over AppleTalk (MacIP)..." + + if [[ $isRpi ]]; then + wget -qO- "http://appleii.ivanx.com/a2server/files/macipgw-rpi.tgz" | sudo tar Pzx + elif [[ $isDebian_x86 ]]; then + wget -qO- "http://appleii.ivanx.com/a2server/files/macipgw-debian7_x86.tgz" | sudo tar Pzx + fi + + if ! command -v macipgw > /dev/null; then + wd="$PWD" + sudo apt-get -y install build-essential + rm -rf /tmp/macipgw &> /dev/null + mkdir /tmp/macipgw + cd /tmp/macipgw + wget -qO macipgw-master.zip "https://github.com/zero2sixd/macipgw/archive/master.zip" + unzip macipgw-master.zip + cd macipgw-master + make + sudo make install + cd "$wd" + rm -rf /tmp/macipgw + fi +else + echo "A2SERVER: TCP over AppleTalk (MacIP) has already been installed." +fi # --- Configuring Netatalk @@ -198,6 +226,12 @@ if [[ ! $(grep 'kernelRelease' /etc/init.d/netatalk) ]]; then sudo sed -i 's@\(\tif \[ x\"$ATALKD_RUN\)@\n\t# check for valid AppleTalk kernel module\n\t[[ $ATALKD_RUN == "yes" ]] \&\& { kernelRelease=$(uname -r); kernelMajorRelease=$(cut -d "." -f 1 <<< $kernelRelease); kernelMinorRelease=$(cut -d "." -f 2 <<< $kernelRelease | sed '"'"'s/\\(^[0-9]*\\)[^0-9].*$/\\1/'"'"'); kernelPatchRelease=$(cut -d "." -f 3- <<< $kernelRelease | sed '"'"'s/\\(^[0-9]*\\)[^0-9].*$/\\1/'"'"'); [[ ( $kernelMajorRelease -eq 3 \&\& $kernelMinorRelease -ge 12 \&\& $kernelMinorRelease -le 15 ) \&\& ( ! ( -f /usr/bin/raspi-config \&\& $kernelMinorRelease -eq 12 \&\& $kernelPatchRelease -ge 25 ) ) \&\& ( ( ! -f /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko ) || $(sha1sum /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko | cut -f 1 -d " ") != "ecb239fc084c36de93f6926e7749b80f6024f269" ) ]] \&\& { ATALKD_RUN=no; echo "[AppleTalk networking is not available.]" 1>\&2; } }\n\n\1@' /etc/init.d/netatalk fi +# enable MacIPgw support after launching atalkd +if ! grep -q -i 'macipgw' /etc/init.d/netatalk; then + sudo sed -i ':a;N;$!ba;s@\(echo -n " atalkd"\)\(.*# prepare\)@\1\n\n # start MacIPgw (TCP over AppleTalk) service\n ps aux | grep -q "[m]acipgw" \&\& sudo killall macipgw 2> /dev/null\n atalkd_interface=$(grep "^[^ #]" /etc/netatalk/atalkd.conf | tail -1 | cut -d " " -f 1)\n sysctl -w net.ipv4.ip_forward=1 > /dev/null\n macipgw -n 8.8.8.8 192.168.151.0 255.255.255.0\n /sbin/iptables -t nat -A POSTROUTING -o ${atalkd_interface} -j MASQUERADE\n /sbin/iptables -A FORWARD -i ${atalkd_interface} -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT\n /sbin/iptables -A FORWARD -i tun1 -o ${atalkd_interface} -j ACCEPT\n\n echo -n " macipgw"\n\2@' /etc/init.d/netatalk + sudo sed -i 's@\(start-stop-daemon --stop --quiet --oknodo --exec /usr/local/sbin/atalkd.*$\)@\1\n echo -n " macipgw"\n sudo killall macipgw 2> /dev/null@' /etc/init.d/netatalk +fi + # enable network boot support in netatalk sudo sed -i 's/timelord/a2boot/g' /etc/init.d/netatalk sudo sed -i 's/TIMELORD/A2BOOT/g' /etc/init.d/netatalk @@ -319,7 +353,7 @@ fi # set up A2FILES case-insensitive share (for ProDOS 8 files, and GS/OS system) sudo sed -i \ - 's/^#share2/\/media\/A2SHARED\/A2FILES\ A2FILES options:prodos\ ea:ad/' \ + 's/^#share2/\/srv\/A2SERVER\/A2FILES\ A2FILES options:prodos\ ea:ad/' \ /usr/local/etc/netatalk/AppleVolumes.default [[ -d /srv/A2SERVER/A2FILES ]] || mkdir -p /srv/A2SERVER/A2FILES [[ -d /srv/A2SERVER/.a2files ]] || mkdir -p /srv/A2SERVER/.a2files diff --git a/scripts/a2server-6-samba.txt b/scripts/a2server-6-samba.txt index d6dcc14..ebec934 100755 --- a/scripts/a2server-6-samba.txt +++ b/scripts/a2server-6-samba.txt @@ -46,7 +46,13 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupWindowsSharing ]]; then sudo sed -i 's/^ workgroup = .*$/ workgroup = '$workgroup'/' /etc/samba/smb.conf 2> /dev/null sudo sed -i 's/^# security = user/ security = user/' /etc/samba/smb.conf 2> /dev/null - grep ^/media /usr/local/etc/netatalk/AppleVolumes.default | cut -d" " -f2 \ + # remove GSFILES if no longer serving it + if ! grep ^/srv/A2SERVER/GSFILES /usr/local/etc/netatalk/AppleVolumes.default; then + sudo sed -i ':a;N;$!ba;s#\n\[GSFILES\].*\[#\n[#' /etc/samba/smb.conf + sudo sed -i ':a;N;$!ba;s#\n\[GSFILES\].*$#\n#' /etc/samba/smb.conf + fi + + grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | cut -d" " -f2 \ | while read sharename; do if [[ $(grep $sharename /etc/samba/smb.conf) ]]; then echo "A2SERVER: $sharename is already set up for Windows file sharing." diff --git a/scripts/tools/a2server-aliases.txt b/scripts/tools/a2server-aliases.txt index 5c0dc78..752b117 100755 --- a/scripts/tools/a2server-aliases.txt +++ b/scripts/tools/a2server-aliases.txt @@ -24,8 +24,8 @@ alias showmac-wifi='ifconfig wlan0 | grep "HWaddr" | cut -dH -f2 | cut -c7-23' alias ifreset='sudo rm /etc/udev/rules.d/70-persistent-net.rules; echo Interfaces removed. You should system-restart now.' alias netatalk-stop="sudo /etc/init.d/netatalk stop; bonjour-off" -alias netatalk-start="sudo /etc/init.d/netatalk start; bonjour-on" -alias netatalk-restart="sudo /etc/init.d/netatalk restart; bonjour-on" +alias netatalk-start="sudo /etc/init.d/netatalk start; bonjour-on; grep -q 'ATALKD_RUN=yes' /etc/default/netatalk" +alias netatalk-restart="sudo /etc/init.d/netatalk restart; bonjour-on; grep -q 'ATALKD_RUN=yes' /etc/default/netatalk" alias netatalk-off='sudo /etc/init.d/netatalk stop; bonjour-off; sudo update-rc.d -f netatalk remove &> /dev/null' alias netatalk-on='sudo update-rc.d netatalk defaults &> /dev/null; bonjour-on; sudo /etc/init.d/netatalk restart' @@ -42,8 +42,8 @@ alias netatalk-wifi='sudo sed -i 's/^eth0/wlan0/' /usr/local/etc/netatalk/atalkd -alias appletalk-off='sudo sed -i "s/ATALKD_RUN=yes/ATALKD_RUN=no/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart' -alias appletalk-on='sudo sed -i "s/ATALKD_RUN=no/ATALKD_RUN=yes/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart' +alias appletalk-off='sudo sed -i "s/ATALKD_RUN=yes/ATALKD_RUN=no/" /etc/default/netatalk; sudo killall macipgw > /dev/null; /etc/init.d/netatalk restart' +alias appletalk-on='sudo sed -i "s/ATALKD_RUN=no/ATALKD_RUN=yes/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart; sudo macip-start' NETATALK="/usr/local/etc/netatalk" diff --git a/scripts/tools/a2serverrc.txt b/scripts/tools/a2serverrc.txt new file mode 100755 index 0000000..30c74fc --- /dev/null +++ b/scripts/tools/a2serverrc.txt @@ -0,0 +1,4 @@ +#! /bin/bash +# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh: + +source /usr/local/etc/a2server-aliases diff --git a/scripts/tools/afpsync.txt b/scripts/tools/afpsync.txt index d8dd752..0b0b3a5 100755 --- a/scripts/tools/afpsync.txt +++ b/scripts/tools/afpsync.txt @@ -11,7 +11,7 @@ # # -v will silently create a .volinfo file if none exists. # If a path is specified, only that volume is synced; otherwise, all -# all paths in /media which appear in +# all paths in /srv/A2SERVER which appear in # /usr/local/etc/netatalk/AppleVolumes.default are synced. processPath () { @@ -108,7 +108,7 @@ else # (as opposed to defaulting to casefold:toupper previously) processPath 1 else - grep ^/media /usr/local/etc/netatalk/AppleVolumes.default | \ + grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | \ while read line; do [[ $(echo $line | grep toupper) ]]; nocasefold=$? sharepath=$(echo $line | cut -d" " -f1) diff --git a/scripts/tools/cppo.txt b/scripts/tools/cppo.txt index 5c3acd6..66242a4 100755 --- a/scripts/tools/cppo.txt +++ b/scripts/tools/cppo.txt @@ -333,7 +333,8 @@ def processEntry(arg1, arg2): g.activeFileName = getFileName(arg1 ,arg2).decode("L1") g.activeFileSize = getFileLength(arg1, arg2) - if ((not g.PDOSPATH_INDEX) or (g.activeFileName == g.PDOSPATH_SEGMENT)): + if ((not g.PDOSPATH_INDEX) or + (g.activeFileName.upper() == g.PDOSPATH_SEGMENT.upper())): if (getStorageType(arg1, arg2) == 13): # if ProDOS directory if not g.PDOSPATH_INDEX: diff --git a/scripts/tools/mkvolinfo.txt b/scripts/tools/mkvolinfo.txt index 54b9cbd..f4811d4 100755 --- a/scripts/tools/mkvolinfo.txt +++ b/scripts/tools/mkvolinfo.txt @@ -49,7 +49,7 @@ else if [[ $1 ]]; then sharepath=$(readlink -m $1) else - sharepath=$(grep ^/media /usr/local/etc/netatalk/AppleVolumes.default | tail -1 | cut -d" " -f1) + sharepath=$(grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | tail -1 | cut -d" " -f1) fi volinfo=$sharepath/.AppleDesktop/.volinfo diff --git a/setup/index.txt b/setup/index.txt index 9491498..99c7caa 100755 --- a/setup/index.txt +++ b/setup/index.txt @@ -9,7 +9,7 @@ # to download and execute, type: # wget appleii.ivanx.com/a2server/setup; source setup -a2serverVersion="128d1" +a2serverVersion="128d2" # Ensure URL we'll use ends in a / case "$A2SERVER_SCRIPT_URL" in @@ -216,7 +216,7 @@ if (( $doSetup )); then echo "$a2serverVersion" | sudo tee /usr/local/etc/A2SERVER-version &> /dev/null fi - source /usr/local/etc/a2server-aliases + source /usr/local/etc/a2serverrc # get Kernel release (e.g. 3.6.11+) and version (e.g. #557) kernelRelease=$(uname -r) From 343bde59fae86a5be6065aa13df2d3b1669695c8 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 13 Dec 2015 09:31:49 -0800 Subject: [PATCH 2/3] License terms for A2SERVER This doesn't close the open issue on the subject, since precisely what's under what license isn't really addressed yet, but at least the license is specified. For those unfamiliar with the WTFPL, it's a public domain release like CC0, except instead of trying to legally emulate the public domain if that concept is foreign to your jurisdiction, it basically gives all software licenses a giant middle finger. What it lacks in finesse and niceties or in legal rigor of the CC0, it makes up for in simplicity: Do whatever the f*** you want with the code! It's pretty hard to misconstrue what that means. :) --- LICENSE.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..7b81122 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,13 @@ +License for A2SERVER +==================== + +A2SERVER + +Copyright (C) 2013-2015 Ivan Drucker + +The A2SERVER scripts themselves are written primarily by Ivan Drucker and +released under the WTFPL version 2, which you may download from its web page +at . This is essentially a public domain +release, which doesn't extend to the other programs used by A2SERVER such as +netatalk or the various Linux tools it installs. These have their own license +terms and Copyrights. From c2bb79860ad8660c3a7b83123a04e1878a94ec62 Mon Sep 17 00:00:00 2001 From: Ivan X Date: Sun, 20 Dec 2015 00:40:28 -0500 Subject: [PATCH 3/3] on Debian, provides AppleTalk without IPDDP to enable MacIPgw --- scripts/a2server-3-sharing.txt | 105 +++++++++++++++++++++++++++-- scripts/tools/a2server-aliases.txt | 2 +- setup/index.txt | 12 +++- 3 files changed, 110 insertions(+), 9 deletions(-) diff --git a/scripts/a2server-3-sharing.txt b/scripts/a2server-3-sharing.txt index 4de7331..48549f1 100755 --- a/scripts/a2server-3-sharing.txt +++ b/scripts/a2server-3-sharing.txt @@ -40,7 +40,7 @@ else # stop Netatalk and samba if running (during upgrade) if [[ $(ps --no-headers -C afpd) ]]; then - sudo /etc/init.d/netatalk stop + sudo /etc/init.d/netatalk stop &> /dev/null sudo /etc/init.d/samba stop &> /dev/null fi @@ -223,7 +223,7 @@ sudo sed -i 's/bin\/sh/bin\/bash/' /etc/init.d/netatalk sudo sed -i 's/#ATALKD_RUN=no/ATALKD_RUN=yes/' /etc/default/netatalk sudo sed -i 's/#ATALK_BGROUND=no/ATALK_BGROUND=yes/' /etc/default/netatalk if [[ ! $(grep 'kernelRelease' /etc/init.d/netatalk) ]]; then - sudo sed -i 's@\(\tif \[ x\"$ATALKD_RUN\)@\n\t# check for valid AppleTalk kernel module\n\t[[ $ATALKD_RUN == "yes" ]] \&\& { kernelRelease=$(uname -r); kernelMajorRelease=$(cut -d "." -f 1 <<< $kernelRelease); kernelMinorRelease=$(cut -d "." -f 2 <<< $kernelRelease | sed '"'"'s/\\(^[0-9]*\\)[^0-9].*$/\\1/'"'"'); kernelPatchRelease=$(cut -d "." -f 3- <<< $kernelRelease | sed '"'"'s/\\(^[0-9]*\\)[^0-9].*$/\\1/'"'"'); [[ ( $kernelMajorRelease -eq 3 \&\& $kernelMinorRelease -ge 12 \&\& $kernelMinorRelease -le 15 ) \&\& ( ! ( -f /usr/bin/raspi-config \&\& $kernelMinorRelease -eq 12 \&\& $kernelPatchRelease -ge 25 ) ) \&\& ( ( ! -f /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko ) || $(sha1sum /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko | cut -f 1 -d " ") != "ecb239fc084c36de93f6926e7749b80f6024f269" ) ]] \&\& { ATALKD_RUN=no; echo "[AppleTalk networking is not available.]" 1>\&2; } }\n\n\1@' /etc/init.d/netatalk + sudo sed -i 's@\(\tif \[ x\"$ATALKD_RUN\)@\n\t# check for valid AppleTalk kernel module\n\t[[ $ATALKD_RUN == "yes" ]] \&\& { kernelRelease=$(uname -r); kernelMajor=$(cut -d "." -f 1 <<< $kernelRelease); kernelMinor=$(cut -d "." -f 2 <<< $kernelRelease | sed '"'"'s/\\(^[0-9]*\\)[^0-9].*$/\\1/'"'"'); kernelPatch=$(cut -d "." -f 3- <<< $kernelRelease | sed '"'"'s/\\(^[0-9]*\\)[^0-9].*$/\\1/'"'"'); [[ ( $kernelMajor -eq 3 \&\& $kernelMinor -ge 12 \&\& $kernelMinor -le 15 ) \&\& ( ! ( -f /usr/bin/raspi-config \&\& $kernelMinor -eq 12 \&\& $kernelPatch -ge 25 ) ) \&\& ( ( ! -f /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko ) || $(sha1sum /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko | cut -f 1 -d " ") != "ecb239fc084c36de93f6926e7749b80f6024f269" ) ]] \&\& { ATALKD_RUN=no; echo "[AppleTalk networking is not available.]" 1>\&2; } }\n\n\1@' /etc/init.d/netatalk fi # enable MacIPgw support after launching atalkd @@ -455,14 +455,15 @@ fi # get Kernel release (e.g. 3.6.11+) and version (e.g. #557) kernelRelease=$(uname -r) -kernelMajorRelease=$(cut -d '.' -f 1 <<< $kernelRelease) -kernelMinorRelease=$(cut -d '.' -f 2 <<< $kernelRelease | sed 's/\(^[0-9]*\)[^0-9].*$/\1/') -kernelPatchRelease=$(cut -d '.' -f 3- <<< $kernelRelease | sed 's/\(^[0-9]*\)[^0-9].*$/\1/') +kernelMajor=$(cut -d '.' -f 1 <<< $kernelRelease) +kernelMinor=$(cut -d '.' -f 2 <<< $kernelRelease | sed 's/\(^[0-9]*\)[^0-9].*$/\1/') +kernelPatch=$(cut -d '.' -f 3- <<< $kernelRelease | sed 's/\(^[0-9]*\)[^0-9].*$/\1/') +kernelMajorMinor=$(cut -d '.' -f 1-2 <<< $kernelRelease) # if on kernel 3.12 through 3.15, check if we need to delete AppleTalk module to prevent kernel panics -if [[ $kernelMajorRelease -eq 3 && $kernelMinorRelease -ge 12 && $kernelMinorRelease -le 15 ]]; then +if [[ $kernelMajor -eq 3 && $kernelMinor -ge 12 && $kernelMinor -le 15 ]]; then # if not RPi, or RPi without ivanx-fixed AppleTalk module, delete the module - if [[ ! ( $isRpi && $kernelMinorRelease -eq 12 && $kernelPatchRelease -ge 25 ) ]]; then + if [[ ! ( $isRpi && $kernelMinor -eq 12 && $kernelPatch -ge 25 ) ]]; then if [[ -f /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko ]]; then if [[ $(sha1sum /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko | cut -f 1 -d ' ') != "ecb239fc084c36de93f6926e7749b80f6024f269" ]]; then # stop Netatalk @@ -481,6 +482,96 @@ if [[ $kernelMajorRelease -eq 3 && $kernelMinorRelease -ge 12 && $kernelMinorRel fi fi +# if IPDDP module exists (e.g. Debian, but not Raspbian), +# AppleTalk kernel module can't work with MacIP +if [[ -f "/lib/modules/$kernelRelease/kernel/drivers/net/appletalk/ipddp.ko" ]]; then + sudo /etc/init.d/netatalk stop &> /dev/null + sudo rmmod ipddp 2> /dev/null + sudo rmmod appletalk 2> /dev/null + echo "A2SERVER: Attempting to replace AppleTalk kernel module for MacIP use..." + + sudo mv /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko /tmp + + if [[ $isDebian_x86 ]]; then + echo "A2SERVER: Attempting to fetch AppleTalk kernel module for Debian x86..." + wget -qO /tmp/appletalk.tgz http://appleii.ivanx.com/a2server/files/appletalk-$kernelRelease-debian_x86.tgz + if [[ $? -eq 0 ]]; then + # if we found a prebuilt one on a2server site, install it and load it + sudo tar Pxf /tmp/appletalk.tgz + sudo depmod + sudo modprobe appletalk + if [[ $(lsmod | grep appletalk) ]]; then + # if it loaded, restart netatalk + sudo sed -i "s/ATALKD_RUN=no/ATALKD_RUN=yes/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart &> /dev/null + else + # if we didn't load it successfully, remove it + sudo rm /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko 2> /dev/null + fi + fi + fi + + if ! lsmod | grep -q appletalk; then + # we don't have a prebuilt AppleTalk module, try to build from source + if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then + # prepare for installing packages + sudo apt-get -y update + touch /tmp/a2server-packageReposUpdated + fi + + # kernel module compile adapted from from: http://askubuntu.com/a/338403/288003 + for i in 1; do + echo "A2SERVER: Attempting to build AppleTalk kernel module..." + [[ -f /boot/config-$kernelRelease ]] || break + sudo apt-get -y install linux-headers-$kernelRelease linux-source-$kernelMajorMinor || break + sudo apt-get -y install build-essential + cd /usr/src + kernelSrc=$(find linux-source-${kernelMajorMinor}*) + if [[ ${kernelSrc##*.} == "xz" ]]; then + xzcat $kernelSrc | sudo tar x + elif [[ ${kernelSrc##*.} == "bz2" ]]; then + sudo tar jxf $kernelSrc + elif [[ ${kernelSrc##*.} == "gz" || ${kernelSrc##*.} == "tgz" ]]; then + sudo tar zxf $kernelSrc + fi + cd linux-source-$kernelMajorMinor + sudo make mrproper + sudo cp ../linux-headers-$kernelRelease/Module.symvers . + yes '' | sudo make oldconfig + sudo sed -i 's:^.*IPDDP.*$:# CONFIG_IPDDP is not set:gI' .config # disable IPDDP in kernel config + sudo sed -i '$!N; /^\(# CONFIG_IPDDP is not set\)\n\1$/!P; D' .config # delete repeated entries + sudo make prepare + sudo make modules_prepare + sudo make SUBDIRS=scripts/mod + sudo make SUBDIRS=net/appletalk modules + sudo cp net/appletalk/appletalk.ko /lib/modules/$kernelRelease/kernel/net/appletalk + sudo depmod + sudo modprobe appletalk + sudo rm -r /lib/modules/$kernelRelease/kernel/drivers/net/appletalk/ipddp.ko + sudo rmdir /lib/modules/$kernelRelease/kernel/drivers/net/appletalk 2> /dev/null + + # clean up + cd + sudo rm /usr/src/$kernelSrc + sudo rm -r /usr/src/linux-source-$kernelMajorMinor + sudo apt-get -y purge linux-source-$kernelMajorMinor + done + fi + + if [[ $(lsmod | grep appletalk) ]]; then + # if it loaded, make permanent and restart netatalk + sudo rm /lib/modules/$kernelRelease/kernel/drivers/net/appletalk/ipddp.ko 2> /dev/null + sudo sed -i 's:^.*IPDDP.*$:# CONFIG_IPDDP is not set:gI' /boot/config-$kernelRelease + sudo sed -i '$!N; /^\(# CONFIG_IPDDP is not set\)\n\1$/!P; D' /boot/config-$kernelRelease + sudo sed -i "s/ATALKD_RUN=no/ATALKD_RUN=yes/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart &> /dev/null + else + # if we didn't load it successfully, put back the one that was there + echo "A2SERVER: Unable to replace AppleTalk module, replacing original." + sudo mv /tmp/appletalk.ko /lib/modules/$kernelRelease/kernel/net/appletalk 2> /dev/null + sudo depmod + touch /tmp/noMacIP # to notify at end of install + fi +fi + # --- Start Netatalk (if not running) bground= diff --git a/scripts/tools/a2server-aliases.txt b/scripts/tools/a2server-aliases.txt index 752b117..a990860 100755 --- a/scripts/tools/a2server-aliases.txt +++ b/scripts/tools/a2server-aliases.txt @@ -43,7 +43,7 @@ alias netatalk-wifi='sudo sed -i 's/^eth0/wlan0/' /usr/local/etc/netatalk/atalkd alias appletalk-off='sudo sed -i "s/ATALKD_RUN=yes/ATALKD_RUN=no/" /etc/default/netatalk; sudo killall macipgw > /dev/null; /etc/init.d/netatalk restart' -alias appletalk-on='sudo sed -i "s/ATALKD_RUN=no/ATALKD_RUN=yes/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart; sudo macip-start' +alias appletalk-on='sudo sed -i "s/ATALKD_RUN=no/ATALKD_RUN=yes/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart' NETATALK="/usr/local/etc/netatalk" diff --git a/setup/index.txt b/setup/index.txt index 99c7caa..13e61bd 100755 --- a/setup/index.txt +++ b/setup/index.txt @@ -9,7 +9,7 @@ # to download and execute, type: # wget appleii.ivanx.com/a2server/setup; source setup -a2serverVersion="128d2" +a2serverVersion="128d3" # Ensure URL we'll use ends in a / case "$A2SERVER_SCRIPT_URL" in @@ -266,9 +266,18 @@ if (( $doSetup )); then echo "by typing 'appletalk-on'." echo fi + + if [[ -f /tmp/noMacIP ]]; then + echo + echo "MacIP connections may be unavailable. If you know how, try" + echo "recompiling the AppleTalk kernel module with IPDDP options disabled." + echo + rm /tmp/noMacIP + fi if [[ -f /tmp/singleUser ]]; then if [[ ! $autoAnswerYes ]]; then + echo echo "Your Raspberry Pi was started in single-user mode in order to" echo -n "fix a problem. You should restart to operate normally. Restart now? " read @@ -279,6 +288,7 @@ if (( $doSetup )); then echo "A2SERVER: Preparing to restart..." while :; do sleep 60; done fi + rm /tmp/singleUser echo fi