General TC > Programming & Scripting - Unofficial
NFS storage base scripts mod for PXE booting [split]
alu:
thanks, did not see the post of the person loading the service, i shall have a look
gerald_clark:
New patches for 2.4 ( With suggested function name change. )
--- Code: ---*** tc-config.orig 2009-09-20 23:48:37.000000000 -0500
--- tc-config 2009-09-20 23:48:37.000000000 -0500
***************
*** 217,222 ****
--- 217,224 ----
settime*) SETTIME=${i#*=} ;;
thm*) THEME=${i#*=} ;;
bkg*) BACKGROUND=${i#*=} ;;
+ nfsmount* ) NFSMOUNT=${i#*=} ;;
+ tftplist* ) TFTPLIST=${i#*=} ;;
esac
;;
*)
***************
*** 289,294 ****
--- 291,338 ----
/sbin/ifconfig lo 127.0.0.1 up
/sbin/route add 127.0.0.1 lo &
+ # dhcp.sh runs udhcpc async, so it exits before network is up
+ wait4Server() {
+ [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh
+ CNT=0
+ until ping -c 1 $1 >/dev/null 2>&1
+ do
+ [ $((CNT++)) -gt 30 ] && break || sleep 1
+ done
+ DHCP_RAN=1
+ }
+
+ # First process tftp entries
+ modprobe -q squashfs 2>/dev/null
+ if [ -n "$TFTPLIST" ]; then
+ SERVER=`echo $TFTPLIST | awk -F\: '{ print $1 }'`
+ FILE=`echo $TFTPLIST | awk -F\: '{ print $2 }'`
+ wait4Server $SERVER
+ ( mkdir /tmp/tftp ; cd /tmp/tftp
+ NAME=`basename $FILE`
+ tftp -g -r $FILE $SERVER
+ echo -ne "${BLUE}TFTP Loading Extensions ${YELLOW}"
+ while read EXTENSION
+ do
+ tftp -g -r $EXTENSION $SERVER
+ EXTNAME=`basename $EXTENSION`
+ echo -ne "$EXTNAME "
+ tcloop_mount "$EXTNAME" $(getbasefile "$EXTNAME" 1)
+ done < $NAME
+ echo "${GREEN} Done.${NORMAL}"
+ rm $NAME
+ )
+ fi
+
+ if [ -n "$NFSMOUNT" ]; then
+ SERVER=`echo $NFSMOUNT | awk -F\: '{ print $1 }'`
+ wait4Server $SERVER
+ echo "$NFSMOUNT /mnt/nfs nfs defaults,nolock 0 0" >> /etc/fstab
+ echo "Mounting $NFSMOUNT"
+ mkdir /mnt/nfs
+ mount /mnt/nfs
+ fi
+
if [ -n "$CHECKFS" ]; then
touch /etc/sysconfig/checkfs
wait $fstab_pid
***************
*** 340,346 ****
tceSetup
#
- modprobe -q squashfs 2>/dev/null
if [ "$(ls -A /opt/tce)" ]; then
echo "${BLUE}Checking for /opt/tce items... ${NORMAL}"
gettceapps "/opt/tce"
--- 384,389 ----
***************
*** 588,594 ****
if [ -n "$NODHCP" ]; then
echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}"
else
! /etc/init.d/dhcp.sh &
fi
[ -n "$KEYMAP" ] || KEYMAP="us"
--- 631,637 ----
if [ -n "$NODHCP" ]; then
echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}"
else
! [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh &
fi
[ -n "$KEYMAP" ] || KEYMAP="us"
--- End code ---
--- Code: ---*** tc-functions.orig 2009-09-20 23:48:37.000000000 -0500
--- tc-functions 2009-09-20 23:48:37.000000000 -0500
***************
*** 74,79 ****
--- 74,84 ----
MOUNTPOINT=""
MOUNTED="no"
D2="$1"
+ if [ "$D2" == "nfs" ]; then
+ MOUNTPOINT=/mnt/nfs
+ MOUNTED="yes"
+ return
+ fi
if [ "${D2:0:5}" == "UUID=" ]; then
D2=`/sbin/blkid -lt $D2 -o device`
if [ "$?" != 0 ]; then
***************
*** 111,117 ****
autoscan(){
FOUND=""
! for DEVICE in `grep "^/dev/" /etc/fstab | grep -vf /etc/init.d/tc_noscan.lst | awk 'FS="/" { print $3}'`; do
find_mountpoint $DEVICE
if [ -n "$MOUNTPOINT" ]; then
if [ "$MOUNTED" == "no" ]; then
--- 116,122 ----
autoscan(){
FOUND=""
! for DEVICE in `grep "/mnt/" /etc/fstab | grep -vf /etc/init.d/tc_noscan.lst | awk 'FS="/" { print $3}'`; do
find_mountpoint $DEVICE
if [ -n "$MOUNTPOINT" ]; then
if [ "$MOUNTED" == "no" ]; then
--- End code ---
gerald_clark:
Just in case anybody gives a hoot, here are patches for TC 1.4
--- Code: ---*** tc-config.org 2009-09-26 12:59:32.000000000 -0500
--- tc-config 2009-09-26 12:59:33.000000000 -0500
***************
*** 13,18 ****
--- 13,30 ----
TCEWBAR="/usr/local/tce.wbar"
INSTALLED=""
+ tcloop_mount() {
+ [ -d /tmp/tcloop/"$2" ] || mkdir -p /tmp/tcloop/"$2"
+ mount "$1" /tmp/tcloop/"$2" -o loop
+
+ APPNAME=$2 tcz-symlinker --dir > /dev/null 2>&1
+ APPNAME=$2 tcz-symlinker > /dev/null 2>&1
+
+ if [ -f /tmp/tcloop/"$2"/user.tar.gz ]; then
+ tar xzf /tmp/tcloop/"$2"/user.tar.gz -C / > /dev/null 2>&1
+ fi
+ }
+
gettceapps(){
for FILE in `ls $1/*.tce* 2>/dev/null`
do
***************
*** 33,48 ****
if stringinstring "tcz" "$EXT"; then
BASE=$(getbasefile "$FILE" 1)
echo -n " ${YELLOW}$BASE${NORMAL}"
! [ -d /tmp/tcloop/"$BASE" ] || mkdir -p /tmp/tcloop/"$BASE"
! mount "$FILE" /tmp/tcloop/"$BASE" -o loop
!
! APPNAME=$BASE tcz-symlinker --dir > /dev/null 2>&1
! APPNAME=$BASE tcz-symlinker > /dev/null 2>&1
!
! if [ -f /tmp/tcloop/"$BASE"/user.tar.gz ]; then
! tar xzf /tmp/tcloop/"$BASE"/user.tar.gz -C / > /dev/null 2>&1
! fi
!
case "$EXT" in *m*) NEW_MODULES=1 ;; esac
case "$EXT" in *l*) NEW_LIBS=1 ;; esac
[ -x "$TCEINSTALLED"/"$BASE" ] || touch "$TCEINSTALLED"/"$BASE"
--- 45,51 ----
if stringinstring "tcz" "$EXT"; then
BASE=$(getbasefile "$FILE" 1)
echo -n " ${YELLOW}$BASE${NORMAL}"
! tcloop_mount "$FILE" "$BASE"
case "$EXT" in *m*) NEW_MODULES=1 ;; esac
case "$EXT" in *l*) NEW_LIBS=1 ;; esac
[ -x "$TCEINSTALLED"/"$BASE" ] || touch "$TCEINSTALLED"/"$BASE"
***************
*** 125,130 ****
--- 128,135 ----
resume*) RESUME=${i#*=} ;;
host*) HOST=1 ;;
settime*) SETTIME=${i#*=} ;;
+ nfsmount* ) NFSMOUNT=${i#*=} ;;
+ tftplist* ) TFTPLIST=${i#*=} ;;
esac
;;
*)
***************
*** 205,211 ****
if [ -n "$NODHCP" ]; then
echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}"
else
! /etc/init.d/dhcp.sh &
fi
if [ -n "$CHECKFS" ]; then
--- 210,257 ----
if [ -n "$NODHCP" ]; then
echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}"
else
! [ -z "DHCP_RAN" ] && /etc/init.d/dhcp.sh &
! fi
!
! # dhcp.sh runs udhcpc async, so it exits before network is up
! wait4Server() {
! [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh
! CNT=0
! until ping -c 1 $1 >/dev/null 2>&1
! do
! [ $((CNT++)) -gt 30 ] && break || sleep 1
! done
! DHCP_RAN=1
! }
!
! # First process tftp entries
! if [ -n "$TFTPLIST" ]; then
! SERVER=`echo $TFTPLIST | awk -F\: '{ print $1 }'`
! FILE=`echo $TFTPLIST | awk -F\: '{ print $2 }'`
! wait4Server $SERVER
! ( mkdir /tmp/tftp ; cd /tmp/tftp
! NAME=`basename $FILE`
! tftp -g -r $FILE -l ./$NAME $SERVER
! echo -ne "${BLUE}TFTP Loading Extensions ${YELLOW}"
! while read EXTENSION
! do
! EXTNAME=`basename $EXTENSION`
! tftp -g -r $EXTENSION -l ./$EXTNAME $SERVER
! echo -ne "$EXTNAME "
! tcloop_mount "$EXTNAME" $(getbasefile "$EXTNAME" 1)
! done < $NAME
! echo "${GREEN} Done.${NORMAL}"
! rm $NAME
! )
! fi
!
! if [ -n "$NFSMOUNT" ]; then
! SERVER=`echo $NFSMOUNT | awk -F\: '{ print $1 }'`
! wait4Server $SERVER
! echo "$NFSMOUNT /mnt/nfs nfs defaults,nolock 0 0" >> /etc/fstab
! echo "Mounting $NFSMOUNT"
! mkdir /mnt/nfs
! mount /mnt/nfs
fi
if [ -n "$CHECKFS" ]; then
--- End code ---
--- Code: ---*** tc-functions.org 2009-09-26 12:59:32.000000000 -0500
--- tc-functions 2009-09-26 12:59:33.000000000 -0500
***************
*** 80,85 ****
--- 80,90 ----
MOUNTPOINT=""
MOUNTED="no"
D2="$1"
+ if [ "$D2" == "nfs" ]; then
+ MOUNTPOINT=/mnt/nfs
+ MOUNTED="yes"
+ return
+ fi
if [ "${D2:0:5}" == "UUID=" ]; then
D2=`/sbin/blkid -lt $D2 -o device`
if [ "$?" != 0 ]; then
***************
*** 117,123 ****
autoscan(){
FOUND=""
! for DEVICE in `grep "^/dev/" /etc/fstab | grep -vf /etc/init.d/tc_noscan.lst | awk 'FS="/" { print $3}'`; do
find_mountpoint $DEVICE
if [ -n "$MOUNTPOINT" ]; then
if [ "$MOUNTED" == "no" ]; then
--- 122,128 ----
autoscan(){
FOUND=""
! for DEVICE in `grep "/mnt/" /etc/fstab | grep -vf /etc/init.d/tc_noscan.lst | awk 'FS="/" { print $3}'`; do
find_mountpoint $DEVICE
if [ -n "$MOUNTPOINT" ]; then
if [ "$MOUNTED" == "no" ]; then
--- End code ---
gerald_clark:
Wow. Significant changes to TCL 2.4rc2 cause previous patches to not apply.
Removal of tcloop_mount() requires substitution of tce-load. The current patches are:
--- Code: ---*** tc-config.orig 2009-09-30 18:34:07.000000000 -0500
--- tc-config 2009-09-30 18:34:08.000000000 -0500
***************
*** 75,80 ****
--- 75,82 ----
settime*) SETTIME=${i#*=} ;;
thm*) THEME=${i#*=} ;;
bkg*) BACKGROUND=${i#*=} ;;
+ nfsmount* ) NFSMOUNT=${i#*=} ;;
+ tftplist* ) TFTPLIST=${i#*=} ;;
esac
;;
*)
***************
*** 146,151 ****
--- 148,198 ----
/sbin/ifconfig lo 127.0.0.1 up
/sbin/route add 127.0.0.1 lo &
+ # dhcp.sh runs udhcpc async, so it exits before network is up
+ wait4Server() {
+ [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh
+ CNT=0
+ until ping -c 1 $1 >/dev/null 2>&1
+ do
+ [ $((CNT++)) -gt 30 ] && break || sleep 1
+ done
+ DHCP_RAN=1
+ }
+
+ # First process tftp entries
+ modprobe -q squashfs 2>/dev/null
+ if [ -n "$TFTPLIST" ]; then
+ SERVER=`echo $TFTPLIST | awk -F\: '{ print $1 }'`
+ FILE=`echo $TFTPLIST | awk -F\: '{ print $2 }'`
+ wait4Server $SERVER
+ ( TMPDIR=/tmp/tftp
+ TCEDIR=/opt/.tce_dir
+ echo > $TCEDIR
+ mkdir $TMPDIR ; cd $TMPDIR
+ NAME=`basename $FILE`
+ tftp -g -r $FILE $SERVER
+ echo -ne "${BLUE}TFTP Loading Extensions ${YELLOW}"
+ while read EXTENSION
+ do
+ tftp -g -r $EXTENSION $SERVER
+ EXTNAME=`basename $EXTENSION`
+ echo -ne "$EXTNAME "
+ /usr/bin/tce-load -i $TMPDIR/$EXTNAME
+ done < $NAME
+ echo "${GREEN} Done.${NORMAL}"
+ rm $NAME $TCEDIR
+ )
+ fi
+
+ if [ -n "$NFSMOUNT" ]; then
+ SERVER=`echo $NFSMOUNT | awk -F\: '{ print $1 }'`
+ wait4Server $SERVER
+ echo "$NFSMOUNT /mnt/nfs nfs defaults,nolock 0 0" >> /etc/fstab
+ echo "Mounting $NFSMOUNT"
+ mkdir /mnt/nfs
+ mount /mnt/nfs
+ fi
+
if grep -q "^/dev/root" /proc/mounts; then
INSTALLED=1
echo "${RED}Detected Traditional (Scatter) Hard drive installation.${NORMAL}"
***************
*** 177,183 ****
fi
fi
#
- modprobe -q squashfs 2>/dev/null
if [ -n "$USER" ]; then
if ! grep "$USER" /etc/passwd >/dev/null; then addUser; fi
--- 224,229 ----
***************
*** 367,373 ****
if [ -n "$NODHCP" ]; then
echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}"
else
! /etc/init.d/dhcp.sh &
fi
[ -n "$KEYMAP" ] || KEYMAP="us"
--- 413,419 ----
if [ -n "$NODHCP" ]; then
echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}"
else
! [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh &
fi
[ -n "$KEYMAP" ] || KEYMAP="us"
--- End code ---
--- Code: ---*** tc-functions.orig 2009-09-30 18:34:07.000000000 -0500
--- tc-functions 2009-09-30 18:34:08.000000000 -0500
***************
*** 74,79 ****
--- 74,84 ----
MOUNTPOINT=""
MOUNTED="no"
D2="$1"
+ if [ "$D2" == "nfs" ]; then
+ MOUNTPOINT=/mnt/nfs
+ MOUNTED="yes"
+ return
+ fi
if [ "${D2:0:5}" == "UUID=" ]; then
D2=`/sbin/blkid -lt $D2 -o device`
if [ "$?" != 0 ]; then
***************
*** 111,117 ****
autoscan(){
FOUND=""
! for DEVICE in `grep "^/dev/" /etc/fstab | grep -vf /etc/init.d/tc_noscan.lst | awk 'FS="/" { print $3}'`; do
find_mountpoint $DEVICE
if [ -n "$MOUNTPOINT" ]; then
if [ "$MOUNTED" == "no" ]; then
--- 116,122 ----
autoscan(){
FOUND=""
! for DEVICE in `grep "/mnt/" /etc/fstab | grep -vf /etc/init.d/tc_noscan.lst | awk 'FS="/" { print $3}'`; do
find_mountpoint $DEVICE
if [ -n "$MOUNTPOINT" ]; then
if [ "$MOUNTED" == "no" ]; then
--- End code ---
gutmensch:
It's a PITA to rebuild patches for every "maintenance" release... good work, Gerald! For this reason I'll stay with 2.3.1 first ;-)
BTW your patches are working great, using them for a while now :)
Best regards,
Robert
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version