#!/bin/sh # http://www.phys.ethz.ch/~franklin/Projects/dphys3/end2stage.simple # - script to be run at end of second install stage for further automation # 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 root user shell, some commands and ssh login files ### ------ 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} # --- get rest of packages I want, even for an install test server #nice yes '' | apt-get install tcsh #nice yes '' | apt-get install less #nice yes '' | apt-get install ssh # --- give user some shell settings cat << END-CSHRC > /root/.cshrc # .cshrc - set up C shell # author Neil Franklin, last modification 2004.01.04 # reduced version for test hosts 2004.08.05 # turn on filename completion, history set filec set history = 100 # prevent loose files umask 022 if ( \$user == "root") then set path = (/sbin /usr/sbin /usr/local/sbin \$path) endif # more and less setenv LESS "-cfiMq" setenv LESSCHARSET latin1 setenv PAGER /usr/bin/less setenv EDITOR /usr/bin/vi # get my own programs set path = (~/bin \$path) # prompt how I like it set prompt='%n@%m %~%# ' if (\$?term == 1) then if ( \$term == "linux" || \$term == "vt100" ) then # console some configurations fail to work with \033 for some odd reason set prompt="%B\$prompt%b" endif if ( \$term == "xterm" || \$term == "iris-ansi" ) then set prompt="%{\033]2;\$prompt\007%}%B\$prompt%b" endif endif END-CSHRC # --- add some important scripts if [ ! -e /root/bin ] ; then mkdir /root/bin fi # I prefer scripts (cost of one at runtime) over alias (cost of all at login) cat << END-BIN-LA > /root/bin/la #!/bin/sh # ~/bin/la - ls all long exec ls -alF \$* END-BIN-LA chmod 755 /root/bin/la # --- allow ssh logins without password if [ ! -e /root/.ssh ] ; then mkdir /root/.ssh chmod 700 /root/.ssh fi cat << END-SSH-AUTH-KEY > /root/.ssh/authorized_keys 1024 35 87284004596883244711294572577878691295870121542215195616794331308261777326879452323193798528948434670829119898580668256893668153836470682618291469217706441884331454172106552397405732549599921952126473434558872640359621704806839163346411310207952522962629894560040108406215173211743913961199629550664569669811 root@chonsp ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAnxkN5P5X6vuhyXnTbK8AD6HLAjlL1fuQOG3h+I6RcdoS0vQY1GL0+oFdcivmfSDwKfJCt+uv5rrbFqx797wDyo2O8BbJHCrgh/JWILxPlaAb4TerJQxp0NaDdl9SJVQhOni+EOGmu8m3ALw/l+JNZtKBJocXj3o21Hx7EYjS95M= root@chonsp ssh-dss AAAAB3NzaC1kc3MAAACBAJf6tCeSYavSDm73pADfm3wM28TQlC0LwPo9P9LD7/6D59oTpBDhRABu3oMi6cWCZBCZOgal9oi7+s0R5XMyvT8hG+10eCsr3zI2w5Jf1JtPJSWJhDdLFEPoL1sMZHAAf7oMZYTk4/TE4Pgi/y7eUKwHWXusqqWthYlTk7bSnHdlAAAAFQCvAaYx+q1zSJDvZDuodXt55175cwAAAIBQmaCoFiP6CL7a3pk3fkwlubdAFNqPUaWRATLFt9bQTaLlN16ticHD+gubTIIsyDkOdZ5ckW28iq1tE1Gh9kwoz/2NFATz5WtIfufCZO2pNQoAYW0+45vvgCJpR2uXDGBEYI3a9ntIlvl7cKayA/5fDVt5gIKgSNXcEiu+/YOlbQAAAIA2muypWBf1lSZxhOXDbaBzCleoCXjbd583LcSEuAW+GXb5b1nWiW0tg2FocPa8nutFIbM95r0sNEjbu1i2UOh1zqD0tkJCrTHUNZrO+LtutVYNBz7yxiRszN3voKW6waaR7H39xJ6E2Q5iZWIcY5Z34JkH4ob+8L452AAUqfPoIA== root@chonsp END-SSH-AUTH-KEY chmod 600 /root/.ssh/authorized_keys # --- end logging ${CMD_DEBUG_PRINT} "/e2s finished" >> /root/debug_print ${CMD_DEBUG_WAIT} exit 0