============================================================== PDL for base VNS config script: setup.sh ============================================================== - Ian! D. Allen - idallen@idallen.ca - www.idallen.com This PDL for the base VNS setup.sh is cumulative up through Lab 8 and Lab 9. Lab 8 and Lab 9 entries are marked. ----------------- START PDL for base VNS config script: setup.sh SET up shell environment (#!, PATH, umask, etc.) SET shell variables for use in rest of script, e.g. hostname, disk IF ntpd is NOT running update Debian packages (optional) fetch and install the NTP Internet Time daemon packages run the start-up script for the ntpdate package run the start-up script for the NTP package ELSE (optional) stop the NTP daemon (using its start-up script) run the start-up script for the ntpdate package run the start-up script for the NTP package ENDIF PRINT the current date IF virtual disk is NOT mounted PRINT warning on stderr create mount point under /mnt IF mounting the disk on the mount point FAILS PRINT an error message on stderr EXIT the script with non-zero status ENDIF PRINT message saying disk was mounted RUN df on virtual disk to show that the disk is correctly mounted ENDIF Fix the /host symlink to point to the virtual disk (Lab 8) Enable ip_forward and log_martians; disable rp_filter (Lab 8) Make sure each of these has the correct value Enable iptables MASQUERADE on eth0 (Lab 8) Fix the Daylight Savings problem using a new localtime file (Lab 8) Clean away unnecessary cache files (Lab 9) Make sure sshd is running, start it if not (Lab 9) Make sure we have three hubs started, start hub UI if not (Lab 9) Stop the machine from halting when the X server exits (Lab 9) Kill the xsession script Create a system log directory and fix system logging to use it (Lab 9) Kill both log daemons (because of bug in start-up script) Restart both log daemons Copy our vns DNS resolv.conf (set by DHCP) to the virtual disk (Lab 9) # We want to move or symlink $HOME .uml and virtuals to the virtual disk. # This section below has been hugely reworked to prevent/detect common errors. # You can keep your current (working, we hope) script, or you can # replace it with this verbose version that will detect errors much better. # IF virtual disk/virtuals is a symlink (-L) PRINT an error message on stderr EXIT the script with non-zero status ENDIF IF virtual disk/virtuals exists (-e) and is NOT a directory (! -d) PRINT an error message on stderr EXIT the script with non-zero status ENDIF IF virtual disk/.uml is a symlink (-L) PRINT an error message on stderr EXIT the script with non-zero status ENDIF IF virtual disk/.uml exists (-e) and is NOT a directory (! -d) PRINT an error message on stderr EXIT the script with non-zero status ENDIF # we get here if the virtual disk either has nothing or has real directories IF virtual disk/virtuals does NOT exist (! -e) PRINT message about setting up virtual disk IF virtual disk/.uml exists (-e) PRINT an error message on stderr (inconsistency found) EXIT the script with non-zero status ENDIF # check the items in the $HOME directory before moving them # IF $HOME/virtuals is a symlink (-L) or is NOT a directory (! -d) PRINT an error message on stderr EXIT the script with non-zero status ENDIF IF $HOME/.uml is a symlink (-L) or is NOT a directory (! -d) PRINT an error message on stderr EXIT the script with non-zero status ENDIF MOVE $HOME/virtuals to virtual disk/virtuals SYMLINK virtual disk/virtuals into $HOME/virtuals MOVE $HOME/.uml to virtual disk/.uml SYMLINK virtual disk/.uml into $HOME/.uml PRINT long listing of $HOME/.uml and $HOME/virtuals EXIT the script with zero status ENDIF # we get here only if virtual disk/virtuals is a real directory IF virtual disk/.uml does NOT exist PRINT an error message on stderr (inconsistency found) EXIT the script with non-zero status ENDIF IF virtual disk/.uml/umlsettings is missing or zero size (! -s) PRINT an error message on stderr EXIT the script with non-zero status ENDIF # check the items in the $HOME directory before deleting them IF $HOME/virtuals is already a symlink IF $HOME/.uml is already a symlink PRINT message that symlinks already exist - nothing to do PRINT long listing of $HOME/.uml and $HOME/virtuals EXIT the script with zero status ENDIF PRINT an error message on stderr (inconsistency found) EXIT the script with non-zero status ENDIF IF $HOME/virtuals is NOT a directory or $HOME/.uml is NOT a directory PRINT an error message on stderr EXIT the script with non-zero status ENDIF # make sure nobody is using a UML that we are trying to move count = count the files under $HOME/.uml IF count > 1 PRINT an error message on stderr (someone is using a UML) EXIT the script with non-zero status ENDIF count = count the files under $HOME/virtuals IF count > 0 PRINT an error message on stderr (someone is using a UML) EXIT the script with non-zero status ENDIF # remove the two $HOME directories and link them to the virtual disk # don't use a recursive remove, in case it has files in it already # we want this remove to fail if virtuals has files in it (should be empty) # PRINT message about removing $HOME/virtuals IF remove directory $HOME/virtuals FAILS PRINT an error message on stderr (someone is using a UML) EXIT the script with non-zero status ENDIF PRINT message about removing $HOME/.uml IF recursively remove directory $HOME/.uml FAILS PRINT an error message on stderr EXIT the script with non-zero status ENDIF PRINT message about linking SYMLINK virtual disk/virtuals into $HOME/virtuals SYMLINK virtual disk/.uml into $HOME/.uml PRINT long listing of $HOME/.uml and $HOME/virtuals EXIT the script with zero status END PDL for setup.sh