6 Commits
1.3.0 ... 1.3.1

4 changed files with 328 additions and 28 deletions

View File

@@ -358,6 +358,7 @@ if [[ -d /srv/A2SERVER/A2FILES && ! -d /srv/A2SERVER/.a2files ]]; then
mkdir /srv/A2SERVER/A2FILES
sudo sed -i 's/casefold:toupper //' /usr/local/etc/netatalk/AppleVolumes.default 2> /dev/null
sudo sed -i 's/^VOLCASEFOLD:.*/VOLCASEFOLD:/' /srv/A2SERVER/.a2files/.appledesktop/.volinfo 2> /dev/null
sudo sed -i 's|/media/A2SHARED/A2FILES|/srv/A2SERVER/A2FILES|' /srv/A2SERVER/.a2files/.appledesktop/.volinfo 2> /dev/null
fi
# 1.3.0: remove GSFILES if empty
@@ -380,7 +381,7 @@ fi
# set up A2FILES case-insensitive share (for ProDOS 8 files, and GS/OS system)
sudo sed -i \
's/^#share2/\/srv\/A2SERVER\/A2FILES\ A2FILES options:prodos\ ea:ad/' \
/usr/local/etc/netatalk/AppleVolumes.default
/usr/local/etc/netatalk/AppleVolumes.default
[[ -d /srv/A2SERVER/A2FILES ]] || mkdir -p /srv/A2SERVER/A2FILES
[[ -d /srv/A2SERVER/.a2files ]] || mkdir -p /srv/A2SERVER/.a2files
@@ -458,6 +459,8 @@ fi
# to make Netatalk start up when the server boots:
sudo update-rc.d netatalk defaults &> /dev/null
# prepare shared volumes for use
afpsync -v < /dev/null
# --- Setting up users

View File

@@ -9,12 +9,12 @@
# Ensure URL we'll use ends in a /
case "$A2SERVER_SCRIPT_URL" in
*/) scriptURL="$A2SERVER_SCRIPT_URL" ;;
*) scriptURL="${A2SERVER_SCRIPT_URL:-http://ivanx.com/a2server}/" ;;
*/) scriptURL="$A2SERVER_SCRIPT_URL" ;;
*) scriptURL="${A2SERVER_SCRIPT_URL:-http://ivanx.com/a2server}/" ;;
esac
case "$A2SERVER_BINARY_URL" in
*/) binaryURL="$A2SERVER_BINARY_URL" ;;
*) binaryURL="${A2SERVER_BINARY_URL:-http://ivanx.com/a2server/files}/" ;;
*/) binaryURL="$A2SERVER_BINARY_URL" ;;
*) binaryURL="${A2SERVER_BINARY_URL:-http://ivanx.com/a2server/files}/" ;;
esac
useExternalURL=1
[[ $A2SERVER_NO_EXTERNAL ]] && useExternalURL=
@@ -36,6 +36,41 @@ adtproDir=$commDir/ADTPro
gsosURL="http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Apple_II/Apple_IIGS_System_6.0.1/"
gsosBackupURL="http://archive.org/download/download.info.apple.com.2012.11/download.info.apple.com.2012.11.zip/download.info.apple.com%2FApple_Support_Area%2FApple_Software_Updates%2FEnglish-North_American%2FApple_II%2FApple_IIGS_System_6.0.1%2F"
# --- bashByter library routines
decToChar () {
# converts single-byte decimal value to equivalent character
# arg: decimal number from 0-255
# out: one character
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
[[ $1 ]] || return 11
[[ $2 ]] && return 8
[[ ( $(printf %d "$1" 2> /dev/null ) == $1 ) \
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
# args are valid
echo -n -e "\x$(printf %02X "$1")"
}
charToDec () {
# converts single character to corresponding decimal value
# stdin OR arg: one character
# [arg overrides stdin; stdin is required for NUL (0) or LF (0x0A)]
# out: decimal value from 0-255
#exit: 8=extraneous arg, 9=invalid stdin,
# 11=missing stdin/arg, 21=invalid arg
[[ ( ! -t 0 ) && $1 ]] && { cat > /dev/null; return 8; }
[[ ( -t 0 ) ]] && { [[ $2 ]] && return 8; [[ $1 ]] || return 11; }
# arg/stdin is potentially valid (additional check below)
charX="$1X"; [[ $1 ]] || charX="$(cat; echo -n 'X';)"
[[ ${#charX} -le 2 ]] || return $(( $([[ $1 ]]; echo $?) ? 9 : 21 ))
# above line verifies that arg/stdin is valid
[[ ${#charX} -ne 2 ]] && { echo -n 0; return 0; }
echo -n "${charX:0:1}" | od -t u1 | \
head -1 | sed 's/[0\ ]*//' | tr -d ' \n'
}
# --- end bashByter
cpAD () {
# copy a file with its AppleDouble component in ./.AppleDouble
# arg1 = source path, # arg2 = destination directory (not filename)
@@ -52,18 +87,87 @@ cpAD () {
[[ $afpsync ]] && afpsync -v > /dev/null
}
checkP8YearTables () {
updateP8YearTables -c $1
return $?
}
updateP8YearTables () {
# Geoff Body and Andrew Roughan helped Joseph Carter with this one
# JC: Geoff Body and Andrew Roughan helped Joseph Carter with this one
# Update ProDOS 8 year table (and spalsh date because may as well)
# Effectively, we're turning p8 into the 6.0.3 version here.
# Effectively, we're turning p8 into the 6.0.2 or 6.0.3 version here.
#
# ID: updates the year tables for the Thunderclock driver in ProDOS 8;
# calculated from the day of week and date, as year is unavailable.
# accepts optional arguments for custom patches
# arg1 = year table, comma separated
# arg2 = date string for ProDOS splash screen in format "dd-Mmm-yy"
# OR for presets, arg1=602 or arg1=603, arg2 is empty
check=
if [[ $1 == "-c" ]]; then
check=1
shift
fi
patch1=""
patch2=""
if [[ $1 == "602" ]]; then
patch1=$(echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d")
patch2=$(echo -n -e "\xb2\xb2\xad\xca\xf5\xee\xad\xb1\xb5")
elif [[ $1 == "603" ]]; then
patch1=$(echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d")
patch2=$(echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5")
elif [[ $1 ]]; then # year table supplied as seven comma-separated values
for year in $(tr "," " " <<< $1); do
patch1=${patch1}$(echo -n -e "\x$(printf %02X $year)")
done
if [[ $2 ]]; then # splash screen date supplied, convert to high-ascii bytes
for c in $(sed "s/./& /g" <<< $2); do
patch2=${patch2}$(decToChar $(( $(charToDec $c) + 128 )))
done
fi
fi
wd=$PWD
cd /usr/local/etc/netatalk/a2boot
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
files=("p8" "ProDOS16 Image" "Apple :2f:2fe Boot Blocks" "$gsosDir/System/P8")
offset1=(3958 7030 7071 3958) # splash screen date
offset2=(38 3110 79 38) # year table
i=0
if [[ $check ]]; then
# check if patched -- we're not actually doing this any more; we're always patching
patched=0 # 0 is true in this case since it's the return value
while (( $i < ${#files[@]} )); do
[[ ! -f "${files[$i]}" ]] && { (( i++ )); continue; }
if [[ ! $patch1 || $patch1 != $(sudo dd if="${files[$i]}" skip=${offset1[$i]} bs=1 count=7 2> /dev/null) ]]; then
patched=1 # 1 is false
break
fi
if [[ ! $patch2 || $patch2 != $(sudo dd if="${files[$i]}" skip=${offset2[$i]} bs=1 count=9 2> /dev/null) ]]; then
patched=1 # 1 is false
break
fi
(( i++ ))
done
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
(( 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"
}
@@ -376,14 +480,23 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
fi
fi
if [[ ! $autoAnswerYes && gsosInstall -lt 2 ]]; then
echo
echo -n "Do you want to update the ProDOS 8 year tables? "
read
fi
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
updateP8YearTables
fi
# if [[ ! $autoAnswerYes && (! $gsosInstall || $gsosInstall -lt 2) ]] && ! checkP8YearTables 603; then
# echo
# echo -n "Do you want to update the ProDOS 8 Thunderclock year tables? "
# 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 tables..."
mkdir -p /tmp/netboot
wget -qO /tmp/netboot/clock.patch.py "${scriptURL}scripts/clock.patch.py"
updateP8YearTables $(python /tmp/netboot/clock.patch.py $(LANG=C date +"%a %m/%d/%y"))
if [[ ! $autoAnswerYes ]]; then
echo

180
scripts/clock.patch.py Executable file
View File

@@ -0,0 +1,180 @@
#!/usr/bin/env python
'''CLOCK.PATCH by Greg Branche implemented in Python 2/3 for A2SERVER
This is a line-for-line conversion of an edited version of CLOCK.PATCH
from the System Tools 2 disk in GS/OS 6.0.1. It's not good Python,
but I thought it would be an interesting exercise. In general
I have tried replicate each line as closely to BASIC as possible.
Because BASIC substrings are 1-based and python's are 0-based, various
indexes are minus one of their BASIC equivalents.
The one change is that you can optionally pass the day and date by
command line argument (e.g "Wed 3/13/15"). I also improved error
checking. These are in the BASIC lines that don't end in 0.
Rather than modifying PRODOS, this outputs a string of comma-separated
year values for a calling script (the a2server-setup installer),
followed by a space and a dd-Mmm-yy date string.
'''
# imports for python 3 code compatibility
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import division
# other imports
import sys
import datetime
# substitute raw_input for input in Python2
try: input = raw_input
except NameError: pass
dow_str = None
day = None
if len(sys.argv) > 2:
dow_str = sys.argv[1] # day of week passed on command line
day = sys.argv[2] # date passed on command line
# 60000 REM # of days in each month
data = [31,28,31,30,31,30,31,31,30,31,30] # 60010 DATA 31,28,31,30,31,30,31,31,30,31,30
# 60020 REM Names of days of week
data += [ # 60030 DATA SUN,MON,TUE,WED,THU,FRI,SAT
"SUN","MON","TUE","WED","THU","FRI","SAT"]
data = iter(data)
# 110 REM cu() = cumulative # of days in year
cu = [0] * 13 # 120 DIM CU(12)
# 130 REM fill array with # of days in year
cu[1] = 0 # 140 CU(1) = 0: REM January
for i in range(2,13): # 150 FOR I = 2 TO 12
x = next(data) # 160 READ X
cu[i] = cu[i-1] + x # 170 CU(I) = CU(I - 1) + X
# 180 NEXT I
# 200 REM DN$() = Names for days of week
dn = [""] * 8 # 210 DIM DN$(7)
# 220 REM fill array with names of days of week
for i in range(1,8): # 230 FOR I = 1 TO 7
dn[i] = next(data) # 240 READ DN$(I)
# 250 NEXT I
# 270 REM yt() is the year table values
yt = [0] * 8 # 280 DIM YT(7)
def mod7(x): # 340 DEF FN MOD7(X) = INT (((X / 7) - INT (X / 7)) * 7 + .5)
return int(((x / 7) - int(x / 7)) * 7 + .5)
def find_slash_pos(day): # 799 REM Finds position of / within date string
x = -1 # 800 X = 0: REM On exit, contains position of /, or 0 if none found
for i in range(0,3): # 810 FOR I = 1 TO 3
if day[i:i+1] == "/": x = i; break # 820 IF MID$ (DAY$,I,1) = "/" THEN X = I:I = 3
# 830 NEXT I
return x # 840 RETURN
while True: # 999 REM get the user's input and convert
if not day:
print( # 1010 PRINT "Please enter today's date (mm/dd/yy)"
"Please enter today's date (mm/dd/yy)")
day = input("-> ") # 1020 INPUT "-> ";DAY$
x = find_slash_pos(day) # 1030 GOSUB 800: REM find slash separator
input_ok = False
while not input_ok:
if not (x != -1): # 1040 IF X < > 0 THEN 1080
print( # 1050 PRINT "Invalid date entered. Please try again."; CHR$ (7)
"Invalid date entered. Please try again.\x07")
break # 1060 GOTO 1010
# 1070 REM Convert month value to numeric variable
mo = int(day[0:0+x]) # 1080 MO = VAL ( MID$ (DAY$,1,X - 1))
day = day[x+1:] # 1090 DAY$ = MID$ (DAY$,X + 1)
if mo < 1 or mo > 12: x = -1; continue # 1100 IF MO < 1 OR MO > 12 THEN 1050: REM Range check the month value
x = find_slash_pos(day) # 1110 GOSUB 800: REM Parse out the current day
if x == -1: continue # 1120 IF X = 0 THEN 1050
# 1130 REM Convert day string into numeric value
da = int(day[0:0+x]) # 1140 DA = VAL ( MID$ (DAY$,1,X - 1))
day = day[x+1:] # 1150 DAY$ = MID$ (DAY$,X + 1)
if da < 1 or da > 31: x = -1; continue # 1160 IF DA < 1 OR DA > 31 THEN 1050: REM Range check the day value
if mo == 2 and da > 29: # 1161 IF MO = 2 AND DA > 29 THEN 1050
x = -1; continue
if (mo == 4 or # 1162 IF (MO = 4 OR MO = 6 OR MO = 9 OR MO = 11) AND DA > 30 THEN 1050
mo == 6 or
mo == 9 or
mo == 11): x = -1; continue
# 1170 REM Convert year string into numeric value
yr = int(day) # 1180 YR = VAL (DAY$)
if yr < 0 or yr > 99: x = -1; continue # 1190 IF YR < 0 OR YR > 99 THEN 1050: REM Only allow 0-99
if yr > 39: yr = yr + 1900 # 1200 IF YR > 39 THEN YR = YR + 1900: REM 40-99 must be 1940-1999
if yr < 40: yr = yr + 2000 # 1210 IF YR < 40 THEN YR = YR + 2000: REM 0-39 must be 2000-2039
if ((yr / 4) != int(yr / 4) and # 1211 IF ((YR / 4) < > INT(YR / 4)) AND MO = 2 AND DA > 28 THEN 1050
mo == 2 and
da > 28): x = -1; continue
input_ok = True
if x != -1: break
else: dow_str = ""; day = ""
while True:
if not dow_str:
print(
"Please enter the day of the week") # 1230 PRINT "Please enter the day of the week"
dow_str = input("(e.g. Wed) -> ") # 1240 INPUT "(e.g. Wed) -> ";DOW$
input_ok = False
while not input_ok:
if not (len(dow_str) >= 3): # 1250 IF LEN (DOW$) > = 3 THEN 1270: REM Must be at least 3 characters
print( # 1260 PRINT "Invalid day of week. Please try again."; CHR$ (7): GOTO 1230
"Invalid day of week. Please try again.\x07")
break
if len(dow_str) > 3: # 1270 IF LEN (DOW$) > 3 THEN DOW$ = LEFT$ (DOW$,3)
dow_str = dow_str[0:0+3]
# 1280 REM Shift any lower case letters to upper case
b = "" # 1290 B$ = ""
for i in range(0,3): # 1300 FOR I = 1 TO 3
a = dow_str[i:i+1] # 1310 A$ = MID$ (DOW$,I,1)
if ( # 1320 IF ASC (A$) > = ASC ("a") AND ASC (A$) < = ASC ("z") THEN A$ = CHR$ ( ASC (A$) - ( ASC ("a") - ASC ("A")))
ord(a) >= ord("a") and ord(a) <= ord("z")): a = chr(ord(a) - (ord("a") - ord("A")))
b = b + a # 1330 B$ = B$ + A$
# 1340 NEXT I
dow_str = b # 1350 DOW$ = B$
# 1360 REM Now convert day-of-week string to numeric value
dow_num = 0 # 1370 DOW = 0
for i in range (1,8): # 1380 FOR I = 1 TO 7
if dow_str == dn[i]: # 1390 IF DOW$ = DN$(I) THEN DOW = I:I = 7
dow_num = i; i = 7
# 1400 NEXT I
if dow_num == 0: dow_str = ""; continue # 1410 IF DOW = 0 THEN 1260
input_ok = True
if len(dow_str) >= 3: break
else: dow_str = ""; day = ""
# 1430 REM Calculate the number of days so far this year
dys = da + cu[mo] # 1440 DYS = DA + CU(MO)
oyr = yr
# 1450 REM Must account for extra day in leap year
if ((yr / 4) == int(yr / 4)) and (mo > 2): # 1460 IF (YR / 4) = INT (YR / 4) AND MO > 2 THEN DYS = DYS + 1
dys = dys + 1
# 1480 REM Now calculate the index to use to fill in the table
idx = dow_num - mod7(dys) + 1 # 1490 IDX = DOW - FN MOD7(DYS) + 1
idx = abs(idx - 10) # 1500 IDX = ABS (IDX - 10)
if idx > 7: idx = idx - 7 # 1510 IF IDX > 7 THEN IDX = IDX - 7
# 1530 REM Now we can fill in the year table
for i in range(1,8): # 1540 FOR I = 1 TO 7
if '_i' in vars() and i < (_i + 1): continue # python: simulate change of i within loop
x = yr - 1900 # 1550 X = YR - 1900
if x >= 100: x = x - 100 # 1560 IF X > = 100 THEN X = X - 100
yt[idx] = x # 1570 YT(IDX) = X: REM store the year into table
idx = idx - 1 # 1580 IDX = IDX - 1
if idx < 1: idx = 7 # 1590 IF IDX < 1 THEN IDX = 7
if not ((yr / 4) != int(yr / 4)): # 1600 IF (YR / 4) < > INT (YR / 4) THEN 1660: REM not a leap year
i = i + 1; _i = i # 1610 I = I + 1: REM update index
if i > 7: continue # 1620 IF I > 7 THEN 1670: REM if entire array done, exit
yt[idx] = x # 1630 YT(IDX) = X: REM duplicate entry for leap year
idx = idx - 1 # 1640 IDX = IDX - 1
if idx < 1: idx = 7 # 1650 IF IDX < 1 THEN IDX = 7
yr = yr + 1 # 1660 YR = YR + 1
# 1670 NEXT I
print(",".join([str(x) for x in yt[1:]]) + " " +
str(da).encode("L1").decode("L1").zfill(2) + "-" +
datetime.date(1900, mo, 1).strftime('%b') + "-" +
str(oyr).encode("L1").decode("L1")[2:])

View File

@@ -497,7 +497,8 @@ def processDir(arg1, arg2=None, arg3=None, arg4=None, arg5=None):
g.PDOSPATH_INDEX += 1
g.PDOSPATH_SEGMENT = g.PDOSPATH[g.PDOSPATH_INDEX]
else:
print(g.DIRPATH)
pass
# print(g.DIRPATH)
while (pe < entryCount):
if (getStorageType(arg1, e) > 0):
#print(pe, e, entryCount)
@@ -540,7 +541,7 @@ def processEntry(arg1, arg2):
if (not g.PDOSPATH_INDEX or
g.activeFileName.upper() == g.PDOSPATH_SEGMENT.upper()):
# if ProDOS directory, not file
if (not g.SHK and getStorageType(arg1, arg2) == 13):
if not g.PDOSPATH_INDEX:
@@ -559,10 +560,17 @@ def processEntry(arg1, arg2):
g.targetDir = g.targetDir.rsplit("/", 1)[0]
g.ADdir = (g.targetDir + "/.AppleDouble")
else: # ProDOS or DOS 3.3 file either from image or ShrinkIt archive
dirPrint = ""
if g.DIRPATH:
dirPrint = g.DIRPATH + "/"
else:
if g.SHK:
if ("/".join(dirName.split('/')[3:])):
dirPrint = ("/".join(dirName.split('/')[3:]) + "/")
if (not g.extractFile or
(os.path.basename(g.extractFile.lower()) ==
origFileName.split('#')[0].lower())):
print(" " + g.activeFileName.split("#")[0] +
print(dirPrint + g.activeFileName.split("#")[0] +
("+" if (g.shk_hasrf or
(not g.SHK and getStorageType(arg1, arg2) == 5))
else "") +
@@ -1227,10 +1235,6 @@ if g.SHK:
makedirs(g.targetDir)
if g.AD:
makedirs(g.ADdir)
if not g.extractFile:
print("/".join(dirName.split('/')[3:])
if "/".join(dirName.split('/')[3:])
else "(top level)")
for fname in sorted(fileList):
g.shk_hasrf = ""
g.shk_rfork = False