Oberon/A2/myaos
Jump to navigation
Jump to search
#!/bin/bash
# A script to start UnixAos 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 script to work.
# * The volume containing the working files has a reliable name.
# The names in /dev/disk/by-label/ and /dev/disk/by-partuuid/
# are convenient. For example, a volume labeled A will appear
# as /dev/disk/by-label/A. Additional details here.
# http://reactivated.net/writing_udev_rules.html#builtin
# https://wiki.debian.org/udev
# * A mount point and working directory exist for the working volume.
# mountPoint and workingDirectory can be the same or different.
# What if the volume is automounted at a second location?
# If edit conflict is avoided, a second mount is probably harmless.
# * The following assignments to workingVolume, mountPoint
# and workingDirectory are consistent with preceding information.
# * An appropriate entry exists in /etc/fstab. Example.
# /dev/A /home/me/A ext2 defaults,user,users,exec,noauto 0 0
# * /etc/sudoers.d/sudoers is adjusted to allow the user to fsck the
# working filesystem.
# 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 the start scipt was /usr/bin/aos.
# For revision 10272 the start script is /usr/local/bin/a2
# * aos or a2 attempts to create the link <workingDirectory>/.aoshome
# to the installation directory but a FAT file system disallows links.
# This can be resolved by reformatting to ext2.
# https://en.wikipedia.org/wiki/Ext2
#
# workingVolume=/dev/disk/by-label/A
workingVolume=/dev/disk/by-partuuid/0006ebcf-03
echo workingVolume is $workingVolume.
mountPoint=/home/root/AY
echo mountPoint is $mountPoint.
workingDirectory=/home/root/AY
echo workingDirectory=$workingDirectory.
# For any hostname violating Oberon file name syntax, make a conformant name.
# Ref. https://www.tldp.org/LDP/abs/html/comparison-ops.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
echo h = $h
Aos () {
AosContextDir=$PWD
cd $workingDirectory
if test -f Configuration.$h.XML
then
echo Copying Configuration.$h.XML to Configuration.XML.
/bin/cp Configuration.$h.XML Configuration.XML
if test -f Oberon.$h.Text
then
echo Copying Oberon.$h.Text to Oberon.Text.
/bin/cp Oberon.$h.Text Oberon.Text
/bin/rm --force --verbose AOS*.Log
/bin/rm --force --verbose Trap*.txt
/bin/rm --force --verbose .tmp.*
/usr/bin/aos
else
echo Oberon.$h.Text not present in $workingDirectory. Aborting.
fi
else
echo Configuration.$h.XML not present in $workingDirectory. Aborting.
fi
cd $AosContextDir
}
if test -b $workingVolume
then
if findmnt -rn $workingVolume
then
echo working volume is mounted.
Aos
else
echo working volume is not mounted.
if /sbin/fsck -p $workingVolume
then
echo Filesystem in $workingVolume passed fsck.
mount -v $workingVolume
Aos
else
echo fsck found a problem in $workingVolume and attempted repair. Try again.
fi
fi
else
echo $workingVolume containing working files not connected. Aborting.
fi