#!/bin/sh # http://www.phys.ethz.ch/~franklin/Projects/dphys3/end2stage.dphys # - script to be run at end of second install stage for further automation # [1] http://www.phys.ethz.ch/~franklin/Projects/dphys-config/ # [2] http://www.phys.ethz.ch/~franklin/Projects/dphys-admin/ # author Neil Franklin, last modification 2006.11.09 # copyright ETH Zuerich Physics Departement, # use under either BSD or GPL license # this script is intended to be run as root at end of second install stage # / is root of the final system, as we are just short before login prompt # set up and run dphys-config[1] and dphys-admin[2] as used on our site ### ------ configuration for this script # first CONF_* various site or subnet dependant user config variables # then DEBUG_* various debugging settings # last SYS_* various system internal values # some of these are overridable by hostname input line options # --- CONF_* various site or subnet dependant user config variables # set this to get rid of status reports, replaces -q option #CONF_PRINT_QUIET=yes # set this to get more status reported, replaces -v option #CONF_PRINT_VERBOSE=yes # --- DEBUG_*, various debugging settings # these can be set to "yes" by -D option, followed by name without DEBUG_ # set this to sleep after displaying each steps header #DEBUG_SLEEP=yes # set this to output debug state info after each step #DEBUG_PRINT_STEP=yes # set this to output debug state info and wait after each step #DEBUG_WAIT_STEP=yes # --- SYS_*, various system internal values # none of these currently ### ------ actual implementation from here on # no user settings any more below this point set -e # --- get ready to work # sanitise this place, else some commands may fail # must be before any commands are executed, incl config/input processing PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH # --- tidy up some commands, make systematic, common infrastructure # stuff that goes wrong, not expected by user, not in data output, use >&2 # so also with $0 in case this script was called by an other script # something within the system that user does not expect, give up CMD_FATAL="echo $0: FATAL:" # something from users input, user will correct this and continue CMD_ERROR="echo $0: ERROR:" # something we can continue with, but may be wrong, and user may not suspect it CMD_WARNING="echo $0: WARNING:" # something most likely not wrong, but tell user for the odd case it is wrong CMD_NOTE="echo $0: NOTE:" # normal stuff users expect, so to stdout as normal output, no $0, no marking CMD_INFO="echo" # stuff users asked for, so add to stdout as normal output, no $0, but mark it CMD_DEBUG="echo DEBUG:" # other stuff we may want to use CMD_SLEEP="sleep 2" CMD_WAIT="read -p ---DEBUG-wait-after-step--- dummy" # DEBUG_* or option controllable stuff CMD_INFO_PRINT="${CMD_INFO}" CMD_VERBOSE_PRINT=true CMD_DEBUG_SLEEP=true CMD_DEBUG_PRINT=true CMD_DEBUG_WAIT=true # set debug option controllable stuff here if [ "${DEBUG_SLEEP}" = yes ] ; then CMD_DEBUG_SLEEP="${CMD_SLEEP}" fi if [ "${DEBUG_PRINT_STEP}" = yes ] ; then CMD_DEBUG_PRINT="${CMD_DEBUG}" fi if [ "${DEBUG_WAIT_STEP}" = yes ] ; then CMD_DEBUG_WAIT="${CMD_WAIT}" fi # set option controllable stuff here, as no command line to parse if [ "${CONF_PRINT_QUIET}" = yes ] ; then CMD_INFO_PRINT=true fi if [ "${CONF_PRINT_VERBOSE}" = yes ] ; then CMD_VERBOSE_PRINT="${CMD_INFO}" fi # --- begin logging # start with >> so no old file entire lost, may detect unwanted loops # and also determines whether the intended "/target" loop took place ${CMD_DEBUG_PRINT} "entered /e2s" >> /root/debug_print ${CMD_INFO_PRINT} "running end2stage script ..." ${CMD_DEBUG_SLEEP} # --- load our sites packages # install identd, else no access to non-free site packages and config files # this was once needed, for woody, but sarge already loads an pidentd # run yes with nice , else it uses up all CPU und apt-get gets really slow #nice yes '' | apt-get install oidentd # - tell apt where to find dphys-config and dphys-admin cat << END-APT-SOURCES >> /etc/apt/sources.list deb http://debian.ethz.ch/pub/debian-local sarge/local main contrib non-free END-APT-SOURCES apt-get update # - then configure dphys-config so it can find all the config files # http://www.phys.ethz.ch/~franklin/Projects/dphys-config/ cat << END-DHPYS-CONFIG > /etc/dphys-config CONF_BASEURL="http://debian.ethz.ch/pub/debian-local/configs/sarge" END-DHPYS-CONFIG # install it, and auto-run it via its /etc/init.d script # run yes with nice , else it uses up all CPU und apt-get gets really slow nice yes '' | apt-get install dphys-config # now our apt sources.list and dphys-admin config and list files are here # apt-get update and apt-cache dumpavail and dpkg --update-avail # are all done as part of running dphys-admin # - then install of all packages our site wants, by using dphys-admin # http://www.phys.ethz.ch/~franklin/Projects/dphys-admin/ # dphys-admin package is expected to: # a) add daily cron job to apt-get update/upgrade, incl newer dphys-admin # b) add init script for the case cron job is not run due to power off # c) get run by its init script, fetching all packages we want # this allows us to do anything else, as part of packages postinst scripts # including even rebooting, without any conflicts or hard coded stuff # we name all our self made packages dphys-*, # you are advised to use -* # see "makesourcepackage" for generating/modifying such packages # install it # it will not auto-run it via its /etc/init.d script, because apt-get active nice yes '' | apt-get install dphys-admin # so run manually, as if by init, we allow reboots at install time dphys-admin init # --- end logging ${CMD_DEBUG_PRINT} "/e2s finished" >> /root/debug_print ${CMD_DEBUG_WAIT} exit 0