411 REFERENCE · Wikibooks
Oberon/A2/MyA2
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
MyA2 () { \
#!/usr/bin/ash
# A function or script to start UnixAos or repository based A2 with
# a working directory which can be in a removable flash store.
# A flash store is accommodated in multiple machines by copying
# machine specific configurations into Configuration.XML and
# Oberon.Text.
#
# Conditions for this to work.
# * The volume containing the working files has a reliable identity.
# All Unix-like systems recognize a UUID. Refer to lsblk and blkid.
# * If /etc/fstab has a specification for the working volume it
# should be consistent with the names and mount command below. Eg.
# UUID=40d81923-8f9d-4964-b724-87bcf2731432a /home/me/A ext2 defaults,user,users,exec,noauto 0 0
# * The user can fsck the working filesystem.
# A line such as the following may be required in /etc/sudoers.d/sudoers.
# me mycomputer = NOPASSWD: /sbin/fsck
# Test fsck interactively.
# * If the working volume is removeable, the user can mount it.
# Note the user option in /etc/fstab.
# * Prior to revision 10272, UnixAos attempts to create the link
# <workingDirectory>/.aoshome to /usr/aos but the FAT file system
# doesn't provide links. Resolved by reformatting to ext2.
# Ext2 in Wikipedia.
#
# UUID of a stainless steel Kingston USB store.
workingVolume=40d81969-8f9d-4964-b214-87bcf273192a
printf "The UUID assigned to 'workingVolume' is %s.\n" "$workingVolume"
#
easyosWorkingDirectory=/mnt/A
printf "easyosWorkingDirectory=%s\n" "$easyosWorkingDirectory"
devuanWorkingDirectory=/mnt/A
printf "devuanWorkingDirectory=%s\n" "$devuanWorkingDirectory"
#
# For UnixAOS preceding revision.10272.
oldAosStartScript=/usr/bin/aos
printf "oldAosStartScript=%s\n" "$oldAosStartScript"
# For UnixAOS revision.10272.
newAosStartScript=/usr/local/bin/a2
printf "newAosStartScript=%s\n" "$newAosStartScript"
# For repository based A2.
# repositoryStartScript=<somewhere>/<repository>/<platform>/<script>
if [ "$(getconf LONG_BIT)" = "32" ]; then
repositoryStartScript=/mnt/A/A2/Linux32/a2.sh
elif [ "$(getconf LONG_BIT)" = "64" ]; then
repositoryStartScript=/mnt/A/A2/Linux64/a2.sh
else
printf "Neither a Linux 32 bit nor Linux 64 bit system.\n"
fi
printf "repositoryStartScript=%s\n" "$repositoryStartScript"
#
# For any hostname violating Oberon file name syntax, make a conformant name.
# https://tldp.org/LDP/abs/html/testconstructs.html
if [[ $(hostname) = xo-53-1d-bb* ]]; then
h="xo"
elif [[ $(hostname) = joule* ]]; then
h="joule"
# Add more cases here.
else
h=$(hostname --short)
fi
printf "Shortened hostname, h = $h\n"
A2 () {
contextDir=$PWD
cd $workingDirectory
printf "Switched to working directory.\n"
if ! test -f Configuration.$h.XML ; then
printf "Configuration.$h.XML not present in %s. Aborting.\n" "$workingDirectory"
else
printf "Copying Configuration.$h.XML to Configuration.XML.\n"
/bin/cp Configuration.$h.XML Configuration.XML
if ! test -f Oberon.$h.Text ; then
printf "Oberon.$h.Text not present in $workingDirectory. Aborting.\n"
else
printf "Copying Oberon.$h.Text to Oberon.Text.\n"
/bin/cp Oberon.$h.Text Oberon.Text
/bin/rm --force --verbose AOS*.Log
/bin/rm --force --verbose Trap*.txt
/bin/rm --force --verbose .tmp.*
printf "Starting A2 system.\n"
$startScript
fi
fi
cd $contextDir
printf "MyA2 exited normally.\n"
}
EvaluateWorkingVolume () {
printf "startScript=%s\n" "$startScript"
printf "Search for working volume can take a few seconds.\n"
if ! lsblk -alno UUID | grep -q $workingVolume ; then
printf "The UUID assigned to the workingVolume variable is not available. Aborting.\n"
printf "\n"
printf "Check that the intended working volume is connected.\n"
printf "Execute a command such as 'blkid /dev/sdXn' to obtain the UUID.\n"
printf "To correct the UUID assigned to 'workingVolume', edit the declaration of \n"
printf "this MyA2 function, declare with a shell command such as '. ShellFunctions' \n"
printf "and try MyA2 again.\n"
else
printf "$workingVolume containing working files is connected.\n"
if test -n "$(findmnt -nrS UUID=$workingVolume)" ; then
printf "Working volume is mounted. Ideally, consistent with the subsequent mount command.\n"
A2
else
printf "Working volume is not mounted.\n"
if fsck -p UUID=$workingVolume ; then
printf "Filesystem in $workingVolume passed fsck.\n"
# busybox mount lacks the -U option. Therefore mount /dev/*.
mount -v "$(blkid --uuid $workingVolume)" $workingDirectory
A2
else
printf "fsck attempted repair of $workingVolume. Try again.\n"
fi
fi
fi
}
if test -f /etc/DISTRO_SPECS > /dev/null ; then
if ( grep -- EasyOS /etc/DISTRO_SPECS > /dev/null ) ; then
printf "This is an EasyOS system. Therefore,\n"
workingDirectory="$easyosWorkingDirectory"
startScript=$repositoryStartScript
EvaluateWorkingVolume
fi
elif [ -f "/etc/devuan_version" ] ; then
printf "Probably a Devuan system. Therefore,\n"
workingDirectory="$devuanWorkingDirectory"
startScript=$repositoryStartScript
EvaluateWorkingVolume
elif [ -f "/etc/debian_version" ] ; then
printf "Probably a Debian 32 bit system. Therefore,\n"
workingDirectory="$devuanWorkingDirectory"
startScript=$oldAosStartScript
EvaluateWorkingVolume
else
printf "Operating system not recognized. A2 not started.\n"
fi
} # End MyA2.