From a47daa41a620c72df6a87f9dffa71f91c82fef4e Mon Sep 17 00:00:00 2001 From: Eric Thibodeau Date: Sat, 19 Jul 2008 21:56:01 -0400 Subject: Multiple fixes and feature additions: Fix: - stderr misredirrection `>2 --> >&2` - Messages now display the scriptname and not just "STATELESS... - Now setting domainname in the right place Features: - now a single tmpfs folder is mounted and folders created under that folder, ** the function should be easy to modify if ever one was to mount another FS than tmpfs ** Kernel command line parameter now required, ie: rwdev=tmpfs Misc: - Cleaned out unused and commented code - Renamed some functions --- catalyst/nfsroot/2008.0/overlay/boot/stateless.sh | 59 ++++++++++------------- 1 file changed, 26 insertions(+), 33 deletions(-) (limited to 'catalyst') diff --git a/catalyst/nfsroot/2008.0/overlay/boot/stateless.sh b/catalyst/nfsroot/2008.0/overlay/boot/stateless.sh index 39e9071..ab59076 100755 --- a/catalyst/nfsroot/2008.0/overlay/boot/stateless.sh +++ b/catalyst/nfsroot/2008.0/overlay/boot/stateless.sh @@ -17,46 +17,32 @@ ahostname(){ MYHOST="${NODE_NAME}${MYIP##*.}" echo "I proclaim that I am $MYHOST !!" else - echo DHCP told me my hostname is ${MYHOST}... - echo "Setting domainname to DHCP's settings" - /bin/domainname $DOMAIN + echo "DHCP told me my hostname is ${MYHOST}..." fi - echo "STATELESS: Setting Hostname to $MYHOST" + echo "$0: Setting Hostname to $MYHOST" echo "HOSTNAME=\"$MYHOST\"" > /etc/conf.d/hostname /bin/hostname "$MYHOST" + + echo "Setting domainname to DHCP's settings: $DOMAIN" + /bin/domainname $DOMAIN } -#getparams() { -# #local cmdline=$(dmesg | grep '^Kernel command line' | sed 's/^Kernel command line://g') -# cmdline=$(cat /proc/cmdline) -# for pp in $cmdline; do -# echo $pp | grep '^softlevel=' >/dev/null 2>&1 -# if [ $? -eq 0 ]; then -# echo $pp | sed 's/softlevel=//g' -# return 0 -# fi -# done -# echo "" -# return 1 -#} -isset() { - #for p in $(getparams | tr ',' ' '); do - for p in $(get_param softlevel); do - if [ "$p" == "$1" ]; then - return 0 - fi - done - return 1 +# Used to mount the RW part of the ROOT, it should be easy to add other +# FS than tmpfs here. +mount_rw_dev() { + echo "$0: Mounting $RWDEV as Read Write device ..." + if [ $RWDEV == "tmpfs" ]; then + mount -n -t tmpfs -o defaults tmpfs_rw /mnt/rw_mounts/ + fi } -aunionfs() { +mount_rw_dir() { while [ "$1" != "" ]; do - echo "STATELESS: Mounting tmpfs $1 ..." - mount -n -t tmpfs -o defaults tmpfs_$1 /mnt/$UNIONMOD/$1 - echo "STATELESS: Mounting $1 using $UNIONMOD ..." - mount -n -t $UNIONMOD -o dirs=/mnt/$UNIONMOD/$1=rw:/$1=ro ${UNIONMOD}_$1 /$1 + echo "$0: Mounting $1 using $UNIONMOD ..." + mkdir -p /mnt/rw_mounts/$1 + mount -i -n -t $UNIONMOD -o dirs=/mnt/rw_mounts/$1=rw:/$1=ro ${UNIONMOD}_$1 /$1 shift done } @@ -90,13 +76,13 @@ get_param() { echo $* else shift $PARAM - iecho $1 + echo $1 fi return 0 ;; esac done - echo "Parameter '$1' not found" >2 + echo "Parameter '$1' not found" >&2 return 1 } @@ -118,19 +104,26 @@ import_dhcp_info() { ROOTSERV=$(get_param rootserver 1) } +# if mounting /proc becomes a problem we have to use the following: +# PARSELINE=$(dmesg | grep '^Kernel command line' | sed 's/^Kernel command line://g') import_cmdline() { mount -n -t proc none /proc PARSELINE=$(cat /proc/cmdline) UNIONMOD=$(get_param unionmod 1) + RWDEV=$(get_param rwdev 1) } import_dhcp_info +import_cmdline +[ ! -z $RWDEV ] && mount_rw_dev if [ ! -z $UNIONMOD ]; then echo "Loading $UNIONMOD" + # we should detect wether it's a mod or kernel builtin... $MODPROBE $UNIONMOD - aunionfs etc var tmp + mount_rw_dir etc var tmp fi +touch /etc || /bin/bash ahostname ahosts exec /sbin/init -- cgit v1.2.3-65-gdbad