|
From: Serge L. <sma...@us...> - 2008-09-18 17:45:57
|
Update of /cvsroot/devil-linux/build/scripts/scripts In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv20910 Modified Files: install-on-usb Log Message: - added serial console configuration Index: install-on-usb =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/install-on-usb,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- install-on-usb 9 Sep 2008 21:03:35 -0000 1.26 +++ install-on-usb 19 Sep 2008 00:44:52 -0000 1.27 @@ -10,6 +10,7 @@ # # + TMPDIR="$(pwd)/tmp-install2usb" # You should set $EDITOR or make an editor soft link if you don't like these choices @@ -237,6 +238,8 @@ mkdir -p $TMPDIR/iso-mnt || return 1 mkdir -p $TMPDIR/disk-mnt || return 1 + mkdir -p $TMPDIR/etc-mnt || return 1 + mkdir -p $TMPDIR/etc-for-mods || return 1 echo read -p "Enter DL ISO source (disk file or CD device) -> " DLISO @@ -305,28 +308,38 @@ fi echo + + read -p "Enter seperate partition for configuration (recommended) or enter if same -> " ETC_PART + if [ -z "$ETC_PART" ]; then + ETC_PART=$PARTITION + elif [ ! -b "$ETC_PART" ]; then + echo " Can not find partition \"$ETC_PART\"" + return 1 + else + + echo;echo -n "Would you like to format $ETC_PART ? " + if ask_yes_no ; then + format_partition $ETC_PART || return 1 + else + # Try to mount $DEVICE + mount -t auto $ETC_PART $TMPDIR/etc-mnt || ( echo "Unable to mount $ETC_PART"; return 1 ); + fi + + fi + ETC_FILE="" read -p "Enter configuration file to preload to disk (if any) -> " ETC_FILE if [ -n "$ETC_FILE" ]; then if [ ! -f "$ETC_FILE" ]; then echo " No such file: \"$ETC_FILE\"" return 1 - else - read -p "Enter seperate partition for configuration (recommended) or enter if same -> " ETC_PART - if [ -z "$ETC_PART" ]; then - ETC_PART=$PARTITION - elif [ ! -b "$ETC_PART" ]; then - echo " Can not find partition \"$ETC_PART\"" - return 1 - else - - echo;echo -n "Would you like to format $ETC_PART ? " - if ask_yes_no ; then - format_partition $ETC_PART || return 1 - else - # Try to mount $DEVICE - mount -t auto $ETC_PART $TMPDIR/etc-mnt || ( echo "Unable to mount $ETC_PART"; return 1 ) - fi + fi + else + if [ -f "/DEVIL-LINUX" ]; then + echo;echo -n "Would you like to save current configs to disk?" + if ask_yes_no ; then + umount $TMPDIR/etc-mnt 2> /dev/null + save-config -q -d $ETC_PART || echo -e "Unable to save configs to $ETC_PART \nPlease do it manually after installation.\n\t/bin/save-config -d $ETC_PART" fi fi fi @@ -334,7 +347,7 @@ echo echo "This will install DL on \"$DEVICE\" using the \"$BOOTLOADER\" bootloader. " -# Check the initrd type (INITRAMFS) + # Check the initrd type (INITRAMFS) # Decompress image gunzip $TMPDIR/iso-mnt/boot/initrd.gz -d -c > $TMPDIR/initrd || return 1 if file -b $TMPDIR/initrd | grep -i "cpio archive" > /dev/null 2>&1; then @@ -368,6 +381,12 @@ cat $TMPDIR/iso-mnt/boot/message | sed -e s%"/boot/"%""% > $TMPDIR/disk-mnt/message || return 1 copy_iso_file $DLISO $TMPDIR/disk-mnt/bootcd.iso not_save_permissions || return 1 + if [ "$SERIAL_CONSOLE" = "true" ]; then + cp -a $TMPDIR/disk-mnt/syslinux.cfg $TMPDIR/syslinux.cfg && (echo "serial 0 $SERIALSPEED" > $TMPDIR/disk-mnt/syslinux.cfg && cat $TMPDIR/syslinux.cfg | sed -e s/"append"/"append console=tty0 console=ttyS0,$SERIALSPEED"/g >> $TMPDIR/disk-mnt/syslinux.cfg ) || ( echo "Unable to modify syslinux.cfg file"; return 1 ) + configure_serial_console || echo -e "There is a problem with Serial Console configuration\nPlease check configs (/etc/inittab and /etc/securetty or restart the script"; + fi + + elif [ "$BOOTLOADER" = "grub" ] || [ "$BOOTLOADER" = "lilo" ]; then echo;echo -n "Would you like to format $PARTITION ? " if ask_yes_no ; then @@ -404,6 +423,7 @@ return 1 fi + if [ -n "$ETC_FILE" ]; then mount -t auto $ETC_PART $TMPDIR/etc-mnt echo @@ -413,9 +433,69 @@ umount $TMPDIR/etc-mnt > /dev/null fi + if [ "$SERIAL_CONSOLE" = "true" ]; then + configure_serial_console || ( echo -e "There is a problem with Serial Console configuration\nPlease check configs (/etc/inittab and /etc/securetty or restart the script"; return 1 ; ) + umount $TMPDIR/etc-mnt 2> /dev/null + fi + return 0; } +modify_inittab () { + if ! grep "^S0:2345:respawn:/sbin/agetty" $TMPDIR/etc-for-mods/etc-mods/inittab > /dev/null; then + echo "S0:2345:respawn:/sbin/agetty -L $SERIALSPEED ttyS0 vt102" >> $TMPDIR/etc-for-mods/etc-mods/inittab || \ + ( echo -e "Please configure login via serial console ttyS0 manually. \nAdd the following line to /etc/inittab:\n\tS0:2345:respawn:/sbin/agetty -L $SERIALSPEED ttyS0 vt102\n"; return 1 ) + fi +} + +modify_securetty () { + if ! grep "^ttyS0" $TMPDIR/etc-for-mods/etc-mods/securetty > /dev/null; then + echo "ttyS0" >> $TMPDIR/etc-for-mods/etc-mods/securetty || \ + ( "Please configure login via serial console ttyS0 manually. \nAdd the following line to /etc/securetty:\n\tttyS0\n"; return 1) + fi +} + +configure_serial_console () { + + MESSAGE="Please configure login via serial console ttyS0 manually. \nAdd the following line to /etc/inittab:\n\tS0:2345:respawn:/sbin/agetty -L $SERIALSPEED ttyS0 vt102\nAdd the following line to /etc/securetty:\n\tttyS0\n"; + + if ! grep etc-mnt /proc/mounts > /dev/null; then + mount -t auto $ETC_PART $TMPDIR/etc-mnt + fi + + if [ -f $TMPDIR/etc-mnt/etc-mods.tar.bz2 ] ; then + tar vpfxj $TMPDIR/etc-mnt/etc-mods.tar.bz2 -C $TMPDIR/etc-for-mods > /dev/null || \ + ( echo "Unable to unpack etc-mods.tar.bz2..."; echo -e $MESSAGE ; return 1 ); + else + mkdir -p $TMPDIR/etc-for-mods/etc-mods/ && \ + cp -a $TMPDIR/iso-mnt/etc-cd/{inittab,securetty} $TMPDIR/etc-for-mods/etc-mods/ || ( echo -e $MESSAGE ; return 1; ) + fi + + if [ -f $TMPDIR/etc-for-mods/etc-mods/inittab ]; then + modify_inittab || return 1; + else + cp -a $TMPDIR/iso-mnt/etc-cd/inittab $TMPDIR/etc-for-mods/etc-mods/inittab || + ( echo -e "Please configure login via serial console ttyS0 manually. \nAdd the following line to /etc/inittab:\n\tS0:2345:respawn:/sbin/agetty -L $SERIALSPEED ttyS0 vt102\n"; ) + modify_inittab || return 1; + fi + + if [ -f $TMPDIR/etc-for-mods/etc-mods/securetty ]; then + modify_securetty || return 1; + else + cp -a $TMPDIR/iso-mnt/etc-cd/securetty $TMPDIR/etc-for-mods/etc-mods/securetty || \ + ( "Please configure login via serial console ttyS0 manually. \nAdd the following line to /etc/securetty:\n\tttyS0\n"; return 1) + modify_securetty || return 1; + fi + + tar -C $TMPDIR/etc-for-mods -c -j -f $TMPDIR/etc-mnt/etc-mods.tar.bz2.new etc-mods root && \ + mv $TMPDIR/etc-mnt/etc-mods.tar.bz2.new $TMPDIR/etc-mnt/etc-mods.tar.bz2 || \ + ( echo "Unable to unpack etc-mods.tar.bz2..."; return 1; ) + + return 0 + +} + + format_partition () { local PARTITION=$1 @@ -544,18 +624,20 @@ echo echo "Select which bootloader you want to use:" echo " 1) SysLinux" -echo " 2) Grub" -echo " 3) Grub with serial console" -echo " 4) Lilo" +echo " 2) SysLinux with serial console" +echo " 3) Grub" +echo " 4) Grub with serial console" +echo " 5) Lilo (doesn't work yet)" ANS="" read -p "Choice: " -t 60 -n 1 -rs ANS ANS=${ANS:-1} echo $ANS [ $ANS = "1" ] && BOOTLOADER="syslinux" -[ $ANS = "2" ] && { BOOTLOADER="grub"; SERIAL_CONSOLE=""; } -[ $ANS = "3" ] && { BOOTLOADER="grub"; SERIAL_CONSOLE="true"; } -[ $ANS = "4" ] && BOOTLOADER="lilo" +[ $ANS = "2" ] && { BOOTLOADER="syslinux"; SERIAL_CONSOLE="true"; } +[ $ANS = "3" ] && { BOOTLOADER="grub"; SERIAL_CONSOLE=""; } +[ $ANS = "4" ] && { BOOTLOADER="grub"; SERIAL_CONSOLE="true"; } +[ $ANS = "5" ] && BOOTLOADER="lilo" SERIALSPEED="9600" if [ "$SERIAL_CONSOLE" = "true" ]; then |