X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=grml-terminalserver-config;h=a2fe9cf19ff2a49cb53d4f7c80dc008c480c76b9;hb=171deab13c10f818debaf197de423a41032e8fe8;hp=61cd0569646f09f7f6fc96a837f08c0913292158;hpb=3e8c788ea8c40ac8e705b30eaa4fad9e45a18e43;p=grml-terminalserver.git diff --git a/grml-terminalserver-config b/grml-terminalserver-config index 61cd056..a2fe9cf 100755 --- a/grml-terminalserver-config +++ b/grml-terminalserver-config @@ -1,10 +1,10 @@ -#!/bin/sh +#!/bin/bash # Filename: terminalserver-config # Purpose: configuration program for grml-terminalserver # Authors: grml-team (grml.org), (c) Michael Gebetsroither # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Don Nov 16 14:39:51 CET 2006 [mika] +# Latest change: Son Jän 20 12:12:44 CET 2008 [mika] ################################################################################ @@ -38,7 +38,7 @@ IPRANGE_TO_="" NETWORK_="" OPTIONS_="" BOOT_ARGS_="" -NAT_INTERFACE_="none" +NAT_INTERFACE_="" ### @@ -56,7 +56,8 @@ COMMANDS: help This help text interactive Interactive Configuration of the grml-terminalserver - grubConf Configure grub and create boot-image (for non-PXE NICs) + grubConf Configure grub and create boot-image (for non-PXE NICs) + Read modules for grub from file if given. grubConfWrite Configure grub and write image to floppy disk grubWrite Write compiled grub-image to floppy disk grubMultiWrite batchwrite grub-image to floppy disk @@ -121,15 +122,40 @@ function actionAutoconf # INITRD {{{ - function actionMkInitrd { + echo echo -n "Creating initrd $PATH_/minirt26.gz: " - isExistent "$PATH_/minirt26.gz" && echo && echo "$PATH_/minirt26.gz exists already, skipping initrd creation" && return 0 - mkInitrd + if isExistent "$PATH_/minirt26.gz" ; then + echo + echo "$PATH_/minirt26.gz exists already, skipping initrd creation" + return 0 + fi + + if [ -e '/live/cow' ]; then + mkInitrdNew + else + mkInitrd + fi echo done } +function mkInitrdNew +{ + set -e + local cfg_="/etc/initramfs-tools/initramfs.conf" + local tmp_="`mktemp -t terminalserver__initramfsbk.XXXXXX`" + cp $cfg_ $tmp_ + sed -i 's/^MODULES=.*/MODULES=netboot/' $cfg_ + update-initramfs -u -t 1>/dev/null + mv $tmp_ $cfg_ + + local initrd_="/boot/initrd.img-$KERNEL_VERSION_" + mv $initrd_ $PATH_/minirt26.gz + mv ${initrd_}.bak $initrd_ + set +e +} + function mkInitrd { TMP_DIR_=`mktemp -td terminalserver_initrd.XXXXXX` @@ -273,7 +299,7 @@ for addresses from 192.168.0.101 to (and including) 192.168.0.200. local grub_message_="Do you have any NON-PXE network cards you would like to boot from?" # on witch interfaces should we listen - local netdevices_="$(cat /proc/net/dev | awk -F: '/eth.:|tr.:/{print $1}')" + local netdevices_="$(grep -ve 'lo:' -ve 'Inter-|' -ve 'face |bytes' /proc/net/dev | awk -F: '{print $1}')" local device_list_="" for INTERFACE_ in $netdevices_; do device_list_="$device_list_ ${INTERFACE_} Networkcard_${INTERFACE_##eth}"; done echo -n "" >"$TMP_" @@ -331,8 +357,8 @@ the internet?" NAT_INTERFACE_="$GW_DEV_" else # no NAT, no sensible gateway - GW_= - NAT_INTERFACE_="none" + GW_="" + NAT_INTERFACE_="" fi fi @@ -396,9 +422,8 @@ Quite usefull examples: ssh= - Start ssh server and set password of user grml to pw services=<1,2,3> - Execute /etc/init.d/{1,2,3} start -console=ttyS0,9600n8 - Initialise seriell console -secure - Boot only restricted clients (without root permissions) -startx - Boot into X (should be used with secure) +console=ttyS0,9600n8 - Initialise serial console +startx - Boot into X " @@ -468,7 +493,7 @@ function grubConfig local tmp_=`mktemp -td terminalserver_grub.XXXXXX` || warn "could not create tmp file for grubConfig" if [ -z "$tmp_" ]; then return 1; fi - grubConfigWork $tmp_ + grubConfigWork "$tmp_" "$1" local ret_=$? execute "rm -rf $tmp_" warn @@ -481,25 +506,32 @@ function grubConfigWork local grub_title_="Grub configuration" local grub_nic_message_=" -Give me the types of network cards you would want to boot from. -If you networkcard is already listed press ! +Please select the types of network cards you want to boot from. +If your networkcard is already listed just press ! -WARNING: DON't add all NIC's, grub could possibly stop working!!" +WARNING: Do NOT add all NICs, grub could possibly stop working!" local nics_="" - while read module_ desc_ mode_; do - nics_="$nics_ $module_ $desc_ $mode_" - done < $GRUB_NIC_CONF_ - - echo -n "" >$TMP_ - local cmd_line_="" - $DIALOG_ --clear --separate-output --backtitle "$BACK_TITLE_" --title "$grub_title_" --checklist \ - "$grub_nic_message_" 10 70 0 $nics_ 2>$TMP_ - local ret_=$? - if [[ $ret_ -ne 0 || `wc -l <$TMP_` -eq 0 ]]; then - echo $ret_ - warn "you should give me your specified NICs but didn't => DEFAULT will be used" - awk '/ on$/{print $1}' $GRUB_NIC_CONF_ >$TMP_ + if [[ $2 == "" ]]; then + while read module_ desc_ mode_; do + nics_="$nics_ $module_ $desc_ $mode_" + done < $GRUB_NIC_CONF_ + + echo -n "" >$TMP_ + local cmd_line_="" + $DIALOG_ --clear --separate-output --backtitle "$BACK_TITLE_" --title "$grub_title_" --checklist \ + "$grub_nic_message_" 10 70 0 $nics_ 2>$TMP_ + local ret_=$? + if [[ $ret_ -ne 0 ]]; then + die "exiting as requested" + fi + if [[ `wc -l <$TMP_` -eq 0 ]]; then + echo $ret_ + warn "you should give me your specified NICs but didn't => DEFAULT will be used" + awk '/ on$/{print $1}' $GRUB_NIC_CONF_ >$TMP_ + fi + else + cat $2 >$TMP_ fi while read module_; do cmd_line_="$cmd_line_ --enable-$module_" @@ -508,6 +540,7 @@ WARNING: DON't add all NIC's, grub could possibly stop working!!" echo "\"$cmd_line_\"" execute "tar xzf $GRUB_SOURCE_ -C $tmp_" warn || return 1 + local_dir="$(pwd)" execute "cd $tmp_/grub*" warn || return 1 cat >preset-menu < $PATH_/grub.img" warn || return 1 + + cd "$local_dir" + return 0 } @@ -625,7 +667,7 @@ fi case "$1" in interactive) actionInteractive ;; - grubConf) grubConfig ;; + grubConf) grubConfig "$2" ;; grubConfWrite) grubConfig && grubWrite ;; grubWrite) grubWrite ;; grubMultiWrite) grubMultiWrite "$2" ;;