Skip to content
Browse files

Drop all grub- and /linuxrc related stuff

  • Loading branch information...
1 parent c9f6a07 commit 3d2c6036d7453b108475d2936877060e153e68a5 @mika mika committed Oct 26, 2009
Showing with 33 additions and 1,650 deletions.
  1. +1 −20 Makefile
  2. +0 −10 cdir
  3. +8 −0 debian/changelog
  4. +8 −8 debian/control
  5. +3 −15 debian/grml-terminalserver-config.8
  6. +0 −6 debian/overrides
  7. +9 −29 debian/rules
  8. +4 −261 grml-terminalserver-config
  9. +0 −1,029 linuxrc
  10. +0 −75 modcalc.py
  11. +0 −12 rdir
  12. +0 −6 shared_prog_vars
  13. +0 −140 timeout.c
  14. +0 −39 udhcp-config.sh
View
21 Makefile
@@ -2,42 +2,23 @@ install_ = "install"
name = "grml-terminalserver"
-#ifndef CFLAGS
-CFLAGS = -Wall -O2
-#endif
-
etc = ${DESTDIR}/etc/grml/terminalserver
usr = ${DESTDIR}/usr
usrbin = $(usr)/bin
usrsbin = $(usr)/sbin
usrshare = $(usr)/share/$(name)
-bin: timeout
-
-timeout: timeout.c
- diet gcc $(CFLAGS) $^ -o $@
- strip --strip-unneeded $@
-
-install: bin
+install:
$(install_) -d -m 755 $(etc)
$(install_) -m 644 config $(etc)
$(install_) -d -m 755 $(usrshare)
- $(install_) -m 644 grub_cards $(usrshare)
$(install_) -m 644 default_config $(usrshare)
$(install_) -m 644 shared_prog_vars $(usrshare)
$(install_) -m 755 nfs-kernel-server $(usrshare)
$(install_) -m 644 terminalserver_netboot_package.conf $(usrshare)
- $(install_) -m 755 linuxrc $(usrshare)
- $(install_) -m 755 udhcp-config.sh $(usrshare)
- $(install_) -m 755 rdir $(usrshare)
- $(install_) -m 755 cdir $(usrshare)
- $(install_) -m 755 timeout $(usrshare)
cp -r templates $(usrshare)
$(install_) -m 755 -d $(usrsbin)
$(install_) -m 755 grml-terminalserver $(usrsbin)
$(install_) -m 755 grml-terminalserver-config $(usrsbin)
-
-clean:
- rm -f timeout
View
10 cdir
@@ -1,10 +0,0 @@
-#!/static/ash
-# creates the custom dir layout to load modules and execute discover
-
-if [ -e /mylib -o -e /myusr ]; then
- mv /lib /lib~
- mv /usr /usr~
- mv /mylib /lib
- mv /myusr /usr
-fi
-
View
8 debian/changelog
@@ -1,3 +1,11 @@
+grml-terminalserver (0.99.7) unstable; urgency=low
+
+ * Drop all grub-related stuff.
+ * Drop old linuxrc and related files, resulting in architecture independent
+ package.
+
+ -- Michael Prokop <mika@grml.org> Mon, 26 Oct 2009 16:47:35 +0100
+
grml-terminalserver (0.99.6) unstable; urgency=low
[ Ulrich Dangel ]
View
16 debian/control
@@ -3,17 +3,17 @@ Section: net
Priority: optional
Maintainer: Michael Gebetsroither <gebi@grml.org>
Uploaders: Michael Prokop <mika@grml.org>
-Build-Depends: debhelper (>= 5), dietlibc-dev
+Build-Depends: debhelper (>= 5)
Standards-Version: 3.8.3
Homepage: http://grml.org/terminalserver/
Vcs-git: git://git.grml.org/grml-terminalserver.git
Vcs-Browser: http://git.grml.org/?p=grml-terminalserver.git
Package: grml-terminalserver
-Architecture: any
-Depends: grml-shlib (>=1.02.03), grml-terminalserver-data (>=0.63), dialog, dhcp3-server, atftpd (>=0.7.dfsg-1.2), syslinux, gcc, ipcalc, ash, libc6-dev [i386], gcc-multilib [amd64], make, nfs-kernel-server, grml2usb (>=0.9.14)
-Description: terminalserver for grml
- This software should netboot grml on other computers over the
- network. The terminalserver also works with NON-PXE
- cards (compiles grub during configuration and makes a
- boot-disk).
+Architecture: all
+Depends: grml-shlib (>=1.02.03), dialog, dhcp3-server, atftpd (>=0.7.dfsg-1.2), syslinux, ipcalc, nfs-kernel-server, grml2usb (>=0.9.14)
+Description: terminalserver for grml to boot via PXE
+ This packages provides all what's needed to boot
+ grml over the network (PXE). An easy to use interface
+ does all the setup steps to get the server side up
+ and running.
View
18 debian/grml-terminalserver-config.8
@@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
-.TH GRML-TERMINALSERVER-CONFIG 8 "March 20, 2005"
+.TH GRML-TERMINALSERVER-CONFIG 8 "October 26, 2009"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@@ -16,7 +16,7 @@
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
-grml-terminalserver-config \- Config program for terminalserver coming with GRML
+grml-terminalserver-config \- Config program for terminalserver coming with Grml
.SH SYNOPSIS
.B grml-terminalserver-config
.RI [ options ] " <command>
@@ -29,7 +29,7 @@ This manual page documents briefly the
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively.
\fBgrml-terminalserver-config\fP is a program that
-provides the configuration script for the terminalserver coming with GRML.
+provides the configuration script for the terminalserver coming with Grml.
.SH OPTIONS
These programs follow the long option style without dashes and
short options starting with one dash (`-').
@@ -41,18 +41,6 @@ Interactive configuration of the terminalserver (same as option interactive).
.B interactive
Interactive configuring the terminalserver
.TP
-.B grubConf
-Configure grub and make boot-image (for non-PXE NICs)
-.TP
-.B grubConfWrite
-Configure grub & write image to floppy disk
-.TP
-.B grubWrite
-Write compiled grub-image to floppy disk
-.TP
-.B grubMultiWrite
-batchwrite grub-image to floppy disk (exiting with strg+c)
-.TP
.B clean
Remove all configfiles created during user configuration
.TP
View
6 debian/overrides
@@ -1,6 +0,0 @@
-grml-terminalserver: wrong-path-for-interpreter ./usr/share/grml-terminalserver/cdir (#!/static/ash != /bin/ash)
-grml-terminalserver: wrong-path-for-interpreter ./usr/share/grml-terminalserver/linuxrc (#!/static/sh != /bin/sh)
-grml-terminalserver: wrong-path-for-interpreter ./usr/share/grml-terminalserver/rdir (#!/static/ash != /bin/ash)
-grml-terminalserver: wrong-path-for-interpreter ./usr/share/grml-terminalserver/udhcp-config.sh (#!/static/sh != /bin/sh)
-grml-terminalserver: arch-dependent-file-in-usr-share ./usr/share/grml-terminalserver/timeout
-grml-terminalserver: statically-linked-binary ./usr/share/grml-terminalserver/timeout
View
38 debian/rules
@@ -9,25 +9,9 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-CFLAGS = -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
-
- touch configure-stamp
-
-
build: build-stamp
-build-stamp: configure-stamp
+build-stamp:
dh_testdir
# Add here commands to compile the package.
@@ -37,45 +21,41 @@ build-stamp: configure-stamp
clean:
dh_testdir
dh_testroot
- rm -f build-stamp configure-stamp
+ rm -f build-stamp
# Add here commands to clean up after the build process.
- $(MAKE) clean
- dh_clean
+ dh_clean
install: build
dh_testdir
dh_testroot
- dh_clean -k
+ dh_clean -k
dh_installdirs usr/sbin
# Add here commands to install the package into debian/grml-terminalserver.
$(MAKE) install DESTDIR=$(CURDIR)/debian/grml-terminalserver
+# Build architecture-dependent files here.
+binary-arch: build install
+# We have nothing to do by default.
# Build architecture-independent files here.
binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
dh_testdir
dh_testroot
- dh_installchangelogs
+ dh_installchangelogs
dh_installdocs
dh_installexamples
dh_installman debian/grml-terminalserver.8 debian/grml-terminalserver-config.8
dh_installexamples create-netboot
dh_link
dh_compress
- mkdir -p debian/grml-terminalserver/usr/share/lintian/overrides/
- cp -av debian/overrides debian/grml-terminalserver/usr/share/lintian/overrides/grml-terminalserver
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+.PHONY: build clean binary-indep binary-arch binary install
View
265 grml-terminalserver-config
@@ -55,11 +55,6 @@ COMMANDS:
help This help text
interactive Interactive Configuration of the grml-terminalserver
- grubConf <file> 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
initrd Only create the initrd
clean Remove all configfiles created during user configuration
<default> interactive mode
@@ -131,15 +126,12 @@ function actionMkInitrd
return 0
fi
- if [ -e '/live/cow' ]; then
- mkInitrdNew
- else
- mkInitrd
- fi
+ mkInitrd
+
echo '... done'
}
-function mkInitrdNew
+function mkInitrd
{
# we do not want to include persistent configuration files
# from udev in the initrd
@@ -171,121 +163,6 @@ function mkInitrdNew
rmdir "${udev_tmp_}"
fi
}
-
-function mkInitrd
-{
- TMP_DIR_=`mktemp -td terminalserver_initrd.XXXXXX`
- local i=''
- local tmp_loopname=''
-
- # copying original initrd into $INITRD
- execute "rm -r $INITRD_" 2>/dev/null
- execute "cp $ORIGINAL_INITRD_ $TMP_DIR_/minirt26.gz" warn || return 1
- execute "mkdir -p $INITRD_" warn || return 1
- execute "mkdir -p $PATH_/mini-root.orig" warn || return 1
- execute "gunzip $TMP_DIR_/minirt26.gz" warn || return 1
- tmp_loopname=`findNextFreeLoop die`
- execute "mount -o loop=$tmp_loopname $TMP_DIR_/minirt26 $PATH_/mini-root.orig " warn || return 1
- execute "cp -a $PATH_/mini-root.orig/* $INITRD_" warn || return 1
- execute "umount $PATH_/mini-root.orig" warn || return 1
- losetup -d $tmp_loopname &>/dev/null
- tmp_loopname=''
- execute "rmdir $PATH_/mini-root.orig" warn || return 1
- execute "rm $TMP_DIR_/minirt26" warn || return 1
-
- # implanting my initrd changes into the original initrd
-
- # copy programs, check if there are already links with this name to busybox
- for i in $USR_SHARE_/timeout $USR_SHARE_/udhcp-config.sh $USR_SHARE_/cdir $USR_SHARE_/rdir; do
- tmp_name_="${i##*/}"
- isNotExistent "$INITRD_/static/$tmp_name_" eprint || execute "rm $INITRD_/static/$tmp_name_"
- cp $i "$INITRD_/static/$tmp_name_"
- done
- cp $USR_SHARE_/linuxrc $INITRD_/
- mkdir -p $INITRD_/mylib
- mkdir -p $INITRD_/myusr
-
- #
- # which modules should i put into the ramdisk
- #
-
- # find *all* network drivers, but do not include wlan/pcmcia/... related ones
- # blacklist: proteon and depca as they seem to cause problems with udevsettle
- find ${MODULES_PATH_}/${KERNEL_VERSION_}/kernel/drivers/net/ -name \*.ko | \
- grep -v 'wireless\|wan\|hamradio\|wlan\|ppp\|irda\|pcmcia\|depca\|proteon' | \
- sed 's#.*./## ; s#\.ko##' | sort | uniq > $CARDS_DETECTED_BY_DISCOVER
-
- local modules="`cat $CARDS_DETECTED_BY_DISCOVER |xargs` af_packet"
- local modules_dep=""
-
- # get paths of modules + paths of all dependent modules
- echo -n "" >"$TMP_"
- for i in $modules; do
- tmp_=`awk -F: '{if($1~/'"$i".ko'/) {print $0}}' $MODULES_PATH_/$KERNEL_VERSION_/modules.dep`
- echo "${tmp_%%:*}"
- # FIXME ugly sed hack :(
- echo "${tmp_#*:}" | xargs -n1 echo | sed 's/://'
- done \
- | sort | uniq | while read module relax; do
- if [ -n "$module" ]; then
- echo "$module" >> $TMP_
- fi
- done
-
- # copy modules + dependend modules into ramdisk
- local mod_path_="$INITRD_/mylib/modules/$KERNEL_VERSION_"
- local tmp_dst_path_="$mod_path_/kernel"
- mkdir -p $tmp_dst_path_
- cat $TMP_ |sort |uniq |while read module; do
- local tmp_path=${module#*/kernel/}
- tmp_path=$tmp_dst_path_/${tmp_path%/*.ko}
- local module_path=$tmp_path/${module##/*/}
-
- isNotExistent "$tmp_path" dprint && mkdir -p "$tmp_path"
- isNotExistent "$module_path" dprint && cp "$MODULES_PATH_ROOT_DIFF_/$module" "$module_path"
- done
-
- # copying additional modules
- for i in fs/nfs/nfs.ko net/sunrpc/sunrpc.ko fs/lockd/lockd.ko net/packet/af_packet.ko; do
- local tmp_path="$tmp_dst_path_/${i%/*}"
- mkdir -p $tmp_path
- cp $MODULES_PATH_/$KERNEL_VERSION_/kernel/$i "$tmp_path"
- done
-
- # copying modules.*
- cp $MODULES_PATH_/$KERNEL_VERSION_/modules.dep $mod_path_
- cp $MODULES_PATH_/$KERNEL_VERSION_/modules.alias $mod_path_
- #grep "^\/lib\/modules\/$KERNEL_VERSION_\/kernel\/" $MODULES_PATH_/$KERNEL_VERSION_/modules.dep |\
- # sed "s/\/lib\/modules\/$KERNEL_VERSION_\/kernel\//\/modules\//g" > $mod_path_/modules.dep
-
- # put everything into the new initrd
- local tmp_size=`du -s $INITRD_ |awk '{print $1}'` # in kB
- let tmp_size=$tmp_size+1000
- local max_size=24000
- if (( $tmp_size >= $max_size )); then
- warn "Your initrd is $tmp_size kByte large => TOO BIG (should be <= ${max_size}kB)"
- warn "Please remove a few modules from $CARDS_DETECTED_BY_DISCOVER or edit $INITRD_ manually"
- return 1
- fi
-
- execute "dd if=/dev/zero of=$TMP_DIR_/minirt26 bs=${tmp_size}k count=1 &>/dev/null" warn || \
- warn "could not create filesystem image"
-
- tmp_loopname=`findNextFreeLoop die`
- execute "losetup $tmp_loopname $TMP_DIR_/minirt26" die
- execute "mke2fs -L \"GRML NETINIT\" -b 1024 -N 8192 -O none -F -q -m 0 $tmp_loopname" warn
-
- execute "mkdir $PATH_/minirt26_mountp" warn
- execute "mount $tmp_loopname $PATH_/minirt26_mountp" warn
- execute "cp -a $INITRD_/* $PATH_/minirt26_mountp" warn
- execute "umount $PATH_/minirt26_mountp" warn
- execute "losetup -d $tmp_loopname &>/dev/null" warn
- execute "rmdir $PATH_/minirt26_mountp" warn
- execute "gzip -9 $TMP_DIR_/minirt26" warn
- execute "rm -r $INITRD_" warn
- execute "mv $TMP_DIR_/minirt26.gz $PATH_"
- execute "rm -fr $TMP_DIR_"
-}
# }}}
@@ -311,8 +188,6 @@ for addresses from 192.168.0.101 to (and including) 192.168.0.200.
"
local runconfig_title_="Networkcard config"
local runconfig_message_="Would you like to configure your interfaces now?"
- local grub_title_="Grub configuration"
- 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_="$(grep -ve 'lo:' -ve 'Inter-|' -ve 'face |bytes' /proc/net/dev | awk -F: '{print $1}')"
@@ -378,15 +253,6 @@ the internet?"
fi
fi
-
- # grub -> do not use it anymore
- # echo -n "" >"$TMP_"
- # local grub_write_="YES"
- # $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$grub_title_" --yesno "$grub_message_" 5 75 && \
- # grubConfig || grub_write_="NO"
- grub_write_="NO"
-
-
# get options
#local OPT_IPTABLES_="yes"
#local OPT_SSH_="yes"
@@ -449,9 +315,6 @@ startx - Boot into X
BOOT_ARGS_="$BOOT_ARGS_ $(<$TMP_)"
writeConfig
- if [ $grub_write_ == "YES" ]; then
- grubWrite
- fi
actionMkInitrd
notice "GRML terminalserver successfully configured"
}
@@ -504,122 +367,6 @@ function optGrml2Hd
}
#}}}
-# GRUB CONFIG {{{
-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_" "$1"
- local ret_=$?
- execute "rm -rf $tmp_" warn
-
- return $ret_
-}
-
-function grubConfigWork
-{
- local tmp_="$1"
-
- local grub_title_="Grub configuration"
- local grub_nic_message_="
-Please select the types of network cards you want to boot from.
-If your networkcard is already listed just press <OK>!
-
-WARNING: Do NOT add all NICs, grub could possibly stop working!"
- local nics_=""
-
- 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 specify the 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_"
- done < $TMP_
-
- 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 <<EOT
-# Set up the serial terminal, first of all.
-#serial --unit=0 --speed=19200
-#terminal --timeout=0 serial
-
-# Initialize the network.
-#dhcp --with-configfile
-#bootp --with-configfile
-dhcp
-default 0
-timeout 0
-title Load config from Tftp server
- configfile (nd)/menu.lst
-EOT
-
- CC='gcc'
- test -r /lib64 && export CC="$CC -m32"
-
- CC="$CC" execute "./configure --enable-preset-menu=./preset-menu $cmd_line_" warn || read
- CC="$CC" execute "make -j2" warn || read #return 1
-
- local st1_="stage1/stage1"
- local st2_="stage2/stage2"
- isExistent $st1_ warn || return 1
- isExistent $st2_ warn || return 1
-
- if [ -r "$PATH_/grub.img" ] ; then
- execute "mv -fb $PATH_/grub.img $PATH_/grub.img.old"
- fi
-
- execute "cat $st1_ $st2_ > $PATH_/grub.img" warn || return 1
-
- cd "$local_dir"
-
- return 0
-}
-
-function grubWrite
-{
- local grub_title_="Grub configuration"
- $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$grub_title_" --yesno \
- "Do you want to write the grub image to /dev/fd0" 5 75 || return 1
-
- execute "dd if=$PATH_/grub.img of=/dev/fd0" warn || return 0
- return 1
-}
-
-function grubMultiWrite
-{
- local target_=${1:-'/dev/fd0'}
-
- isExistent "$PATH_/grub.img" die "you have to specify an image or run \"$PROG_NAME__ grubconf\""
- isExistent "$target_" die "$target_ is not a valied"
- while true; do
- echo -n "Please insert disk into $target_ and press <ENTER> (STRG-C for end)"
- read
- dd if=$PATH_/grub.img of="$target_"
- done
-}
-# }}}
-
function removeTmpFiles
{
@@ -628,7 +375,7 @@ function removeTmpFiles
function actionClean
{
- for i in dhcpd.conf grub.img minirt26.gz; do
+ for i in dhcpd.conf minirt26.gz; do
execute "rm -f $PATH_/$i*"
done
@@ -684,10 +431,6 @@ fi
case "$1" in
interactive) actionInteractive ;;
- grubConf) grubConfig "$2" ;;
- grubConfWrite) grubConfig && grubWrite ;;
- grubWrite) grubWrite ;;
- grubMultiWrite) grubMultiWrite "$2" ;;
initrd) actionMkInitrd ;;
clean) actionClean ;;
*) actionInteractive ;;
View
1,029 linuxrc
@@ -1,1029 +0,0 @@
-#!/static/sh
-# Filename: /linuxrc
-# Purpose: minirt for kernel 2.6 running on grml live-cd
-# Authors: (c) Klaus Knopper <knoppix@knopper.net>, (c) Michael Prokop <mika@grml.org>
-# Latest change: Tue Mar 27 23:05:51 CEST 2007
-#######################################################################################
-
-# hardcoded configurable options
-# Default maximum size of dynamic ramdisk in kilobytes
-RAMSIZE=1000000
-# End of options
-
-# Don't allow interrupt signals
-trap "" 1 2 3 15
-
-# Misc functions
-INSMOD="/static/insmod"
-# [ -x /modules/insmod ] && INSMOD="/modules/insmod"
-
-RMMOD="/static/rmmod"
-# [ -x /modules/rmmod ] && RMMOD="/modules/rmmod"
-
-# Builin filesystems
-# BUILTIN_FS="iso9660 ext2 vfat"
-BUILTIN_FS="iso9660 ext2 ext3 reiserfs vfat xfs jfs reiser4"
-
-mountit(){
-# Usage: mountit src dst "options"
-for fs in $BUILTIN_FS; do
- if test -b $1; then
- options="$3"
- case "$fs" in vfat)
- # We REALLY need this for Knoppix on DOS-filesystems
- shortname="shortname=winnt"
- [ -n "$options" ] && options="$options,$shortname" || options="-o $shortname"
- ;;
- esac
- mount -t $fs $options $1 $2 >/dev/null 2>&1 && return 0
- fi
-done
-return 1
-}
-
-FOUND_SCSI=""
-FOUND_GRML=""
-INTERACTIVE=""
-
-# Clean input/output
-exec >/dev/console </dev/console 2>&1
-
-# Mount /proc and /dev/pts
-mount -t proc /proc /proc
-
-# Disable kernel messages while probing modules in autodetect mode
-echo "0" > /proc/sys/kernel/printk
-
-mount -t devpts /dev/pts /dev/pts
-# Kernel 2.6
-mount -t sysfs /sys /sys >/dev/null 2>&1
-
-# Read boot command line with builtin cat command (shell read function fails in Kernel 2.4.19-rc1)
-CMDLINE="$(cat /proc/cmdline)"
-
-# Simple shell grep
-stringinfile(){
- case "$(cat $2)" in *$1*) return 0;; esac
- return 1
-}
-
-# same for strings
-stringinstring(){
- case "$2" in *$1*) return 0;; esac
- return 1
-}
-
-# Reread boot command line; echo last parameter's argument or return false.
-getbootparam(){
- stringinstring " $1=" "$CMDLINE" || return 1
- result="${CMDLINE##*$1=}"
- result="${result%%[ ]*}"
- echo "$result"
- return 0
-}
-
-# Check boot commandline for specified option
-checkbootparam(){
- stringinstring " $1" "$CMDLINE"
- return "$?"
-}
-
-if checkbootparam "nocolor" ; then
- echo "Disabling colors in bootsequence as requested on commandline."
- # Reset fb color mode
- RESET="]R"
- # ANSI COLORS
- # Erase to end of line
- CRE="
-"
- # Clear and reset Screen
- CLEAR="c"
-else
- # Reset fb color mode
- RESET="]R"
- # ANSI COLORS
- # Erase to end of line
- CRE="
-"
- # Clear and reset Screen
- CLEAR="c"
- # Normal color
- NORMAL=""
- # RED: Failure or error message
- RED=""
- # GREEN: Success message
- GREEN=""
- # YELLOW: Descriptions
- YELLOW=""
- # BLUE: System mesages
- BLUE=""
- # MAGENTA: Found devices or drivers
- MAGENTA=""
- # CYAN: Questions
- CYAN=""
- # BOLD WHITE: Hint
- WHITE=""
-fi
-
-# don't output anything if running with bootsplash feature
-if checkbootparam "splash" ; then
- echo ""
- echo "${WHITE}Welcome to"
- echo ""
- echo "${RED} ____ ____ __ __ _ "
- echo "${RED} / ___| _ \| \/ | | "
- echo "${RED} | | _| |_) | |\/| | | "
- echo "${RED} | |_| | _ <| | | | |___ "
- echo "${RED} \____|_| \_\_| |_|_____|"
- echo ""
- echo "${WHITE}grml.org - Linux for users of texttools and sysadmins."
- echo "${NORMAL}"
- exec >/dev/null </dev/null 2>&1
-fi
-
-# helper functions {{{
-#log_success_msg () {
-# echo " * $@"
-#}
-
-log_failure_msg () {
- echo " ${RED}*${NORMAL} $@"
-}
-
-#log_warning_msg () {
-# echo " ${BLUE}*${NORMAL} $@"
-#}
-
-# int log_begin_message (char *message)
-log_begin_msg () {
- echo -n " ${GREEN}*${NORMAL} $@"
-}
-
-log_warn_msg () {
- echo -n " ${YELLOW}*${NORMAL} $@"
-}
-
-# int log_end_message (int exitstatus)
-SUCCESS=" ${BLUE}[ ${GREEN}ok ${BLUE}]${NORMAL}"
-FAILED=" ${NORMAL}[${RED}fail${NORMAL}]"
-# }}}
-
-# Clear screen with colormode reset
-# echo "$CLEAR$RESET"
-# echo "$CLEAR"
-# Just go to the top of the screen
-# echo -n ""
-echo ""
-echo "${WHITE}Welcome to"
-echo ""
-echo "${RED} ____ ____ __ __ _ "
-echo "${RED} / ___| _ \| \/ | | "
-echo "${RED} | | _| |_) | |\/| | | "
-echo "${RED} | |_| | _ <| | | | |___ "
-echo "${RED} \____|_| \_\_| |_|_____|"
-echo ""
-echo "${WHITE}grml.org - Linux for users of texttools and sysadmins."
-echo "${NORMAL}"
-
-# We need the builtin commands and /static only starting at this point
-PATH=/static
-export PATH
-
-umask 022
-
-case "$CMDLINE" in *debuglinuxrc*) set -x; echo "linuxrc debugging activated"; DEBUG="yes"; ;; esac
-case "$CMDLINE" in *BOOT_IMAGE=expert\ *) INTERACTIVE="yes"; :>/interactive; ;; esac
-case "$CMDLINE" in *BOOT_IMAGE=vmware\ *) VMWARE="yes"; ;; esac
-case "$CMDLINE" in *modules-disk*) INTERACTIVE="yes"; ;; esac
-case "$CMDLINE" in *BOOT_IMAGE=debug\ *|*\ debug\ *) DEBUG="yes"; ;; esac
-case "$CMDLINE" in *secure*) SECURE=",nosuid"; ;; esac
-# Does the user want to skip scsi detection?
-NOSCSI=""
-NOUSB=""
-NOFIREWIRE=""
-case "$CMDLINE" in *noscsi*|*nobootscsi*) NOSCSI="yes"; ;; esac
-case "$CMDLINE" in *nousb\ *|*nobootusb*) NOUSB="yes"; ;; esac
-case "$CMDLINE" in *nofirewire*|*nobootfirewire*) NOFIREWIRE="yes"; ;; esac
-NOCD=""
-case "$CMDLINE" in *fromhd*) NOCD="yes"; ;; esac
-case "$CMDLINE" in *fromdvd*) FROMDVD="yes"; ;; esac
-case "$CMDLINE" in *idecd*|*atapicd*) IDECD="yes"; ;; esac
-case "$CMDLINE" in *noideraid*) NOIDERAID="yes"; ;; esac
-USB2="ehci-hcd.ko"
-case "$CMDLINE" in *nousb2*) USB2="" NOUSB2="yes"; ;; esac
-case "$CMDLINE" in *\ usb*) USB="yes"; ;; esac
-
-GRML_DIR="GRML"
-GRML_NAME="GRML"
-case "$CMDLINE" in *grml_dir=*) GRML_DIR="$grml_dir"; ;; esac
-case "$CMDLINE" in *grml_name=*) GRML_NAME="$grml_name"; ;; esac
-
-# NFS
-for i in $cmdline; do case "$i" in nfsdir=*|NFSDIR=*) eval $i;; esac; done
-[ -n "$nfsdir" ] && NFS="$nfsdir"
-
-if [ -n "$DEBUG" ]; then
- log_begin_msg "Bootoption debug detected. Printing kernel command line:"
- echo ""
- cat /proc/cmdline
-fi
-
-# Run a shell if in debug mode
-# echo "${BLUE}Dropping you to a busybox shell for debugging.${NORMAL}"
-stage=1
-rundebugshell(){
- if [ -n "$DEBUG" ]; then
- log_begin_msg "Starting intermediate shell stage $stage as requested by \"debug\" option."
- echo ""
- echo " ${GREEN}-${NORMAL} Just exit the shell to continue boot process...${NORMAL}"
- if [ -x /static/sh ]; then
- /static/sh
- else
- /bin/bash
- fi
- fi
-}
-rundebugshell
-
-# Mount module disk
-mountmodules(){
-TYPE="$1"; shift
-echo -n "${CRE}Please insert ${TYPE} modules disk and hit Return."
-read a
-echo -n "${CRE}Mounting ${TYPE} modules disk... "
-# We always mount over /modules/scsi (because it's there ;-)
-if mountit /dev/fd0 /modules/scsi "-o ro"; then
-echo "${GREEN}OK.${NORMAL}"
-return 0
-fi
-echo "${RED}NOT FOUND.${NORMAL}"
-return 1
-}
-
-# Unmount module disk
-umountmodules(){
-TYPE="$1"; shift
-echo -n "${CRE}Unmounting ${TYPE} modules disk... "
-umount /modules/scsi 2>/dev/null
-echo "${GREEN}DONE.${NORMAL}"
-}
-
-# Ask user for modules
-askmodules(){
- TYPE="$1"; shift
- echo "${TYPE} modules available:${WHITE}"
- c=""
- for m in "$@"; do
- if test -f "/modules/scsi/$m"; then
- test -z "$c" && { echo -n " $m"; c="1"; } || { echo " $m"; c=""; }
- fi
- done
- [ -n "$c" ] && echo ""
- echo "Load ${TYPE} Modules?"
- echo "[Enter full filename(s) (space-separated), Return for autoprobe, n for none] "
- echo -n "insmod module(s)> "
- read MODULES
- case "$MODULES" in n|N) MODULES=""; ;; y|"") MODULES="$*"; ;; esac
-}
-
-# Try to load the given modules (full path or current directory)
-loadmodules(){
- TYPE="$1"; shift
- test -n "$INTERACTIVE" && echo "6" > /proc/sys/kernel/printk
- echo ""
- for i in "$@"; do
- echo -n " Probing ${TYPE}... ${WHITE}$i${NORMAL}: "
- if test -f /modules/scsi/$i.ko && $INSMOD /modules/scsi/$i.ko >/dev/null 2>&1 && echo " $SUCCESS" || echo " failed " ; then
- case "$TYPE" in scsi|SCSI) FOUND_SCSI="yes"; ;; esac
- fi
- done
- test -n "$INTERACTIVE" && echo "0" > /proc/sys/kernel/printk
- echo -n "${CRE}"
-}
-
-# Check for SCSI, use modules on bootfloppy first
-# Trying to do kind of /proc/pci hardware detection
-if checkbootparam oldscsi ; then
- PROCPCI="`cat /proc/pci 2>/dev/null`"
- case "$PROCPCI" in *[Aa][Ii][Cc]-*|*[Aa][Hh][Aa]-*) SCSI_PROBE="$SCSI_PROBE aic7xxx" ;; esac
- case "$PROCPCI" in *[Bb][Uu][Ss][Ll][Oo][Gg][Ii][Cc]*) SCSI_PROBE="$SCSI_PROBE BusLogic" ;; esac
- case "$PROCPCI" in *[Tt][Rr][Mm]-[Ss]1040*|*[Dd][Cc]395*|*[Dd][Cc]315*) SCSI_PROBE="$SCSI_PROBE dc395x" ;; esac
- case "$PROCPCI" in *53[Cc]8*) SCSI_PROBE="$SCSI_PROBE sym53c8xx" ;; esac
- case "$PROCPCI" in *53[Cc]9*) SCSI_PROBE="$SCSI_PROBE NCR53C9x" ;; esac
- case "$PROCPCI" in *53[Cc]406*) SCSI_PROBE="$SCSI_PROBE NCR53c406a" ;; esac
- case "$PROCPCI" in *[Ii][Nn][Ii][Tt][Ii][Oo]\ *|*[Ii][Nn][Ii]-[Aa]100[Uu]2[Ww]*) SCSI_PROBE="$SCSI_PROBE initio" ;; esac
- case "$PROCPCI" in *[Mm][Pp][Tt]*[Ss][Cc][Ss][Ii]*) SCSI_PROBE="$SCSI_PROBE mptbase mptscsih" ;; esac
- case "$PROCPCI" in *[Aa][Dd][Vv][Aa][Nn][Cc][Ee][Dd]\ [Ss][Yy][Ss]*) SCSI_PROBE="$SCSI_PROBE advansys" ;; esac
- case "$PROCPCI" in *[Aa][Tt][Pp]8*|*[Aa][Ee][Cc]6*) SCSI_PROBE="$SCSI_PROBE atp870u" ;; esac
- case "$PROCPCI" in *[Dd][Tt][Cc]*) SCSI_PROBE="$SCSI_PROBE dtc" ;; esac
- case "$PROCPCI" in *[Ee][Aa][Tt][Aa]*) SCSI_PROBE="$SCSI_PROBE eata" ;; esac
- case "$PROCPCI" in *[Ff]*[Dd][Oo][Mm][Aa][Ii][Nn]*) SCSI_PROBE="$SCSI_PROBE fdomain" ;; esac
- case "$PROCPCI" in *[Gg][Dd][Tt]\ *) SCSI_PROBE="$SCSI_PROBE gdth" ;; esac
- case "$PROCPCI" in *[Mm][Ee][Gg][Aa][Rr][Aa][Ii][Dd]*) SCSI_PROBE="$SCSI_PROBE megaraid_mm megaraid_mbox" ;; esac
- case "$PROCPCI" in *[Qq][Ll][Oo][Gg][Ii][Cc]*) SCSI_PROBE="$SCSI_PROBE qlogicfas408 qlogicfas qlogicfc" ;; esac
- case "$PROCPCI" in *53[Cc]974*) SCSI_PROBE="$SCSI_PROBE tmscsim" ;; esac
- case "$PROCPCI" in *[Uu][Ll][Tt][Rr][Aa][Ss][Tt][Oo][Rr]*) SCSI_PROBE="$SCSI_PROBE ultrastor" ;; esac
- case "$PROCPCI" in *3[Ww][Aa][Rr][Ee]*) SCSI_PROBE="$SCSI_PROBE 3w-xxxx" ;; esac
-fi
-
-# New sysfs based SCSI detection (thanks, Jörg Schirottke)
-sysfsscsi(){
-SYS=$(for x in $(find /sys/devices/ -name modalias); do grep pci: $x; done|cut -f2 -d:)
-while read id driver; do
- for sysid in $SYS; do
- case $sysid in $id)
- if [ -z "$SCSI_PROBE" ]; then
- SCSI_PROBE="$driver"
- else
- SCSI_PROBE="$SCSI_PROBE $driver"
- fi
- ;;
- esac
- done
-done <<EOF
-$(cat /modules/scsi/scsi-modules.txt)
-EOF
-}
-
-if test -n "$INTERACTIVE"; then
-# Let the user select interactively
- askmodules SCSI $(cd /modules/scsi; echo *.ko)
-else
-# these are the autoprobe-safe modules
- sysfsscsi
- MODULES="$SCSI_PROBE"
-fi
-
-if test -z "$NOSCSI" ; then
- log_begin_msg "Scanning for SCSI devices."
- $INSMOD /modules/scsi/firmware_class.ko 1>/dev/null
- test -n "$MODULES" && loadmodules SCSI $MODULES && echo -n "" || echo " ${BLUE}[${NORMAL} none found ${BLUE}]${NORMAL} (try bootoption scsi=probe)"
-else
- log_warn_msg "Not scanning for SCSI devices as requested on commandline." && echo " $SUCCESS"
-fi
-
-if checkbootparam scsi ; then
- MODULE="$(getbootparam 'scsi' 2>/dev/null)"
- if test "$MODULE" = "probe" ; then
- log_begin_msg "Bootoption scsi=probe found. Trying to autoprobe SCSI modules:"
- echo ""
- echo -n " Trying to load scsi_debug: " ; $INSMOD /modules/scsi/scsi_debug.ko 1>/dev/null && echo " $SUCCESS" || echo " [ failed ]"
- for module in /modules/scsi/*.ko ; do
- echo -n " Probing ${WHITE}${module}${NORMAL}..."
- $INSMOD ${module} >/dev/null 2>&1 && echo " $SUCCESS" || echo " [ failed ]"
- done
- elif test "$MODULE" = "ask" ; then
- askmodules SCSI $(cd /modules/scsi; echo *.ko)
- test -z "$NOSCSI" && test -n "$MODULES" && loadmodules SCSI $MODULES
- else
- [ -n "$MODULE" ] || echo " ${RED}Neither a specific module nor option probe nor option ask for SCSI module given. Skipping.${NORMAL}"
- [ -n "$MODULE" ] && echo -n " Trying to load module ${WHITE}${MODULE}${NORMAL}:" ; \
- $INSMOD "/modules/scsi/${MODULE}.ko" 1>/dev/null && echo " $SUCCESS" || echo " [ failed ]"
- fi
-fi
-# End of SCSI check
-
-if test -n "$VMWARE" ; then
- log_begin_msg "Bootoption VMware detected. Trying to load SCSI modules:"
- echo ""
- for module in mptbase mptscsih mptspi BusLogic ; do
- echo -n " Trying to load ${WHITE}${module}${NORMAL}: "
- $INSMOD /modules/scsi/${module}.ko >/dev/null 2>&1 && echo " $SUCCESS" || echo " [ failed ]"
- done
-fi
-
-# Check for USB, use modules on bootfloppy first
-if test -z "$NOUSB"; then
- log_begin_msg "Checking for USB."
- if test -f /modules/div/usbcore.ko; then
- $INSMOD /modules/div/usbcore.ko >/dev/null 2>&1
- FOUNDUSB=""
- for i in $USB2 uhci-hcd.ko ohci-hcd.ko usbhid.ko ; do
- test -f /modules/div/$i && $INSMOD /modules/div/$i >/dev/null 2>&1 && FOUNDUSB="yes"
- done
- if test -n "$FOUNDUSB"; then
- test -f /modules/div/usb-storage.ko && $INSMOD /modules/div/usb-storage.ko >/dev/null 2>&1
- echo " $SUCCESS"
- else
- echo " ${BLUE}[${NORMAL} not found ${BLUE}]${NORMAL}"
- true
- fi
- if [ -n "$NOUSB2" ] ; then
- echo " Not loading usb2 module ehci-hcd as requested on commandline."
- echo " Notice: to skip loading of USB in initrd at all use bootoption nousb"
- fi
- fi
-else
- log_warn_msg "Not scanning for USB devices as requested on commandline." && echo " $SUCCESS"
- echo " Notice that bootoption nousb affects initrd only, it does *not*"
- echo " avoid loading of usb modules in userspace afterwards"
- echo " Boot using something like 'nousb blacklist=uhci-hcd' to avoid loading of usb modules at all"
-fi
-# End of USB check
-
-# Check for Firewire, use modules on bootfloppy first
-if test -z "$NOFIREWIRE" ; then
- log_begin_msg "Checking for Firewire."
- if test -f /modules/div/ieee1394.ko ; then
- $INSMOD /modules/div/ieee1394.ko > /dev/null 2>&1
- FOUNDFIREWIRE=""
- test -f /modules/div/ohci1394.ko && $INSMOD /modules/div/ohci1394.ko > /dev/null 2>&1 && FOUNDFIREWIRE="yes"
- if test -n "$FOUNDFIREWIRE" ; then
- test -f /modules/div/sbp2.ko && $INSMOD /modules/div/sbp2.ko > /dev/null 2>&1
- echo " $SUCCESS"
- else
- echo " ${BLUE}[${NORMAL} not found ${BLUE}]${NORMAL}"
- true
- fi
- fi
-else
- log_warn_msg "Not scanning for firewire devices as requested on commandline." && echo " $SUCCESS"
- echo " Notice that bootoption nofirewire affects initrd only, it does *not*"
- echo " avoid loading of firewire modules in userspace afterwards"
- echo " Boot with something like 'nofirewire blacklist=ohci1394' to avoid loading of firewire modules at all"
-fi
-# End of FIREWIRE check
-
-# Unfortunately, hotpluggable devices tend to need some time in order to register
-if test -n "$FOUNDUSB" -o -n "$FOUNDFIREWIRE"; then
- log_begin_msg "Scanning for USB/Firewire devices."
- sleep 4
- if test -n "$USB"; then
- sleep 10
- fi
- echo " $SUCCESS"
-fi
-
-if checkbootparam scandelay ; then
- DELAY="$(getbootparam 'scandelay' 2>/dev/null)"
- [ -z $DELAY ] && DELAY='10'
- log_begin_msg "Delaying bootsequence as requested for ${WHITE}${DELAY}${NORMAL} seconds."
- sleep $DELAY && echo " $SUCCESS"
-fi
-
-# boot via pcmcia
-if checkbootparam bootpcmcia ; then
- log_begin_msg "Bootoption bootpcmcia found. Trying to load ${WHITE}PCMCIA${NORMAL} modules..."
- if $INSMOD /modules/div/pcmcia_core.ko 1>/dev/null ; then
- $INSMOD /modules/div/firmware_class.ko 1>/dev/null && \
- $INSMOD /modules/div/pcmcia.ko 1>/dev/null && \
- $INSMOD /modules/div/rsrc_nonstatic.ko 1>/dev/null && \
- $INSMOD /modules/div/yenta_socket.ko 1>/dev/null && echo " $SUCCESS"
- else
- echo " [ failed ]"
- fi
-fi
-
-# Check for misc modules in expert mode
-if test -n "$INTERACTIVE" ; then
- another=""
- answer=""
- while test "$answer" != "n" -a "$answer" != "N" ; do
- echo -n "${CYAN}Do you want to load additional modules from$another floppy disk? [${WHITE}Y${CYAN}/n] ${NORMAL}"
- another=" another"
- read answer
- case "$answer" in n*|N*) break; ;; esac
- if mountmodules new ; then
- askmodules new $(cd /modules/scsi; echo *.ko)
- test -n "$MODULES" && loadmodules new $MODULES
- umountmodules current
- fi
- done
-fi
-# All interactively requested modules should be loaded now.
-
-# Check for ide-scsi supported CD-Roms et al.
-test -f /proc/scsi/scsi && FOUND_SCSI="yes"
-
-# Disable kernel messages again
-echo "0" > /proc/sys/kernel/printk
-
-# We now enable DMA right here, for faster reading/writing from/to IDE devices
-# in FROMHD or TORAM mode
-case "$CMDLINE" in *\ nodma*) ;; *)
- for d in $(cd /proc/ide 2>/dev/null && echo hd[a-z]); do
- if test -d /proc/ide/$d; then
- MODEL="$(cat /proc/ide/$d/model 2>/dev/null)"
- test -z "$MODEL" && MODEL="[GENERIC IDE DEVICE]"
- log_begin_msg "Enabling DMA acceleration for: ${MAGENTA}$d ${YELLOW}[${MODEL}]${NORMAL}"
- echo "using_dma:1" >/proc/ide/$d/settings && echo ""
- fi
- done
- ;;
-esac
-
-stage=2
-rundebugshell
-if [ -n "$NFS" ]; then
- tmp_="$(getbootparam nfsdir)"
- log_begin_msg "Bootoption NFS found." ; echo "$SUCCESS"
-
- /static/cdir
-
- log_begin_msg "Trying to load network driver(s)." ; echo
- modLoad()
- {
- for mod in $@ ; do
- if [ -n "$DEBUG" ] ; then
- echo "Debug: trying to load $mod:"
- modprobe -v $mod
- else
- modprobe $mod 2>/dev/null
- fi
- done
- }
- # modules.alias and modules.dep are in place so USE IT :)!
- find /sys/devices/ -name modalias |/static/xargs -r /static/grep -h pci: |while read i; do
- modLoad "$i"
- done
- # loading additional modules
- modLoad sunrpc lockd af_packet nfs
-
- dhcp_iface_=$(getbootparam dhcp_iface)
- if [ -z "$dhcp_iface_" ]; then
- dhcp_iface_=`ifconfig -a | grep '^eth' | sed 's/ .*//'`
- fi
-
- # make sure we have a udhcpc executable, if it's not present
- # assume that busybox provides one
- if ! [ -x /static/udhcpc ] ; then
- ln -s /static/busybox /static/udhcpc
- fi
-
- for INTERFACE in $dhcp_iface_ ; do
- log_begin_msg "Requesting network configuration using udhcp for ${INTERFACE}:" ; echo
- /static/timeout 10 /static/udhcpc --interface="${INTERFACE}" --foreground --quit --script=/static/udhcp-config.sh
- # echo "press <enter> to start a system shell and configure your system"
- # sh
- done
-
- # recreate dir layout + remove extra modules
- /static/rdir
-
- log_begin_msg "Looking for GRML in: ${MAGENTA}$NFS${NORMAL}" ; echo "$SUCCESS"
- if mount -t nfs "$NFS" -o "async,ro,nolock" /cdrom #>/dev/null 2>&1
- then
- if test -f /cdrom/$GRML_DIR/$GRML_NAME
- then
- log_begin_msg "Accessing grml CDROM at ${MAGENTA}$NFS${NORMAL}" ; echo "$SUCCESS"
- FOUND_GRML="$NFS"
- break
- fi
- fi
-fi
-
-# Now that the right SCSI driver is (hopefully) loaded, try to find CD-ROM
-if test -z $NFS ; then
- DEVICES="/dev/hd?"
- test -n "$FOUND_SCSI" -a -z "$NOCD" && DEVICES="/dev/scd? /dev/scd?? $DEVICES"
- # New: Also try parallel port CD-Roms [for Mike].
- DEVICES="$DEVICES /dev/pcd?"
- # New: also check HD partitions for a GRML/GRML image
- # notice: use /dev/sd? for usb-sticks without partition(s)
- test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9] /dev/sd?"
- DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
- case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd"; ;; esac
- for i in $DEVICES
- do
- log_begin_msg "${CRE} ${GREEN}*${NORMAL} Looking for CD-ROM in: ${MAGENTA}$i${NORMAL}"
- if mountit $i /cdrom "-o ro" >/dev/null 2>&1
- then
- echo " $SUCCESS"
- if test -f /cdrom/$GRML_DIR/$GRML_NAME
- then
- log_begin_msg "Accessing grml CD-ROM at: ${MAGENTA}$i${NORMAL}" ; echo " $SUCCESS"
- FOUND_GRML="$i"
- break
- fi
- umount /cdrom
- fi
- done
-fi
-
-# Harddisk-installed script part version has been removed
-# (GRML can be booted directly from HD now).
-mount_grml()
-{
- if test -n "$FOUND_GRML" -a -f $1/$GRML_DIR/$GRML_NAME; then
- # echo "6" > /proc/sys/kernel/printk
- mount -t squashfs $1/$GRML_DIR/$GRML_NAME /GRML -o loop,ro$SECURE || FOUND_GRML=""
- fi
-}
-
-remount_grml()
-{
- if test -f $TARGET/$GRML_DIR/$GRML_NAME; then
- umount /GRML # unmount it
- umount $SOURCE # unmount CD
- [ -n "$SOURCE2" ] && umount $SOURCE2 # umount possible loop-device
- mount_grml $TARGET
- else
- log_failure_msg "Warning: Changing to $TARGET failed."
- return 1
- fi
-
- return 0
-}
-
-boot_from()
-{
- # preparations
- /bin/mkdir $TARGET
-
- SOURCE_DEV=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/bootfrom=/s/.*=//p' | /usr/bin/tail -1)
-
- LOOP_DEV=$(echo $SOURCE_DEV | /usr/bin/gawk -F/ '{ print $1 "/" $2 "/" $3 }')
- ISO_PATH=$(echo $SOURCE_DEV | /bin/sed "s|$LOOP_DEV||g" )
- case "$ISO_PATH" in /*.[iI][sS][oO]) ;; *) ISO_PATH="" ;; esac
- LOOP_SOURCE=""
-
- # load filesystems
- /GRML/sbin/modprobe fuse
- /GRML/sbin/modprobe ntfs
- $INSMOD /modules/div/ntfs.ko 1>/dev/null
-
- if [ -n "$ISO_PATH" ]; then
- LOOP_SOURCE="$TARGET.loop"
- LOOP_SOURCE2="$LOOP_SOURCE"
- TARGET_DEV="$LOOP_SOURCE$ISO_PATH"
- /bin/mkdir $LOOP_SOURCE
- /bin/mount -o ro $LOOP_DEV $LOOP_SOURCE || LOOP_SOURCE=""
- /bin/mount -n -o loop $LOOP_SOURCE2$ISO_PATH $TARGET
- else
- TARGET_DEV="$SOURCE_DEV"
- /bin/mount -n -o ro $SOURCE_DEV $TARGET
- fi
- if [ $? -ne 0 ]; then
- [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE
- log_failure_msg "Accessing grml CD-ROM failed. ${MAGENTA}$TARGET_DEV${NORMAL} is not mountable."
- sleep 2
- return 1
- fi
-
- if [ -f $TARGET/$GRML_DIR/$GRML_NAME ]; then
- log_begin_msg "Accessing grml CD-ROM at ${MAGENTA}$TARGET_DEV${NORMAL}." ; echo " $SUCCESS"
- else
- log_failure_msg "Accessing grml CD-ROM failed. Could not find $GRML_DIR/$GRML_NAME on ${MAGENTA}$TARGET_DEV${RED}.${NORMAL}"
- [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE
- umount $TARGET
- sleep 2
- return 1
- fi
- # remount the CD
- remount_grml
-}
-
-copy_to()
-{
- # preparations
- /bin/mkdir $TARGET
- COPY="$SOURCE/$GRML_DIR"
-
- # look if we copy to hd or to ram
- SIZE="$(/usr/bin/du -s $COPY | /usr/bin/gawk '{print int($1*1.1)}')"
- test -n "$SIZE" || SIZE="800000"
-
- case "$1" in
- ram)
- TARGET_DEV="/dev/shm"
- TARGET_DEV_DESC="ramdisk"
- FOUNDSPACE="$(/usr/bin/gawk '/MemTotal/{print $2}' /proc/meminfo)"
- /bin/mount -n -t tmpfs -o size=${SIZE}k $TARGET_DEV $TARGET
- ;;
- hd)
- TARGET_DEV=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/tohd=/s/.*=//p' | /usr/bin/tail -1)
- TARGET_DEV_DESC="$TARGET_DEV"
- # load filesystems
- /GRML/sbin/modprobe fuse
- /GRML/sbin/modprobe ntfs
- FS="ext3 ext2 reiserfs reiser4 vfat ntfs"
-
- MOUNTED=""
- for i in $FS; do
- if /GRML/bin/mount -o rw -t "$i" "$TARGET_DEV" "$TARGET"; then
- MOUNTED="true"
- break
- fi
- done
- if test -z "$MOUNTED"; then
- log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} is not mountable."
- sleep 2
- return 1
- fi
- # check for enough free space
- USED_SPACE=0
- [ -f $TARGET/$GRML_DIR/$GRML_NAME ] && USED_SPACE=$(/usr/bin/du -s $TARGET/$GRML_DIR/$GRML_NAME | /usr/bin/gawk '{ print $1 }')
- FOUNDSPACE="$(/bin/df -k $TARGET | /usr/bin/tail -1 | /usr/bin/gawk '{ print $4+int('$USED_SPACE') }')"
- ;;
- *)
- return 1
- ;;
- esac
-
- # sanity check
-
- if [ $FOUNDSPACE -lt $SIZE ]
- then
- log_failure_msg "Copying grml CD-ROM failed. Not enough free space on ${MAGENTA}${TARGET_DEV_DESC}${NORMAL}. Found: ${MAGENTA}${FOUNDSPACE}k${NORMAL} Need: ${MAGENTA}${SIZE}k${NORMAL}"
- sleep 2
- umount $TARGET
- return 1
- fi
-
- # do the real copy
-
- log_begin_msg "Copying grml CD-ROM to ${TARGET_DEV_DESC}... Please be patient."
- echo
- if [ -z "$use_cp" -a -x /usr/bin/rsync ]
- then
- # first cp the small files
- /usr/bin/rsync -a --exclude="$GRML_DIR/$GRML_NAME" $COPY $TARGET # Copy grml to $TARGET
- # then the big file with nice progress meter
- [ -f $TARGET/$GRML_DIR/$GRML_NAME ] && /bin/rm -f $TARGET/$GRML_DIR/$GRML_NAME
- /usr/bin/rsync -a --progress --include="$GRML_DIR/$GRML_NAME" --include="$GRML_DIR/" --exclude="*" $COPY $TARGET # Copy grml to $TARGET
- #/usr/bin/rsync -avP $COPY $TARGET # Copy grml to $TARGET
- # make sure to support directories from http://grml.org/config/
- for dir in scripts bootparams config debs ; do
- if [ -d "/cdrom/$dir" ] ; then
- log_begin_msg "Customization directory $dir found, copying to $TARGET"
- cp -a /cdrom/$dir $TARGET/ && echo "$SUCCESS" || echo "$FAILED"
- fi
- done
- else
- /bin/cp -a -f $COPY $TARGET # Copy grml to $TARGET
- fi
- if [ $? -ne 0 ]
- then
- log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} possibly has not enough space left."
- sleep 2
- return 1
- fi
- # remount r/o
- /bin/mount -n -o remount,ro $TARGET 1>/dev/null 2>&1
- remount_grml
-}
-
-mount_grml /cdrom
-
-COPYTO=""
-BOOTFROM=""
-DO_REMOUNT=""
-REAL_TARGET=""
-UNIONFS=""
-
-case "$CMDLINE" in *toram*) DO_REMOUNT="yes"; COPYTO="ram"; ;; esac
-case "$CMDLINE" in *tohd=*) DO_REMOUNT="yes"; COPYTO="hd"; ;; esac
-case "$CMDLINE" in *bootfrom=*) DO_REMOUNT="yes"; BOOTFROM="yes" ;; esac
-
-# Remount later after copying/isoloading/driverloading?
-# pre-test if everything succeeded
-if test -n "$DO_REMOUNT" -a -n "$FOUND_GRML" ; then
- # copy library cache
- cat /GRML/etc/ld.so.cache > /etc/ld.so.cache
- echo ""
-
- SOURCE="/cdrom"
- TARGET="/cdrom2"
-
- # first copy_to, then boot_from
- if [ -n "$COPYTO" ]; then
- copy_to $COPYTO && REAL_TARGET="$TARGET"
- fi
- if [ -n "$BOOTFROM" ]; then
- boot_from
- if [ "$?" -eq "0" ]; then
- # set new source / target paths
- REAL_TARGET="$TARGET"
- SOURCE2="$LOOP_SOURCE"
- SOURCE="/cdrom2"
- TARGET="/cdrom3"
- fi
- fi
-fi
-
-# Final test if everything succeeded.
-if test -n "$FOUND_GRML" ; then
-# copy library cache
-cat /GRML/etc/ld.so.cache > /etc/ld.so.cache
-
-UNIONFS=""
-if checkbootparam "unionfs" ; then
- $INSMOD /modules/unionfs.ko 1>/dev/null
- grep -q unionfs /proc/filesystems && UNIONFS=yes
- unionfs='unionfs'
- UNIONFS_FILETYPE='unionfs'
- AUFS=''
-else
- $INSMOD /modules/aufs.ko 1>/dev/null
- grep -q aufs /proc/filesystems && UNIONFS=yes
- unionfs='unionfs (using aufs)'
- UNIONFS_FILETYPE='aufs'
- AUFS='yes'
-fi
-
-# Set paths
-log_begin_msg "Setting paths"
-PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:."
-export PATH
-
-# Make space: We don't need the modules anymore from here.
-/GRML/bin/rm -rf /modules
-# Debian weirdness
-/GRML/bin/cp -a /GRML/etc/alternatives /etc/ 2>/dev/null
-
-# Replace /sbin
-/GRML/bin/rm -f /sbin
-/GRML/bin/ln -sf /GRML/sbin /sbin
-
-# From here, we should have all essential commands available.
-hash -r
-
-# Did we remount the source media?
-if test -n "$REAL_TARGET"; then
- /bin/mount -n --move $REAL_TARGET /cdrom # move it back and go on to normal boot
-fi
-
-# Clean up /etc/mtab (and - just in case - make a nice entry for looped ISO)
-egrep " /GRML | /cdrom " /proc/mounts 2>/dev/null | sed 's|/dev/loop0 /cdrom \(.*\) 0 0|'$LOOP_SOURCE$ISO_PATH' /cdrom/ \1,loop=/dev/loop0 0 0|g' >> /etc/mtab
-
-# Clean up /
-/GRML/bin/rm -rf /modules /static
-echo " $SUCCESS"
-
-# New in Kernel 2.4.x: tempfs with variable ramdisk size.
-# We check for available memory anyways and limit the ramdisks
-# to a reasonable size.
-FOUNDMEM="$(awk '/MemTotal/{print $2}' /proc/meminfo)"
-TOTALMEM="$(awk 'BEGIN{m=0};/MemFree|Cached/{m+=$2};END{print m}' /proc/meminfo)"
-
-# Be verbose
-if [ -n "$FOUNDMEM" ] ; then
- log_begin_msg "Total memory found: $FOUNDMEM kB" ; echo " $SUCCESS"
-else
- log_failure_msg "Could not fetch memory information." ; echo " $FAILED"
-fi
-
-# Now we need to use a little intuition for finding a ramdisk size
-# that keeps us from running out of space, but still doesn't crash the
-# machine due to lack of Ram
-
-# Minimum size of additional ram partitions
-MINSIZE=20000
-# At least this much memory minus 30% should remain when home and var are full.
-MINLEFT=16000
-# Maximum ramdisk size
-[ -n "$TOTALMEM" ] && MAXSIZE="$(/usr/bin/expr $TOTALMEM - $MINLEFT)"
-# Default ramdisk size for ramdisk
-[ -n "$TOTALMEM" ] && RAMSIZE="$(/usr/bin/expr $TOTALMEM / 5)"
-
-# Create additional dynamic ramdisk.
-test -z "$RAMSIZE" -o "$RAMSIZE" -lt "$MINSIZE" && RAMSIZE="$MINSIZE"
-mkdir -p /ramdisk
-# tmpfs/varsize version, can use swap
-RAMSIZE=$(/usr/bin/expr $RAMSIZE \* 4)
-log_begin_msg "Creating /ramdisk (dynamic size=${RAMSIZE}k) on shared memory"
-# We need /bin/mount here for the -o size= option
-/bin/mount -t tmpfs -o "size=${RAMSIZE}k" /ramdisk /ramdisk && echo "$SUCCESS"
-mkdir -p /ramdisk/tmp /ramdisk/home/grml && chmod 1777 /ramdisk/tmp && chown grml.grml /ramdisk/home/grml && ln -snf /ramdisk/home /home && /bin/mv /tmp /tmp.old && ln -s /ramdisk/tmp /tmp && rm -rf /tmp.old
-
-stage=3
-rundebugshell
-# unionfs
-log_begin_msg "Creating $unionfs and symlinks on ramdisk"
-mkdir -p /UNIONFS
-if test -n "$UNIONFS" && /bin/mount -t $UNIONFS_FILETYPE -o noatime${SECURE},dirs=/ramdisk=rw:/GRML=ro /UNIONFS /UNIONFS ; then
- # check architecture
- if [ -f /GRML/lib/ld-linux.so.2 ] ; then
- LDLINUX=/GRML/lib/ld-linux.so.2
- GRMLLIB=/GRML/lib
- elif [ -f /GRML/lib64/ld-linux-x86-64.so.2 ] ; then
- LDLINUX=/GRML/lib64/ld-linux-x86-64.so.2
- EMUL='emul'
- LIB64='lib64'
- GRMLLIB=/GRML/lib64
- fi
- # We now have unionfs, copy some data from the initial ramdisk first
- cp -a /etc/fstab /etc/auto.mnt /etc/filesystems /etc/mtab /UNIONFS/etc/
- # disable resolvconf on the terminalserver client
- if [ -n "$NFS" ] ; then
- rm /UNIONFS/etc/resolv.conf
- cp -a /etc/resolv.conf /UNIONFS/etc
- echo REPORT_ABSENT_SYMLINK=no >> /UNIONFS/etc/default/resolvconf
- fi
- for i in bin boot etc sbin var opt root usr $EMUL $LIB64 lib ; do # Move directories to unionfs
- if test -d /$i; then
- /bin/mv /$i /$i.old && \
- # /GRML/lib/ld-linux.so.2 --library-path /GRML/lib /GRML/bin/ln -snf /UNIONFS/$i /$i && \
- $LDLINUX --library-path $GRMLLIB /GRML/bin/ln -snf /UNIONFS/$i /$i 1>/dev/null 2>/dev/null
- rm -rf /$i.old
- else
- ln -snf /UNIONFS/$i /$i
- fi
- done
- [ -n "$AUFS" ] && echo " $SUCCESS" || echo " $SUCCESS"
- log_begin_msg "Merging read-only system with read-writeable /ramdisk."
- for i in $(cd /UNIONFS; echo *); do # Create links for new stuff on /UNIONFS
- test "$i" = "home" -o "$i" = "tmp" && continue
- test -L "/$i" || test -d "/$i" || test -f "/$i" || ln -snf "/UNIONFS/$i" /$i
- done && echo " $SUCCESS" || echo " $FAILED"
-else
- echo ""
- log_failure_msg "ERROR: CANNOT UNITE READ-ONLY MEDIA AND INITIAL RAMDISK!"
- echo "$FAILED"
- sleep 2
- echo "Can not continue booting, dropping you to a busybox shell."
- stage=4
- rundebugshell
-fi
-
-chown grml.grml /home/grml
-# old:
-# chmod 1777 /var/tmp
-# new:
-rm -rf /var/tmp/ ; mkdir /var/tmp ; chown root.root /var/tmp ; chmod 1777 /var/tmp
-
-# Create empty utmp and wtmp
-:> /var/run/utmp
-:> /var/run/wtmp
-
-# Make SURE that these are files, not links!
-rm -rf /etc/ftpusers /etc/passwd /etc/shadow /etc/group \
- /etc/ppp /etc/isdn /etc/ssh /etc/ioctl.save \
- /etc/inittab /etc/network /etc/sudoers \
- /etc/init /etc/localtime /etc/dhcpc /etc/pnm2ppa.conf 2>/dev/null
-cp -a /GRML/etc/ftpusers /GRML/etc/passwd /GRML/etc/shadow /GRML/etc/group \
- /GRML/etc/ppp /GRML/etc/isdn /GRML/etc/ssh \
- /GRML/etc/inittab /GRML/etc/network /GRML/etc/sudoers \
- /GRML/sbin/init /GRML/etc/dhcpc /etc/ 2>/dev/null
-
-# Extremely important, init crashes on shutdown if this is only a link
-:> /etc/ioctl.save
-:> /etc/pnm2ppa.conf
-# Must exist for samba to work
-[ -d /var/lib/samba ] && :> /var/lib/samba/unexpected.tdb
-# Diet libc bug workaround
-# cp -f /GRML/etc/localtime /etc/localtime
-# echo "${BLUE}Done.${NORMAL}"
-
-# Now tell kernel where the real modprobe lives
-echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
-
-# Change root device from /dev/fd0 to /dev/ram0
-echo "0x100" > /proc/sys/kernel/real-root-dev
-
-/bin/umount /sys # (remount in grml-autoconfig)
-
-stage=4
-rundebugshell
-# Give control to the init process.
-log_begin_msg "Starting init process. "
-[ -r /mountit ] && rm -f /mountit
-rm -f /linuxrc
-exit 0
-
-else
- log_failure_msg "Error: Can't find grml filesystem, sorry."
- echo "
-Are you booting via USB or firewire?
-====================================
-Try to boot with bootparam scandelay which delays the
-bootup sequence so modules should have enough time
-to initialize devices.
-
-Usage examples on bootprompt of grml-iso:
-
-grml scandelay -> adds the default delay of 10 seconds
-grml scandelay=13 -> adds a delay of 13 seconds
-
-Are you booting via SCSI?
-====================================
-Use the bootparam scsi.
-Usage examples on bootprompt of grml-iso:
-
-grml scsi=probe -> autoprobing of scsi modules
-grml scsi=ask -> list modules and prompt for module which should be loaded
-grml scsi=modulename -> loads specified module (without .ko extension)
-expert -> activate expert mode, similar to scsi=ask
-
-Are you getting SquashFS/zlib errors?
-=====================================
-Try to boot with \"grml nodma\"
-
-Still problems?
-===============
-Make sure the ISO itself is ok.
-Check the md5sum of downloaded ISO.
-Used a CD-RW? Make sure the medium is ok!
-
-Please report any problems you notice to the grml-team!
-http://grml.org/contact/
-"
- echo "${RED}Now dropping you to the busybox shell.${NORMAL}"
- echo "${RED}Press reset button to quit.${NORMAL}"
- echo ""
- PS1="grml# "
- export PS1
- echo "6" > /proc/sys/kernel/printk
- # Allow signals
- trap 1 2 3 15
- exec /static/sh
View
75 modcalc.py
@@ -1,75 +0,0 @@
-#!/usr/bin/python2.4
-
-import sys
-import os
-
-def getNicModules():
- """Get all NIC modules which discover is able to find"""
- f = open('/lib/discover/pci.lst', 'r')
- import re
- ethlinefilter = re.compile('ethernet')
- modlist = filter(ethlinefilter.search, f)
- new_modlist = set()
- for i in modlist:
- tmplist = i.split('\t', 4)
- try:
- type = tmplist[2]
- mod = tmplist[3]
- except:
- continue
- if type == 'ethernet' and mod != 'unknown':
- new_modlist.add(mod)
- f.close()
- return new_modlist
-
-def basename(p):
- """Quite faster implementation of os.path.basename, submitted and accepted"""
- i = p.rfind('/') + 1
- return p[i:]
-
-def generateModDep():
- """Generate an in-memory represenation of all module dependencies"""
- moddep = {}
- moddepfile = open(sys.argv[1], 'r')
- for i in moddepfile:
- tmplist = i.split()
- mainmod = tmplist.pop(0)
- mainmod = mainmod.rstrip(':')
- rawmod = mainmod.rstrip('.ko')
- rawmod = basename(rawmod)
- newlist = []
- newlist.append((rawmod, mainmod))
- for i in tmplist:
- a = i.rstrip('.ko')
- a = basename(a)
- newlist.append((a, i))
- moddep[rawmod] = newlist
- moddepfile.close()
- return moddep
-
-def generateOutput(modlist, moddep):
- """Function to filter all keys from moddep not in modlist"""
- output = {}
- for i in modlist:
- try:
- for (j, k) in moddep[i]:
- output[j] = k
- except:
- continue
- return output
-
-def calculateModuleDep():
- modlist = getNicModules()
- moddep = generateModDep()
- output = generateOutput(modlist, moddep)
- return output.values()
-
-#############################################################################
-
-if __name__ == '__main__':
- if len(sys.argv) != 2:
- print 'Error: you should give me the path to your modules.dep'
- sys.exit(1)
-
- for i in calculateModuleDep():
- print i
View
12 rdir
@@ -1,12 +0,0 @@
-#!/static/ash
-# recreate the old dir structures
-
-if [ -e /mylib -o -e /myusr ]; then
- return 0
-else
- mv /lib /mylib
- mv /usr /myusr
- mv /lib~ /lib
- mv /usr~ /usr
-fi
-
View
6 shared_prog_vars
@@ -58,12 +58,6 @@ TFTPD_PID_="/var/run/grml-tftpd.pid"
# the dir where the templates for the configuration files are stored
TEMPLATE_CONFIG_DIR_="$USR_SHARE_/templates"
-# this file provides which nic's grub is able to boot from and sane defaults
-GRUB_NIC_CONF_="$USR_SHARE_/grub_cards"
-
-# this file is provided by another debian package (grml-terminalserver-data)
-GRUB_SOURCE_="$USR_SHARE_/grub-0.97.tar.gz"
-
# maximum initrd size
MAX_INITRD_SIZE_=16000
View
140 timeout.c
@@ -1,140 +0,0 @@
-/*++
- * NAME
- * timeout 1
- * SUMMARY
- * run command with bounded time
- * SYNOPSIS
- * \fBtimeout\fR [-\fIsignal\fR] \fItime\fR \fIcommand\fR ...
- * DESCRIPTION
- * \fBtimeout\fR executes a command and imposes an elapsed time limit.
- * The command is run in a separate POSIX process group so that the
- * right thing happens with commands that spawn child processes.
- *
- * Arguments:
- * .IP \fI-signal\fR
- * Specify an optional signal to send to the controlled process.
- * By default, \fBtimeout\fR sends SIGKILL, which cannot be caught
- * or ignored.
- * .IP \fItime\fR
- * The elapsed time limit after which the command is terminated.
- * .IP \fIcommand\fR
- * The command to be executed.
- * DIAGNOSTICS
- * The command exit status is the exit status of the command
- * (status 1 in case of a usage error).
- * AUTHOR(S)
- * Wietse Venema
- * This program is part of SATAN.
- *--
- */
-
-/* System libraries. */
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-
-extern int optind;
-
-/* Application-specific. */
-
-#define perrorexit(s) { perror(s); exit(1); }
-#define WRITE(x) write(2, x, strlen(x))
-
-static int kill_signal = SIGKILL;
-static char *progname;
-static char *commandname;
-
-// fmt_ulong and fmt_long from libowfat {{{
-unsigned int fmt_ulong(char *dest,unsigned long i) {
- register unsigned long len,tmp,len2;
- /* first count the number of bytes needed */
- for (len=1, tmp=i; tmp>9; ++len) tmp/=10;
- if (dest)
- for (tmp=i, dest+=len, len2=len+1; --len2; tmp/=10)
- *--dest = (tmp%10)+'0';
- return len;
-}
-
-unsigned int fmt_long(char *dest,long int i) {
- if (i<0) {
- if (dest) *dest++='-';
- return fmt_ulong(dest,-i)+1;
- } else
- return fmt_ulong(dest,i);
-}
-// }}}
-
-static void usage()
-{
- //fprintf(stderr, "usage: %s [-signal] time command...\n", progname);
- WRITE("usage: ");
- WRITE(progname);
- WRITE(" [-signal] time command...\n");
- exit(1);
-}
-
-static void terminate(int sig)
-{
- signal(kill_signal, SIG_DFL);
- //fprintf(stderr, "Timeout: aborting command ``%s'' with signal %d\n",
- // commandname, kill_signal);
- char kill_signal_string[22];
- fmt_long(kill_signal_string, kill_signal);
- WRITE("Timeout: aborting command ``");
- WRITE(commandname);
- WRITE("'' with signal ");
- WRITE(kill_signal_string);
- WRITE("\n");
- kill(0, kill_signal);
-}
-
-int main(int argc, char** argv)
-{
- int time_to_run = 0;
- pid_t pid;
- pid_t child_pid;
- int status;
-
- progname = argv[0];
-
- /*
- * Parse JCL.
- */
- while (--argc && *++argv && **argv == '-')
- if ((kill_signal = atoi(*argv + 1)) <= 0)
- usage();
-
- if (argc < 2 || (time_to_run = atoi(argv[0])) <= 0)
- usage();
-
- commandname = argv[1];
-
- /*
- * Run the command and its watchdog in a separate process group so that
- * both can be killed off with one signal.
- */
- setsid();
- switch (child_pid = fork()) {
- case -1: /* error */
- perrorexit("timeout: fork");
- case 0: /* run controlled command */
- execvp(argv[1], argv + 1);
- perrorexit(argv[1]);
- default: /* become watchdog */
- (void) signal(SIGHUP, terminate);
- (void) signal(SIGINT, terminate);
- (void) signal(SIGQUIT, terminate);
- (void) signal(SIGTERM, terminate);
- (void) signal(SIGALRM, terminate);
- alarm(time_to_run);
- while ((pid = wait(&status)) != -1 && pid != child_pid)
- /* void */ ;
- return (pid == child_pid ? status : -1);
- }
-}
-
-// vim: foldmethod=marker
View
39 udhcp-config.sh
@@ -1,39 +0,0 @@
-#!/static/sh
-
-# udhcpc script edited by Tim Riker <Tim@Rikers.org>
-
-[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
-
-RESOLV_CONF="/etc/resolv.conf"
-[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
-[ -n "$subnet" ] && NETMASK="netmask $subnet"
-
-case "$1" in
- deconfig)
- /sbin/ifconfig $interface 0.0.0.0
- ;;
-
- renew|bound)
- /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
-
- if [ -n "$router" ] ; then
- echo "deleting routers"
- while route del default gw 0.0.0.0 dev $interface ; do
- :
- done
-
- for i in $router ; do
- route add default gw $i dev $interface
- done
- fi
-
- echo -n > $RESOLV_CONF
- [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
- for i in $dns ; do
- echo adding dns $i
- echo nameserver $i >> $RESOLV_CONF
- done
- ;;
-esac
-
-exit 0

0 comments on commit 3d2c603

Please sign in to comment.
Something went wrong with that request. Please try again.