1
0
mirror of https://github.com/RasppleII/a2server.git synced 2025-04-30 05:37:30 +00:00

Clean the main scripts a bit

Ivan writes pretty dense scripts in some ways, but not others.  Mostly
he likes to collapse statements to a single line and using && and || in
place of if constructs.  Reduces file size and theoretically speeds
execution, but it makes community development tougher and the speed
gains are questionable.

I've begun removing multiple successive writes to a single file such as
those using tee as a means to write files as root.  Clean up enough of
those and you will have a noticable performance impact, although again
there's no evidence there are enough of them here to see one.

Removed a few dead/commented code blocks and restructured a couple of
conditionals to make the no-action condition the else case.

Finally, bumped the version.  This isn't all that'll go into 1.5.1 but
it's a start.
This commit is contained in:
T. Joseph Carter 2016-10-27 00:55:16 -07:00
parent 202d5e6321
commit 530b8d57f5
7 changed files with 180 additions and 131 deletions

@ -11,21 +11,15 @@ if [[ -d /media/A2SHARED ]]; then
[[ ! -d /srv ]] && sudo mkdir -p /srv
sudo mv /media/A2SHARED /srv/A2SERVER
sudo sed -i 's|/media/A2SHARED|/srv/A2SERVER|g' /usr/local/etc/netatalk/AppleVolumes.default
[[ -f /etc/samba/smbd.conf ]] && sudo sed -i 's|/media/A2SHARED|/srv/A2SERVER|g' /etc/samba/smbd.conf
if [[ -f /etc/samba/smbd.conf ]]; then
sudo sed -i 's|/media/A2SHARED|/srv/A2SERVER|g' /etc/samba/smbd.conf
fi
fi
# skip if we're already set up
if [[ -d /srv/A2SERVER ]]; then
echo "A2SERVER: Shared volume is already prepared for use."
else
if [[ ! -d /srv/A2SERVER ]]; then
echo "A2SERVER: Preparing the shared files volume..."
sudo mkdir -p /srv/A2SERVER
sudo chown $USER:$USER /srv/A2SERVER
else
echo "A2SERVER: Shared volume is already prepared for use."
fi

@ -22,12 +22,14 @@ arch=
if [[ -f /usr/bin/raspi-config ]]; then
isRpi=1
arch='rpi'
elif lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian' && [[ $(cut -d . -f 1 <<< $debianVersion) -ge "7" ]]; then
uname_m="$(uname -m)"
if [[ $uname_m == "i686" ]]; then
arch='debian_x86'
elif [[ $uname_m == "x86_64" ]]; then
arch='debian_x64'
elif lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian'; then
if [[ $(cut -d . -f 1 <<< $debianVersion) -ge "7" ]]; then
uname_m="$(uname -m)"
if [[ $uname_m == "i686" ]]; then
arch='debian_x86'
elif [[ $uname_m == "x86_64" ]]; then
arch='debian_x64'
fi
fi
fi
@ -197,16 +199,20 @@ sudo wget -q -O /usr/local/etc/a2serverrc "${scriptURL}scripts/tools/a2serverrc.
# 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
if grep 'a2server-aliases' /etc/bash.bashrc >/dev/null; then
sudo sed -i 's/a2server-aliases/a2serverrc/' /etc/bash.bashrc
fi
if ! grep 'a2serverrc' /etc/bash.bashrc >/dev/null; then
echo "source /usr/local/etc/a2serverrc" | sudo tee -a /etc/bash.bashrc >/dev/null
fi
motd="/etc/motd"
if [[ ! $(grep A2SERVER $motd) ]]; then
echo | sudo tee -a $motd > /dev/null
echo "Type 'system-shutdown' to turn off A2SERVER." | sudo tee -a $motd > /dev/null
echo "Type 'a2server-setup' to configure network boot." | sudo tee -a $motd > /dev/null
echo "Type 'a2server-help' for a list of other commands." | sudo tee -a $motd > /dev/null
echo | sudo tee -a $motd > /dev/null
sudo tee -a $motd >/dev/null <<EOF
Type 'system-shutdown' to turn off A2SERVER.
Type 'a2server-setup' to configure network boot.
Type 'a2server-help' for a list of other commands.
EOF
fi

@ -32,12 +32,14 @@ arch=
if [[ -f /usr/bin/raspi-config ]]; then
isRpi=1
arch='rpi'
elif lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian' && [[ $(cut -d . -f 1 <<< $debianVersion) -ge "7" ]]; then
elif lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian'; then
if [[ $(cut -d . -f 1 <<< $debianVersion) -ge "7" ]]; then
uname_m="$(uname -m)"
if [[ $uname_m == "i686" ]]; then
arch='debian_x86'
elif [[ $uname_m == "x86_64" ]]; then
arch='debian_x64'
if [[ $uname_m == "i686" ]]; then
arch='debian_x86'
elif [[ $uname_m == "x86_64" ]]; then
arch='debian_x64'
fi
fi
fi
@ -54,14 +56,10 @@ if [[ $debianVersion ]]; then
fi
# skip this if already done
if [[ -f /usr/local/etc/A2SERVER-version ]] && (( $(head -c 3 /usr/local/etc/A2SERVER-version) >= 101 )); then
if [[ -f /usr/local/etc/A2SERVER-version && $(head -c 3 /usr/local/etc/A2SERVER-version) -ge 101 ]]; then
echo "A2SERVER: Netatalk is already installed."
else
echo "A2SERVER: Installing Netatalk (this will take a while)..."
# stop Netatalk and samba if running (during upgrade)
if [[ $(ps --no-headers -C afpd) ]]; then
sudo /etc/init.d/netatalk stop &> /dev/null
@ -74,25 +72,6 @@ else
touch /tmp/a2server-packageReposUpdated
fi
# not being used as of 1.2.9, but it's available if full URL to .deb package is supplied
getOldPackage () {
for url in $@; do
pkgFile=${url##*/}
pkgName=${pkgFile%%_*}
if ! dpkg -l $pkgName 2> /dev/null | grep -q '^ii'; then
if [[ $useExternalURL ]]; then
wget -qO "/tmp/${url##*/}" "$url"
fi
if [[ $? -ne 0 || ! -f "/tmp/${url##*/}" ]]; then
wget -qO "/tmp/${url##*/}" "${binaryURL}external/deb/${url##*/}"
fi
sudo dpkg -i "/tmp/${url##*/}"
sudo apt-get clean
rm "/tmp/${url##*/}"
fi
done
}
compileFromSource=1
urls=
while [[ $arch ]]; do
@ -185,7 +164,9 @@ else
./configure --enable-debian --enable-ddp --enable-a2boot
# uninstall Netatalk if already installed
[[ -f /usr/local/sbin/afpd ]] && sudo make uninstall
if [[ -f /usr/local/sbin/afpd ]]; then
sudo make uninstall
fi
# compile and install Netatalk
make
@ -198,7 +179,7 @@ else
fi
# --- Install MacIPgw
if ! hash macipgw &> /dev/null; then
if ! hash macipgw &>/dev/null; then
echo "A2SERVER: Installing TCP over AppleTalk (MacIP)..."
if [[ $arch && ! -f /tmp/a2server-compileAlways ]]; then
@ -282,12 +263,13 @@ sudo sed -i "s/#AFPD_GUEST=nobody/AFPD_GUEST=$USER/" /etc/default/netatalk
if [[ ! $(grep '^- -ddp.*uams_randnum.so' /usr/local/etc/netatalk/afpd.conf) ]]; then
# set up to allow Guest, Cleartext, RandNum, DHX, and DHX2 login
# disable DHX (DHCAST128) on Raspberry Pi, which refuses uams if the config string is too long
[[ -f /usr/bin/raspi-config ]] && dhx="" || dhx="uams_dhx.so,"
echo -n -e \
"- -ddp -tcp -uamlist uams_guest.so,uams_clrtxt.so,uams_randnum.so" \
| sudo tee -a /usr/local/etc/netatalk/afpd.conf > /dev/null
echo -e ",${dhx}uams_dhx2.so" \
| sudo tee -a /usr/local/etc/netatalk/afpd.conf > /dev/null
dhx=
if [[ ! -f /usr/bin/raspi-config ]]; then
dhx="uams_dhx.so,"
fi
sudo tee -a /usr/local/etc/netatalk/afpd.conf >/dev/null <<EOF
- -ddp -tcp -uamlist uams_guest.so,uams_clrtxt.so,uams_randnum.so",${dhx}uams_dhx2.so
EOF
fi
# replace home folder share and end of file mark with share placeholders
@ -298,7 +280,6 @@ sudo sed -i 's/^~/#share1\n\n#share2/' \
sudo sed -i 's/^:DEFAULT/#:DEFAULT/' \
/usr/local/etc/netatalk/AppleVolumes.default
# if [[ ! $(grep ^eth0 /usr/local/etc/netatalk/atalkd.conf) && ! $(grep ^wlan0 /usr/local/etc/netatalk/atalkd.conf) ]]; then
if [[ $(tac /usr/local/etc/netatalk/atalkd.conf | sed '/./,$!d' | head -1 | cut -c 1) == "#" ]]; then
# enable netatalk on the default network interface
# needs -router and -zone to prevent GS/OS AppleShare CDEV crash when used
@ -310,6 +291,7 @@ fi
if [[ $isRpi ]]; then
# blink LED upon netatalk startup
if [[ ! $(grep 'led0' /etc/init.d/netatalk) ]]; then
# FIXME Do this ... readably.
sudo sed -i ':a;N;$!ba;s/fi\n}/fi\n\n # blink LED on Raspberry Pi\n ([[ -e \/sys\/class\/leds\/ACT ]] \&\& led=ACT || led=led0; echo none > \/sys\/class\/leds\/$led\/trigger; for i in {1..20}; do echo 1 > \/sys\/class\/leds\/$led\/brightness; sleep 0.25; echo 0 > \/sys\/class\/leds\/$led\/brightness; sleep 0.25; done; echo mmc0 > \/sys\/class\/leds\/$led\/trigger) \&\n}/' /etc/init.d/netatalk
fi
fi
@ -323,7 +305,7 @@ fi
# 1.3.0: if GSFILES is being shared, make directory if not there
if grep -q '^/srv/A2SERVER/GSFILES' /usr/local/etc/netatalk/AppleVolumes.default; then
[[ -d /srv/A2SERVER/GSFILES ]] || mkdir -p /srv/A2SERVER/GSFILES;
mkdir -p /srv/A2SERVER/GSFILES
fi
# prior to 1.3.0:
@ -388,8 +370,8 @@ fi
sudo sed -i \
'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
mkdir -p /srv/A2SERVER/A2FILES
mkdir -p /srv/A2SERVER/.a2files
# set up ciopfs
if ! hash ciopfs &> /dev/null; then
@ -628,7 +610,7 @@ echo "A2SERVER: Netatalk is installed, configured, and running."
echo
# if atalkd isn't running (no AppleTalk), and this is a Rasbperry Pi:
if [[ ( ! $(ps aux | grep [a]talkd) ) && ( $isRpi ) ]]; then
if [[ ( ! $(pgrep atalkd) ) && $isRpi ]]; then
# if AppleTalk module exists, try to load it
if [[ -f /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko ]]; then # module present, but not loaded?

@ -148,27 +148,30 @@ updateP8YearTables () {
else
# perform patch
while (( $i < ${#files[@]} )); do
[[ ! -f "${files[$i]}" ]] && { (( i++ )); continue; }
[[ $patch1 ]] && echo -n -e ${patch1} | sudo dd of="${files[$i]}" seek=${offset1[$i]} bs=1 conv=notrunc 2> /dev/null
[[ $patch2 ]] && echo -n -e ${patch2} | sudo dd of="${files[$i]}" seek=${offset2[$i]} bs=1 conv=notrunc 2> /dev/null
if [[ ! -f "${files[$i]}" ]]; then
(( i++ ))
continue
fi
if [[ $patch1 ]]; then
echo -n -e ${patch1} | sudo dd of="${files[$i]}" seek=${offset1[$i]} bs=1 conv=notrunc 2>/dev/null
fi
if [[ $patch2 ]]; then
echo -n -e ${patch2} | sudo dd of="${files[$i]}" seek=${offset2[$i]} bs=1 conv=notrunc 2>/dev/null
fi
(( i++ ))
done
patched=0 # 0 is true
fi
return $patched
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="p8" bs=38 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="p8" bs=3958 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="ProDOS16 Image" bs=3110 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="ProDOS16 Image" bs=7030 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="Apple :2f:2fe Boot Blocks" bs=79 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="Apple :2f:2fe Boot Blocks" bs=7071 seek=1 conv=notrunc 2> /dev/null
cd "$wd"
}
# bail out on automated netboot setup unless -b is also specified
[[ -f /tmp/a2server-autoAnswerYes ]] && autoAnswerYes=1 || autoAnswerYes=
autoAnswerYes=
if [[ -f /tmp/a2server-autoAnswerYes ]]; then
autoAnswerYes=1
fi
netbootInstalled=
if [[ -f /usr/local/etc/netatalk/a2boot/ProDOS16\ Boot\ Blocks && \
@ -455,7 +458,9 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
# echo $entryIndex $entryCount ${scriptEntry[@]}
action=${scriptEntry[1]:0:1}
sourcePathMixed=$(tr ':' '/' <<< ${scriptEntry[5]})
[[ ${sourcePathMixed:0:1} != '/' ]] && sourcePathMixed="${pathPrefix}/$sourcePathMixed"
if [[ ${sourcePathMixed:0:1} != '/' ]]; then
sourcePathMixed="${pathPrefix}/$sourcePathMixed"
fi
sourcePath=$sourcePathMixed
targetPath=$gsosDir/$(tr ':' '/' <<< ${scriptEntry[6]})
# volumeName=$(cut -d/ -f 2 <<< $sourcePath)
@ -469,15 +474,17 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
echo "copying: $sourcePathMixed"
echo " to: $targetPath"
echo
[[ ! -d $targetParent ]] && mkdir -p $targetParent
mkdir -p $targetParent
cp -p ${gsosDir%/*}$sourcePath $targetPath
[[ ! -d $targetParent/.AppleDouble ]] && mkdir -p $targetParent/.AppleDouble
mkdir -p $targetParent/.AppleDouble
cp -p ${gsosDir%/*}$sourceParent/.AppleDouble/$sourceFile $targetParent/.AppleDouble/$targetFile
elif [[ $action == 3 || $action == 4 ]]; then
if [[ -f "$targetPath" ]]; then
echo "deleting $targetPath"
rm "$targetPath"
[[ -f $targetParent/.AppleDouble/$targetFile ]] && rm "$targetParent/.AppleDouble/$targetFile"
if [[ -f $targetParent/.AppleDouble/$targetFile ]]; then
rm "$targetParent/.AppleDouble/$targetFile"
fi
fi
fi
(( entryIndex++ ))
@ -511,17 +518,6 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
fi
fi
# if [[ ! $autoAnswerYes && (! $gsosInstall || $gsosInstall -lt 2) ]] && ! checkP8YearTables 603; then
# echo
# echo -n "Do you want to update the ProDOS 8 Thunderclock year table? "
# read
# fi
# if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
# updateP8YearTables 603
# elif [[ $gsosInstall -ge 2 ]]; then
# updateP8YearTables 60${gsosInstall}
# fi
# patch ProDOS 8 Thunderclock driver year table based on today's date
echo
echo "A2SERVER: Updating ProDOS 8 Thunderclock driver year table..."
@ -531,14 +527,26 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
updateP8YearTables $(python /tmp/netboot/clock.patch.py $(LANG=C date +"%a %m/%d/%y"))
gsosInstalled=""
[[ -f "$gsosDir/System/Start.GS.OS" ]] && gsosInstalled="GS/OS and "
if [[ -f "$gsosDir/System/Start.GS.OS" ]]; then
gsosInstalled="GS/OS and "
fi
p8ToolsInstalled=
[[ -f $diskToolsP8Dir/SHRINKIT && -f $diskToolsP8Dir/DSK2FILE && -f $diskToolsP8Dir/SYSUTIL ]] && p8ToolsInstalled=1
if [[ -f $diskToolsP8Dir/SHRINKIT && \
-f $diskToolsP8Dir/DSK2FILE && \
-f $diskToolsP8Dir/SYSUTIL ]]; then
p8ToolsInstalled=1
fi
gsosToolsInstalled=
[[ -f $imageToolsDir/Asimov && -f $gsosDir/System/System.Setup/MountIt && -f $imageToolsDir/GSHK ]] && gsosToolsInstalled=1
if [[ -f $imageToolsDir/Asimov && \
-f $gsosDir/System/System.Setup/MountIt && \
-f $imageToolsDir/GSHK ]]; then
gsosToolsInstalled=1
fi
toolsInstalled=
if [[ $gsosInstalled ]]; then
[[ $gsosToolsInstalled && $p8ToolsInstalled ]] && toolsInstalled=1
if [[ $gsosToolsInstalled && $p8ToolsInstalled ]]; then
toolsInstalled=1
fi
else
toolsInstalled=$p8ToolsInstalled
fi
@ -713,12 +721,25 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
fi
p8CommInstalled=
[[ -f $commDir/ProTERM/PROTERM && -f $commDir/Z.Link/Z.LINK && -f $commDir/ADTPro/ADTPRO && -f $commDir/ADTPro/VSDRIVE ]] && p8CommInstalled=1
if [[ -f $commDir/ProTERM/PROTERM && \
-f $commDir/Z.Link/Z.LINK && \
-f $commDir/ADTPro/ADTPRO && \
-f $commDir/ADTPro/VSDRIVE ]]; then
p8CommInstalled=1
fi
gsosCommInstalled=
[[ -f $commDir/Spectrum/Spectrum && -f $commDir/SAM2/SAM2 && -f $commDir/SAFE2/SAFE2 && -f $commDir/SNAP/SNAP && -f $gsosDir/System/CDevs/TCPIP ]] && gsosCommInstalled=1
if [[ -f $commDir/Spectrum/Spectrum && \
-f $commDir/SAM2/SAM2 && \
-f $commDir/SAFE2/SAFE2 && \
-f $commDir/SNAP/SNAP && \
-f $gsosDir/System/CDevs/TCPIP ]]; then
gsosCommInstalled=1
fi
commInstalled=
if [[ $gsosInstalled ]]; then
[[ $gsosCommInstalled && $p8CommInstalled ]] && commInstalled=1
if [[ $gsosCommInstalled && $p8CommInstalled ]]; then
commInstalled=1
fi
else
commInstalled=$p8CommInstalled
fi
@ -871,7 +892,9 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
mkdir -p /tmp/netboot/safe2
cd /tmp/netboot/safe2
if [[ $useExternalURL ]]; then
[[ ! $safeUrl ]] && safeUrl="http://www.speccie.co.uk/speccie/software/safe229.bxy"
if [[ ! $safeUrl ]]; then
safeUrl="http://www.speccie.co.uk/speccie/software/safe229.bxy"
fi
wget -qO safe2.bxy "$safeUrl"
cppo -s -ad safe2.bxy . &> /dev/null
fi
@ -905,7 +928,9 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
mkdir -p /tmp/netboot/sam2
cd /tmp/netboot/sam2
if [[ $useExternalURL ]]; then
[[ ! $samUrl ]] && samUrl="http://www.speccie.co.uk/speccie/software/sam205.bxy"
if [[ ! $samUrl ]]; then
samUrl="http://www.speccie.co.uk/speccie/software/sam205.bxy"
fi
wget -qO sam2.bxy "$samUrl"
cppo -s -ad sam2.bxy . &> /dev/null
fi
@ -942,7 +967,9 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
mkdir -p /tmp/netboot/snap
cd /tmp/netboot/snap
if [[ $useExternalURL ]]; then
[[ ! $snapUrl ]] && snapUrl="http://www.speccie.co.uk/speccie/software/snap118.bxy"
if [[ ! $snapUrl ]]; then
snapUrl="http://www.speccie.co.uk/speccie/software/snap118.bxy"
fi
wget -qO snap.bxy "$snapUrl"
cppo -s -ad snap.bxy . &> /dev/null
fi

@ -4,7 +4,10 @@
# Set up A2SERVER to support Samba (Windows File Sharing)
# this script can also be used if new shares are introduced
[[ -f /tmp/a2server-autoAnswerYes ]] && autoAnswerYes=1 || autoAnswerYes=
autoAnswerYes=
if [[ -f /tmp/a2server-autoAnswerYes ]]; then
autoAnswerYes=1
fi
if [[ ! $autoAnswerYes || -f /tmp/a2server-setupWindowsSharing ]]; then
@ -19,7 +22,9 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupWindowsSharing ]]; then
sudo true
sudo update-rc.d samba defaults &> /dev/null
[[ ! -f /etc/init.d/samba ]] && installSamba=1
if [[ ! -f /etc/init.d/samba ]]; then
installSamba=1
fi
if (( $installSamba )); then
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
@ -38,12 +43,17 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupWindowsSharing ]]; then
sudo /etc/init.d/samba start &> /dev/null
workgroup=$(grep -o "^ workgroup = .*$" /etc/samba/smb.conf 2> /dev/null | cut -c 16-)
[[ $workgroup ]] || workgroup="WORKGROUP"
if [[ $workgroup ]]; then
workgroup="WORKGROUP"
fi
if [[ ! $autoAnswerYes ]]; then
echo
echo "Enter workgroup name (or press return for '${workgroup}'): "
read
[[ $REPLY ]] && workgroup=$REPLY
# FIXME validation?
if [[ $REPLY ]]; then
workgroup=$REPLY
fi
fi
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
@ -59,13 +69,15 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupWindowsSharing ]]; then
if [[ $(grep $sharename /etc/samba/smb.conf) ]]; then
echo "A2SERVER: $sharename is already set up for Windows file sharing."
else
echo "[$sharename]" | sudo tee -a /etc/samba/smb.conf > /dev/null
echo " path = /srv/A2SERVER/$sharename" | sudo tee -a /etc/samba/smb.conf > /dev/null
echo " browsable = yes" | sudo tee -a /etc/samba/smb.conf > /dev/null
echo " guest ok = yes" | sudo tee -a /etc/samba/smb.conf > /dev/null
echo " read only = no" | sudo tee -a /etc/samba/smb.conf > /dev/null
echo " create mask = 0666" | sudo tee -a /etc/samba/smb.conf > /dev/null
echo " force user = $USER" | sudo tee -a /etc/samba/smb.conf > /dev/null
sudo tee -a /etc/samba/smb.conf >/dev/null <<EOF
[$sharename]
path = /srv/A2SERVER/$sharename
browsable = yes
guest ok = yes
read only = no
create mask = 0666
force user = $USER
EOF
echo "A2SERVER: $sharename has been set up for Windows file sharing."
fi
done

@ -6,18 +6,28 @@
echo
userPw=$(sudo grep "^$USER" /etc/shadow | cut -f 2 -d ':')
[[ $userPw == "$(echo 'apple2' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]] && isApple2Pw=1 || isApple2Pw=
[[ $userPw == "$(echo 'raspberry' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]] && isRaspberryPw=1 || isRaspberryPw=
isApple2Pw=
if [[ $userPw == "$(echo 'apple2' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]]; then
isApple2Pw=1
fi
isRaspberryPw=
if [[ $userPw == "$(echo 'raspberry' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]]; then
isRaspberryPw=1
fi
password="your password"
[[ $isApple2Pw ]] && password="'apple2'"
[[ $isRaspberryPw ]] && password="'raspberry'"
isDebian=
b_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian' && [[ ( -f /etc/debian_version ) && ( $(cut -d . -f 1 < /etc/debian_version) -ge "7" ) ]] && isDebian=1
if lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian'; then
if [[ $(cut -d . -f 1 < /etc/debian_version) -ge "7" ]]; then
isDebian=1
fi
fi
if [[ $isDebian ]]; then
if { lspci 2> /dev/null | grep -q VirtualBox; }; then
if lspci 2>/dev/null | grep -q VirtualBox; then
echo "A2SERVER: Disabling VirtualBox console screen blanking..."
sudo sed -i 's/^BLANK_DPMS=off/BLANK_DPMS=on/' /etc/kbd/config
sudo sed -i 's/^BLANK_TIME=[^0].$/BLANK_TIME=0/' /etc/kbd/config

@ -9,7 +9,7 @@
# to download and execute, type:
# wget ivanx.com/a2server/setup; source setup
a2serverVersion="150"
a2serverVersion="151"
# Ensure URL we'll use ends in a /
case "$A2SERVER_SCRIPT_URL" in
@ -27,7 +27,13 @@ isRpi=
[[ -f /usr/bin/raspi-config ]] && isRpi=1
isDebian=
lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian' && [[ ( -f /etc/debian_version ) && ( $(cut -d . -f 1 < /etc/debian_version) -ge "7" ) ]] && isDebian=1
if lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian'; then
if [[ -f /etc/debian_version ]]; then
if [[ $(cut -d . -f 1 < /etc/debian_version) -ge "7" ]]; then
isDebian=1
fi
fi
fi
if [ -f /usr/local/etc/A2SERVER-version ]; then
installedVersion="$(cat /usr/local/etc/A2SERVER-version)"
@ -73,13 +79,16 @@ while [[ $1 ]]; do
compileAlways="-c"
touch /tmp/a2server-compileAlways
elif [[ $1 == "-os" || $1 == "os" ]]; then
# elif [[ ${1,,} == "rasppleii" || ${1,,} == "raspple" || ${1,,} == "rasappleii" || ${1,,} == "rasapple" || ${1,,} == "raspple2" || ${1,,} == "rasapple2" ]]; then
shift
updateRasppleII=1
elif [[ $1 == "-v" ]]; then
shift
# Version was already printed
[[ $0 == "-bash" ]] && return 1 || exit 1
if [[ $0 == "-bash" ]]; then
return 1
else
exit 1
fi
elif [[ $1 ]]; then
echo "options:"
echo "-v: display installed and available versions, then exit"
@ -92,7 +101,11 @@ while [[ $1 ]]; do
if [[ $isRpi ]]; then
echo "-os: update Raspbian OS, A2CLOUD, A2SERVER, and Apple II Pi"
fi
[[ $0 == "-bash" ]] && return 1 || exit 1
if [[ $0 == "-bash" ]]; then
return 1
else
exit 1
fi
fi
done
@ -100,10 +113,14 @@ if [[ $updateRasppleII ]]; then
echo "A2SERVER: Updating Raspple II (takes up to an hour)..."
wget -qO /tmp/raspbian-update "${A2SERVER_SCRIPT_URL}scripts/raspbian-update.txt"
source /tmp/raspbian-update a2cloud a2server $autoAnswerYes $skipRepoUpdate
[[ $0 == "-bash" ]] && return 0 || exit 0
if [[ $0 == "-bash" ]]; then
return 0
else
exit 0
fi
fi
if { [[ -f /usr/local/etc/A2SERVER-version ]] && (( $(head -c 3 /usr/local/etc/A2SERVER-version) < 110 )); }; then
if [[ -f /usr/local/etc/A2SERVER-version && $(head -c 3 /usr/local/etc/A2SERVER-version) -lt 110 ]]; then
echo
echo "WARNING: The current A2SERVER installer scripts haven't been tested for"
echo "updating the earlier version of A2SERVER that you have. A fresh install"
@ -114,7 +131,7 @@ fi
a2server_update=0
doSetup=1
if { [[ -f /usr/local/etc/A2SERVER-version ]] && (( $(head -c 3 /usr/local/etc/A2SERVER-version) < 150 )); }; then
if [[ -f /usr/local/etc/A2SERVER-version && $(head -c 3 /usr/local/etc/A2SERVER-version) -lt 150 ]]; then
a2server_update=1
fi
@ -126,7 +143,6 @@ if [[ $isRpi ]]; then #supported Raspbian? (16-Feb-15, 20-Jun-14, 09-Jan-14, etc
-960832a6c2590635216c296b6ee0bebf67b21d50-
-2a329e0c7d8ea19c085bac5633aa4fccee0f21be-"
[[ "$fwsupported" == *-$fwhash-* ]] && unsupportedOS=
# [[ ($fwhash == "8aca5762") || ($fwhash == "462f3e3f476f7b6") || ($fwhash == "c32bc633039cd9") || ($fwhash == "9d34d0475f9") || ($fwhash == "d4f5315cfac4e") || ($fwhash == "6f4a90c8cb8817f") || ($fwhash == "5dd9b4962e") || ($fwhash == "17c8799375") ]] && unsupportedOS=
elif [[ $isDebian ]]; then # supported Debian?
debianVersion=$(cat /etc/debian_version)
debianSupported="-8.2- -7.9- -7.8- -7.6- -7.3-"
@ -180,9 +196,11 @@ if (( $doSetup )); then
if (( $doSetup )); then
isApple2Pw=
isRaspberryPw=
userPw=$(sudo grep "^$USER" /etc/shadow | cut -f 2 -d ':')
[[ $userPw == "$(echo 'apple2' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]] && isApple2Pw=1 || isApple2Pw=
[[ $userPw == "$(echo 'raspberry' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]] && isRaspberryPw=1 || isRaspberryPw=
[[ $userPw == "$(echo 'apple2' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]] && isApple2Pw=1
[[ $userPw == "$(echo 'raspberry' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]] && isRaspberryPw=1
password="your password"
[[ $isApple2Pw ]] && password="'apple2'"