From: Michael Gebetsroither Date: Sun, 6 Nov 2005 21:41:03 +0000 (+0100) Subject: initial commit X-Git-Tag: 0.67~1 X-Git-Url: http://git.grml.org/?p=grml-terminalserver.git;a=commitdiff_plain;h=0696e9c985b9324d559845aa67642c7dcb020d54 initial commit --- 0696e9c985b9324d559845aa67642c7dcb020d54 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1af6601 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +install_ = "install" + +name = "grml-terminalserver" + +etc = ${DESTDIR}/etc/grml/terminalserver +usr = ${DESTDIR}/usr +usrbin = $(usr)/bin +usrsbin = $(usr)/sbin +usrshare = $(usr)/share/$(name) + + +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 755 linuxrc $(usrshare) + $(install_) -m 755 udhcp-config.sh $(usrshare) + $(install_) -m 755 udhcpc $(usrshare) + $(install_) -m 755 modcalc $(usrshare) + $(install_) -m 755 rdir $(usrshare) + $(install_) -m 755 cdir $(usrshare) + $(install_) -m 755 discover-nic $(usrshare) + cp -r templates $(usrshare) + + $(install_) -m 755 -d $(usrsbin) + $(install_) -m 755 grml-terminalserver $(usrsbin) + $(install_) -m 755 grml-terminalserver-config $(usrsbin) + +clean: + true diff --git a/cdir b/cdir new file mode 100755 index 0000000..44303bd --- /dev/null +++ b/cdir @@ -0,0 +1,10 @@ +#!/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 + diff --git a/config b/config new file mode 100644 index 0000000..a2c6d51 --- /dev/null +++ b/config @@ -0,0 +1,51 @@ +# attention you have to really know what you are doing +# this options are for debugging purpuose only (to test +# grml-terminalserver on plain debian sid) or to run the +# grml-terminalserver on a grml hd install. +# +# this is a shellscript fragment and will be sourced from both +# grml-terminalserver AND grml-terminalserver-config + + +# should be used if paths within the modules.dep do not refere to +# the current root (if you want to use a module dir of an other +# linux) +# if you want to use /mnt/other-linux/lib/modules then: +# MODULES_PATH_=/mnt/other-linux/lib/modules +# MODULES_PATH_ROOT_DIFF_=/mnt/other-linux +# default: +#MODULES_PATH_ROOT_DIFF_="" + +# path to the kernel modules you would want to use to create +# the initrd (basedir eg. like /lib/modules) +# default: /lib/modules +#MODULES_PATH_="" + +# `uname -r` would give it to you, or THIS config file +# default: `uname -r` +#KERNEL_VERSION_="" + +# this is the path where the grml image/cdrom is placed (mounted) +# default: /cdrom +#MOUNT_POINT_="" + +# path + name of the linux kernel you would want to boot +# default: /cdrom/boot/isolinux/linux26 +#KERNEL_IMAGE_="" + +# this is the initrd the grml-terminalserver-config edits +# if the file is not found, default will be used +# default: /cdrom/boot/isolinux/minirt26.gz +#ORIGINAL_INITRD_="" + +# path + name of the memtest image +# default: /cdrom/boot/isolinux/memtest +#MEMTEST_IMAGE_="" + +# path to pxelinux boot message +# default: /cdrom/boot/isolinux/boot.msg +#PXE_BOOT_MSG_="" + +# path to pxelinux boot logo +# default: /cdrom/boot/isolinux/logo.16 +#PXE_BOOT_LOGO_="" diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..3b77772 --- /dev/null +++ b/debian/README @@ -0,0 +1,6 @@ +The Debian Package grml-terminalserver +---------------------------- + +Comments regarding the Package + +Michael Gebetsroither , Sun, 20 Mar 2005 19:39:26 +0100 diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..76689c7 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,18 @@ +grml-terminalserver for Debian +------------------------------ + +This version of grml-terminalserver is tested and developed on debian sid (it works now ;). +Please adjust the config in /etc/grml/terminalserver/config + +Example setup on debian: +1. mount your grml cd or the iso image to /cdrom +2. mount /cdrom/GRML/GRML to /mnt/tmp +3. adjust the following variables: +MODULES_PATH_ROOT_DIFF_="/mnt/tmp" +MODULES_PATH_="/mnt/tmp/lib/modules" +4. set the kernel version to the kernel you would want to use + choose one from: ls -l /lib/modules |awk '/-grml/{print $8}' +eg. KERNEL_VERSION_="2.6.12-grml" + + + -- Michael Gebetsroither , Sun, 20 Mar 2005 19:39:26 +0100 diff --git a/debian/TODO b/debian/TODO new file mode 100644 index 0000000..409eb69 --- /dev/null +++ b/debian/TODO @@ -0,0 +1,9 @@ + * fix problem with nvidia NICs (forcedeath) + * maybe dump discover + libuclibc in favour of hwinfo + libc (space?) + * udhcp client "timeout" ( --background + in linuxrc 10s warten bis IP kommt, wenn schon ip vorhanden sofort weitermachen). + * resolv.conf should be copied from the initrd + * update linuxrc from grml + * DON'T delete /var/lib/tftpdboot on a !grml-system + * config vars to use external services (dhcp, tftp, nfs) + * make pxelinux configurable (to use another pxe-boot-manager) (MAYBE) + * ... diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..5830e4c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,174 @@ +grml-terminalserver (0.66) unstable; urgency=low + + * fixed partition defaults in option dialog from grml2hd + * few minor typo fixes in the dialogs + + -- Michael Gebetsroither Sat, 22 Oct 2005 03:07:39 +0200 + +grml-terminalserver (0.65) unstable; urgency=low + + * fixed variable definition (added local to most variables) + * fixed loopdevice handling with mount -o loop + * fixed modcalc and grml-terminalserver-config module code + * fixed fix of modcal dependencie calculating code + * fixed modules path problems + * fixed a few small bugs + * fixed a small "bug" if there is no grml-image (clean up correctly) + + -- Michael Gebetsroither Mon, 17 Oct 2005 12:54:43 +0200 + +grml-terminalserver (0.64) unstable; urgency=low + + * cleaned up boot profiles (grub/pxelinux) + * unified variables between grml-terminalserver and + grml-terminalserver-config (one single file for constants) + * cleand up tftpd start prozess + * added $DHCPD_CONFIG_FILE in grml-terminalserver + * removed hardcoded path /cdrom + * variable cleanup + * added template engine, templates are in /usr/share/.../templates/ + * fixed netmask handling + * kicked netmask in favour of ipcalc for network range calculation + * fixed typo in checks against false configuration + * fixed mount problems (permission denied) + + -- Michael Gebetsroither Sun, 14 Aug 2005 21:58:10 +0200 + +grml-terminalserver (0.63) unstable; urgency=low + + * simplified configuration handling (default vars) UPDATE YOUR CONFIG + * added gcc-3.3 to the dependencies (grub won't compile with gcc-4.0) + * added checks against false configuration + + -- Michael Gebetsroither Thu, 4 Aug 2005 22:37:04 +0200 + +grml-terminalserver (0.62) unstable; urgency=low + + * moved discover to -data package + + -- Michael Gebetsroither Thu, 4 Aug 2005 20:06:04 +0200 + +grml-terminalserver (0.61) unstable; urgency=low + + * splitted up package in grml-terminalserver and grml-terminalserver-data + + -- Michael Gebetsroither Sun, 31 Jul 2005 00:32:05 +0200 + +grml-terminalserver (0.60) unstable; urgency=low + + * fixed reboot/halt problems + + -- Michael Gebetsroither Mon, 9 May 2005 18:04:01 +0200 + +grml-terminalserver (0.59) unstable; urgency=low + + * fixed a few small manpage issues + * rewrote complete commandline argument processing + * manpage update + + -- Michael Gebetsroither Sun, 8 May 2005 22:19:44 +0200 + +grml-terminalserver (0.58) unstable; urgency=low + + * fixed a few typos + * make it release ready ;) + * added grml-terminalserver-config clean, to remove all created config files + + -- Michael Gebetsroither Sun, 8 May 2005 21:09:49 +0200 + +grml-terminalserver (0.57) unstable; urgency=low + + * added discover-nic command to the initrd + * added alias debuginit to the bootmenu + + -- Michael Gebetsroither Tue, 3 May 2005 13:18:01 +0200 + +grml-terminalserver (0.56) unstable; urgency=low + + * fixed NON-PXE booting with grub (right boot params) + * added memtest to bootoptions + * updatet linuxrc with upstream + * fixed default ramdisk size + * fixed problem with hosts.allow/hosts.deny + + -- Michael Gebetsroither Sun, 1 May 2005 19:33:43 +0200 + +grml-terminalserver (0.55) unstable; urgency=low + + * first "working" version, it boots up => it's perfect :D (linus) + + -- Michael Gebetsroither Wed, 27 Apr 2005 00:59:32 +0200 + +grml-terminalserver (0.54) unstable; urgency=low + + * new test release + + -- Michael Gebetsroither Mon, 25 Apr 2005 12:30:13 +0200 + +grml-terminalserver (0.53) unstable; urgency=low + + * fixed unnecessary file backup + * DEBUG UPDATE + * tried another initrd/linuxrc combination + * added config file, to run it on plain debian sid also + * added executables cdir/rdir into the initrd + * cdir to create a dir layout to run discover and modprobe + * rdir to put the old files in place + + -- Michael Gebetsroither Sun, 24 Apr 2005 16:14:40 +0200 + +grml-terminalserver (0.52) unstable; urgency=low + + * added libuclibc0 to the dependencies + * added discover-data to the dependencies + * integrate functions to build a "generic" netboot initrd, now it should be + a _real_ terminalserver ;) + * big changes in grml-terminalserver-config + linuxrc + + -- Michael Gebetsroither Tue, 12 Apr 2005 13:56:32 +0200 + +grml-terminalserver (0.51) unstable; urgency=low + + * added sh-lib to the dependencies + * added syslinux to the dependencies + * reworked grml-terminalserver-config get options section (not zsh + compatibel) + * made paths grml compatibel + + -- Michael Gebetsroither Sat, 9 Apr 2005 19:55:08 +0200 + +grml-terminalserver (0.5) unstable; urgency=low + + * added manpages + * fixed a bug in grml-terminalserver-config (getting the options) + + -- Michael Gebetsroither Sun, 3 Apr 2005 12:41:15 +0200 + +grml-terminalserver (0.4) unstable; urgency=low + + * fixed a few lintian warnings (changed section to net, removed /usr/bin) + + -- Michael Gebetsroither Sat, 2 Apr 2005 22:35:34 +0200 + +grml-terminalserver (0.3) unstable; urgency=low + + * fixed #246904 from nfs-kernel-server (own init skript) + * replaced a few parameters with global variables + + -- Michael Gebetsroither Sat, 2 Apr 2005 20:46:49 +0200 + +grml-terminalserver (0.2) unstable; urgency=low + + * fixed a few path's in the skript (get it working) + + -- Michael Gebetsroither Thu, 31 Mar 2005 15:24:18 +0200 + +grml-terminalserver (0.1) unstable; urgency=low + + * Initial Release. + + -- Michael Gebetsroither Sun, 20 Mar 2005 19:39:26 +0100 + +Local variables: +mode: debian-changelog +End: diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/conffiles b/debian/conffiles new file mode 100644 index 0000000..e69de29 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..4711096 --- /dev/null +++ b/debian/control @@ -0,0 +1,15 @@ +Source: grml-terminalserver +Section: net +Priority: optional +Maintainer: Michael Gebetsroither +Build-Depends: debhelper (>= 4.0.0) +Standards-Version: 3.6.2 + +Package: grml-terminalserver +Architecture: all +Depends: sh-lib (>=1.02.03), grml-terminalserver-data (>=0.62), dialog, dhcp3-server, tftpd-hpa, syslinux, libuclibc0, discover-data, gcc-3.3, ipcalc +Description: terminalserver for grml + This software should netboot grml on other computers over the + network. Also this terminalserver should work with NON-PXE + cards (compiles grub during configuration and makes a + boot-disk). diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..48768f9 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,25 @@ +This is grml-terminalserver, written and maintained by Michael Gebetsroither +on Sun, 20 Mar 2005 19:39:26 +0100. + +The original source can always be found at: + ftp://ftp.debian.org/dists/unstable/main/source/ + +Copyright (C) 2003 Michael Gebetsroither + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..236670a --- /dev/null +++ b/debian/dirs @@ -0,0 +1 @@ +usr/sbin diff --git a/debian/grml-terminalserver-config.8 b/debian/grml-terminalserver-config.8 new file mode 100644 index 0000000..d165ec4 --- /dev/null +++ b/debian/grml-terminalserver-config.8 @@ -0,0 +1,69 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" 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" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +grml-terminalserver-config \- Config program for terminalserver coming with GRML +.SH SYNOPSIS +.B grml-terminalserver-config +.RI [ options ] " +.br +.SH DESCRIPTION +This manual page documents briefly the +.B grml-terminalserver-config +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\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. +.SH OPTIONS +These programs follow the long option style without dashes and +short options starting with one dash (`-'). +A summary of options is included below. +.TP +.B +Interactive configuration of the terminalserver (same as option interactive). +.TP +.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 +.B \-h, help +Show summary of options. +.TP +.B \-v +Show what is going on (more v => more output). +.SH SEE ALSO +.BR grml-terminalserver (8) +.SH AUTHOR +grml-terminalserver-config was written by Michael Gebetsroither . +.PP +This manual page was written by Michael Gebetsroither . diff --git a/debian/grml-terminalserver.8 b/debian/grml-terminalserver.8 new file mode 100644 index 0000000..d715216 --- /dev/null +++ b/debian/grml-terminalserver.8 @@ -0,0 +1,74 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" 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 8 "March 20, 2005" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +grml-terminalserver \- Complete Terminalserver software for GRML +.SH SYNOPSIS +.B grml-terminalserver +.RI [ options ] " +.br +.SH DESCRIPTION +This manual page documents briefly the +.B grml-terminalserver +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBgrml-terminalserver\fP is a program that +provides booting grml on other computers via network. +The terminalserver should work also with NON-PXE card via compiling grub during configuration and creating an appropriate bootdisk. +.SH OPTIONS +These programs follow the long option style without dashes and +short options starting with one dash (`-'). +A summary of options is included below. +.TP +.B +For the first start (no config in /etc/grml/terminalserver), grml-terminalserver-config will be executed. +Then start the terminalserver (same as option start). +.TP +.B start +Start services +.TP +.B stop +Stop services +.B clean +Stop all + remove config and boot files from services +.TP +.B \-h, help +Show summary of options. +.TP +.B \-v +Show what is going on (more v => more output). +.SH SERVICES +.TP +.B tftp +Tftp daemon +.TP +.B dhcp +Dhcp daemon +.TP +.B nfs +All necessary nfs daemons +.TP +.B <> +ALL services +.SH SEE ALSO +.BR grml-terminalserver-config (8) +.SH AUTHOR +grml-terminalserver was written by Michael Gebetsroither . +.PP +This manual page was written by Michael Gebetsroither . diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..a670735 --- /dev/null +++ b/debian/rules @@ -0,0 +1,98 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# 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 + dh_testdir + + # Add here commands to compile the package. + # $(MAKE) + #docbook-to-man debian/grml-terminalserver.sgml > grml-terminalserver.1 + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/grml-terminalserver. + $(MAKE) install DESTDIR=$(CURDIR)/debian/grml-terminalserver + + +# 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_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman debian/grml-terminalserver.8 debian/grml-terminalserver-config.8 + dh_link +# dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_python +# dh_makeshlibs + dh_installdeb +# dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/default_config b/default_config new file mode 100644 index 0000000..2665bd0 --- /dev/null +++ b/default_config @@ -0,0 +1,24 @@ +# this are the program default vars for the user configurable variables +# !!! DO NOT EDIT THIS FILE !!! +# /etc/grml/terminalserver/config is what you are searching for + +MODULES_PATH_ROOT_DIFF_="" + +MODULES_PATH_="/lib/modules" + +KERNEL_VERSION_=`uname -r` + +MOUNT_POINT_="/cdrom" + +DATA_PATH_="$MOUNT_POINT_/boot/isolinux" + +KERNEL_IMAGE_="$DATA_PATH_/linux26" + +ORIGINAL_INITRD_="$DATA_PATH_/minirt26.gz" + +MEMTEST_IMAGE_="$DATA_PATH_/memtest" + +PXE_BOOT_MSG_="$DATA_PATH_/boot.msg" + +PXE_BOOT_LOGO_="$DATA_PATH_/logo.16" + diff --git a/discover-nic b/discover-nic new file mode 100755 index 0000000..7b93237 --- /dev/null +++ b/discover-nic @@ -0,0 +1,16 @@ +#!/static/ash + +PATH=/static + +kernel_version_=`uname -r` + +modules_to_load_=$(/static/discover --disable-bus all --enable-bus pci --type network --normalize-whitespace --data-path=linux/module/name --data-version=$kernel_version_) + +if [ $? -ne 0 ]; then + echo "Error: discover returned an error while discovering the appropriate nic module" + echo "$modules_to_load_" + return 1 +fi + +echo $modules_to_load_ | grep -v '^ $' | uniq +return 0 diff --git a/grml-terminalserver b/grml-terminalserver new file mode 100755 index 0000000..7b990d2 --- /dev/null +++ b/grml-terminalserver @@ -0,0 +1,329 @@ +#!/bin/sh +# Filename: terminalserver +# Purpose: Program to do something +# 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: Sat Aug 06 14:14:40 CEST 2005 +################################################################################ + + +### +### __INCLUDES +### +. /etc/grml/sh-lib +#. /etc/grml/sysexits-sh + + + +### +### __VARIABLES +### + +verbose_=0 + +# this file holds all variable definitions +SHARED_PROG_VARS_="/usr/share/grml-terminalserver/shared_prog_vars" +isExistent $SHARED_PROG_VARS_ die +. $SHARED_PROG_VARS_ + + +### +### __FUNCTIONS +### + +function printUsage +{ + cat < + +$PROG_NAME__ is the config program for the terminalserver +comming with grml. + +COMMANDS: + help This help text + start Start services + stop Stop services + clean Stop all + remove config and boot files from services + interactive + +SERVICES: + tftp Tftp daemon + dhcp Dhcp daemon + nfs All necessary nfs daemons + <> ALL services + +OPTIONS: + -v verbose (show what is going on, v++) + -h this help text + +EOT +} + + +# DHCP SERVICE {{{ +function createDhcpConf +{ + execute "mv -fb \"$DHCPD_CONFIG_FILE_\" \"$DHCPD_CONFIG_FILE_.old\"" eprint &>/dev/null + + execute "source $TEMPLATE_CONFIG_DIR_/dhcpd_config" die +} + +function removeDhcpConf +{ + rm -f "$DHCPD_CONFIG_FILE_" +} + + +function stopDhcp +{ + start-stop-daemon --stop --quiet --pidfile "$DHCPD_PID_" + rm -f $DHCPD_PID_ + rm -f /var/lib/dhcp3/dhcpd.leases* 2>/dev/null #FIXME + touch /var/lib/dhcp3/dhcpd.leases +} +function startDhcp +{ + local conf_file_="$DHCPD_CONFIG_FILE_" + + test -f $DHCPD_BIN_ || die "could not find dhcpd \"$DHCPD_BIN_\"" + start-stop-daemon --start --quiet --pidfile "$DHCPD_PID_" \ + --exec "$DHCPD_BIN_" -- -cf "$conf_file_" -q "$INTERFACE_" || warn "problems starting dhcpd" +} +function runDhcp +{ + isExistent "$DHCPD_CONFIG_FILE_" || \ + warn "no config for dhcpd: \"$DHCPD_CONFIG_FILE_\" => not starting dhcpd" || return 1 + + stopDhcp + sleep 1 + startDhcp +} +# }}} + +# TFTP SERVICE {{{ +function removeTftpConf +{ + rm -rf $TFTPD_DATA_DIR_/* +} +function createTftpConf +{ + removeTftpConf + + execute "mkdir $TFTPD_DATA_DIR_/pxelinux.cfg" die + execute "install -m 644 /usr/lib/syslinux/pxelinux.0 $TFTPD_DATA_DIR_" die + execute "install -m 644 $PATH_/minirt26.gz $TFTPD_DATA_DIR_" die + execute "install -m 644 $KERNEL_IMAGE_ $TFTPD_DATA_DIR_/linux26" die + execute "install -m 644 $MEMTEST_IMAGE_ $TFTPD_DATA_DIR_/memtest" die + execute "install -m 644 $PXE_BOOT_MSG_ $TFTPD_DATA_DIR_" die + execute "install -m 644 $PXE_BOOT_LOGO_ $TFTPD_DATA_DIR_" die + + execute "source $TEMPLATE_CONFIG_DIR_/grub-pxelinux_config" die +} + +function stopTftp +{ + start-stop-daemon --stop --quiet --name "${TFTPD_BIN_##*/}" +} +function startTftp +{ + test -f $TFTPD_BIN_ || die "could not find \"$TFTPD_BIN_\"" + start-stop-daemon --start --quiet --exec "$TFTPD_BIN_" -- -l -a "$IP_" -s "$TFTPD_DATA_DIR_" || \ + warn "problems starting tftpd server" +} +function runTftp +{ + stopTftp + sleep 1 + startTftp +} +# }}} + + +# NFS {{{ +function startNfs +{ + /etc/init.d/portmap start + /etc/init.d/nfs-common start + # FIXME /etc/init.d/nfs-kernel-server start + $USR_SHARE_/nfs-kernel-server start + + # FIXME Silly "/etc/init.d/nfs-kernel-server start" + # FIXME #246904 (init script does not start if no exports in /etc/exports) + execute "exportfs -o ro,no_root_squash,async,nohide $NETWORK_/$NETMASK_:$MOUNT_POINT_" warn + #execute "echo -e \"\n$MOUNT_POINT_ $NETWORK_/$NETMASK_(ro,no_root_squash,async)\" >> /etc/exports" warn +} +function stopNfs +{ + execute "exportfs -u -o ro,no_root_squash,async,nohide $NETWORK_/$NETMASK_:$MOUNT_POINT_" warn + if [[ `exportfs |wc -l` > 0 ]]; then + dprint "There are other exports, not stopping NFS serivces" + else + /etc/init.d/nfs-kernel-server stop >/dev/null 2>&1 + /etc/init.d/nfs-common stop >/dev/null 2>&1 + /etc/init.d/portmap stop >/dev/null 2>&1 + fi +} +# }}} + +function allreadyConfigured +{ + isExistent "$CONF_FILE_" dprint || return 1 + return 0 +} + +function createConfig +{ + # FIXME + execute "sed -i 's/^ALL/\#ALL/' /etc/hosts.deny" warn + execute "sed -i 's/^ALL : ALL@ALL : DENY/ALL : ALL@ALL : ALLOW/' /etc/hosts.allow" warn + + createTftpConf + createDhcpConf +} + +function actionStart +{ + createConfig + + echo -n "Starting tftpd..." + runTftp + echo "done" + echo -n "Starting dhcpd..." + runDhcp + echo "done" + echo -n "Starting nfs..." + startNfs + echo "done" +} + +function actionStop +{ + stopTftp + stopDhcp + stopNfs + notice "Terminal-server stopped" +} + +function actionClean +{ + actionStop + removeTftpConf + removeDhcpConf + stopNfs +} + +# SERVICES {{{ +function serviceStart +{ + local service_="$1" # service to start, if nothing => all + + case "$service_" in + "") actionStart ;; + tftp) runTftp ;; + dhcp) runDhcp ;; + nfs) startNfs ;; + *) warn "Service $service_ not available" ;; + esac +} + +function serviceStop +{ + local service_="$1" # service to stop, if nothing => all + + case "$service_" in + "") actionStop ;; + tftp) stopTftp ;; + dhcp) stopDhcp ;; + nfs) stopNfs ;; + *) warn "Service $service_ not available" ;; + esac +} +# }}} + +### +### __MAIN +### + +while getopts "i:hv" opt; do + case "$opt" in + h) printUsage; exit ;; + v) let verbose_=$verbose_+1 ;; + ?) printUsage; exit 64 ;; + esac +done +shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter +setVerbose $verbose_ + +case "$1" in + help) printUsage; exit 0 ;; +esac + +checkRoot die "You have to be root to use this program" +disableSyslog + +isExistent $DEFAULT_CONFIG_ die +. $DEFAULT_CONFIG_ +. $CONFIG_ +# used config vars: +# MOUNT_POINT_ +# KERNEL_IMAGE_ +# MEMTEST_IMAGE_ +# PXE_BOOT_MSG_ +# PXE_BOOT_LOGO_ +if [[ $MOUNT_POINT_ == "" || $KERNEL_IMAGE_ == "" || $MEMTEST_IMAGE_ == "" || \ + $PXE_BOOT_MSG_ == "" || $PXE_BOOT_MSG_ == "" ]]; then + warn "MOUNT_POINT_=\"$MOUNT_POINT_\" \ +KERNEL_IMAGE_=\"$KERNEL_IMAGE_\" \ +MEMTEST_IMAGE_=\"$MEMTEST_IMAGE_\" +PXE_BOOT_MSG_=\"$PXE_BOOT_MSG_\" +PXE_BOOT_LOGO_=\"$PXE_BOOT_LOGO_\"" + die "False configuration, please update $CONFIG_" +fi + +case "$1" in + clean) actionClean; exit 0 ;; +esac + + +while true; do + isExistent "$CONF_FILE_" warn "sorry configfile \"$CONF_FILE_\" not found" + if [ $? -eq 1 ]; then + $CONFIG_PROG_ && continue + $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "Question" --yesno \ + "grml-terminalserver-config returned an error, do you want to quit now?" 5 75 && exit 1 + else + break + fi +done +source $CONF_FILE_ + +# check for necessary files +check_necessary_files_='no' +if [ "$1" == 'start' ]; then + case "$2" in + tftp|"") check_necessary_files_='yes' ;; + esac +fi +if [ $check_necessary_files_ == 'yes' ]; then + # test for files absolutly necessary for grml-terminalserver and created from -config + problem_=0 + for i in $PATH_/minirt26.gz; do + isExistent $i warn || problem_=1 + done + if [ $problem_ -eq 1 ]; then + die 'Some necessary files are missing, please rerun grml-terminalserver-config, or copy the files manually' + fi +fi + + +case "$1" in + start) serviceStart "$2" ;; + stop) serviceStop "$2" ;; + "") actionStart ;; + *) printUsage ;; +esac + +# END OF FILE +################################################################################ +# vim:foldmethod=marker diff --git a/grml-terminalserver-config b/grml-terminalserver-config new file mode 100755 index 0000000..9369465 --- /dev/null +++ b/grml-terminalserver-config @@ -0,0 +1,614 @@ +#!/bin/sh +# Filename: terminalserver-config +# Purpose: Program to do something +# 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: Sun May 08 22:21:32 CEST 2005 [gebi] +################################################################################ + + +### +### __INCLUDES +### +. /etc/grml/sh-lib +#. /etc/grml/sysexits-sh + + + +### +### __VARIABLES +### + +verbose_=0 + +# this file holds all variable definitions +SHARED_PROG_VARS_="/usr/share/grml-terminalserver/shared_prog_vars" +isExistent $SHARED_PROG_VARS_ die +. $SHARED_PROG_VARS_ + +# variables used in the config file for grml-terminalserver +INTERFACE_="" +IP_="" +NETMASK_="" +GW_="" +NAMESERVERS_="" +IPRANGE_FROM_="" +IPRANGE_TO_="" +NETWORK_="" +OPTIONS_="" +BOOT_ARGS_="" + + +### +### __FUNCTIONS +### + +function printUsage +{ + cat < + +$PROG_NAME__ is the config program for the terminalserver +comming with grml. + +COMMANDS: + help This text + interactive Interactive Configuration of the grml-terminalserver + grubConf Configure grub and make boot-image (for non-PXE NICs) + 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 + interactive + +OPTIONS: + -v verbose (show what is going on, v++) + -h this help text + +EOT +} + + +function writeConfig +{ + local date_="" + + if [ -f $CONF_FILE_ ]; then + mv -fb $CONF_FILE_ ${CONF_FILE_}-old + fi + + date_=`date` + cat < $CONF_FILE_ +# GRML TERMINAL-SERVER CONFIG +# created on "$date_" +INTERFACE_="$INTERFACE_" +IP_="$IP_" +NETMASK_="$NETMASK_" +GW_="$GW_" +NAMESERVERS_="$NAMESERVERS_" +IPRANGE_FROM_="$IPRANGE_FROM_" +IPRANGE_TO_="$IPRANGE_TO_" +NETWORK_="$NETWORK_" +OPTIONS_="$OPTIONS_" +BOOT_ARGS_="$BOOT_ARGS_" + +EOT + notice "config successfully safed to \"$CONF_FILE_\"" +} + + +# AUTOMATIC CONFIGURATION {{{ +function checkParamArg +{ + local param_name="$1" + local arg="$2" + + #eval "echo $`echo $test`" + echo $arg |grep "^[-|+]" &>/dev/null || return + + die "Argument from $param_name looks like another parameter \"$arg\"" 1 +} + +function actionAutoconf +{ + checkParamArg "-i" "$interface_" +} +# }}} + + +# INITRD {{{ + +function actionMkInitrd +{ + echo "Creating initrd: $PATH_/minirt26.gz" + isExistent "$PATH_/minirt26.gz" && echo "$PATH_/minirt26.gz does allready exist, skipping initrd creation" && return 0 + mkInitrd + echo 'done' +} + +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 allready links with this name to busybox + for i in $USR_SHARE_/discover* $USR_SHARE_/udhcpc $USR_SHARE_/udhcp-config.sh $USR_SHARE_/cdir $USR_SHARE_/rdir /usr/bin/ldd ;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/i386-uclibc-linux/lib + for i in libdl libc libuClibc ld-uClibc; do + cp -a $UCLIBC_PATH_/$i*.so* $INITRD_/myusr/i386-uclibc-linux/lib + done + + # copy data files for discover (discover-data) + mkdir -p $INITRD_/mylib/discover + cp /lib/discover/list.xml /lib/discover/pci-*.xml $INITRD_/mylib/discover/ + + + # + # which modules should i put into the ramdisk + # + + # get cards detected by discover + isNotExistent $CARDS_DETECTED_BY_DISCOVER && awk '/ethernet/{print $3}' /lib/discover/pci.lst |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 dependet 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 + + # generate modules.dep + cp $MODULES_PATH_/$KERNEL_VERSION_/modules.dep $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 + if (( $tmp_size >= 16000 )); then + warn "Your initrd is $tmp_size kByte large => TOO BIG (should be 16000kByte)" + 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_" +} +# }}} + + +# INTERACTIVE CONFIGURATION {{{ + +function actionInteractive +{ + local i="" + + dprint "running in interactive mode" + + local card_title_="Choose network device connected to client network" + local card_message_="Available network devices:" + local iprange_title_="IP Address range for clients" +local iprange_message_=" +Please enter the desired IP-Range of addresses that should be allocated by clients, separated by a single space. + +Example: + 192.168.0.101 192.168.0.200 + +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_="$(cat /proc/net/dev | awk -F: '/eth.:|tr.:/{print $1}')" + local device_list_="" + for INTERFACE_ in $netdevices_; do device_list_="$device_list_ ${INTERFACE_} Networkcard_${INTERFACE_##eth}"; done + echo -n "" >"$TMP_" + $DIALOG_ --backtitle "$BACK_TITLE_" --title "$card_title_" --menu "$card_message_" \ + 0 0 18 $device_list_ 2>"$TMP_" || warn "could not get network-interface" + INTERFACE_="$(<$TMP_)" ; echo -n "" >"$TMP_" + + while true; do + IP_=`netGetIp "$INTERFACE_" warn` + NETMASK_=`netGetNetmask "$INTERFACE_" warn` + netValidIp "$IP_" warn && break + $DIALOG_ --backtitle "$BACK_TITLE_" --title "$runconfig_title_" --yesno "$runconfig_message_" 18 45 && \ + netcardconfig || die "Could not get interface" $? + done + + IPRANGE_FROM_=`execute "ipcalc -n $IP_/$NETMASK_" warn |awk '/HostMin/{print $2}'` + IPRANGE_TO_=`execute "ipcalc -n $IP_/$NETMASK_" warn |awk '/HostMax/{print $2}'` + NETWORK_=$IPRANGE_FROM_ + local iprange_="" + while [ -z "$IPRANGE_FROM_" -o -z "$IPRANGE_TO_" -o -z "$iprange_" ]; do + iprange_="$IPRANGE_FROM_ $IPRANGE_TO_" + echo -n "" >"$TMP_" + $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$iprange_title_ ($INTERFACE_=$IP_/$NETMASK_)" \ + --inputbox "$iprange_message_" 18 75 "$iprange_" 2>"$TMP_" || die "problems getting network range" $? + + iprange_="$(<$TMP_)" + IPRANGE_FROM_="${iprange_%% *}" + IPRANGE_TO_="${iprange_##* }" + + for i in "$IPRANGE_FROM_" "$IPRANGE_TO_"; do + netValidIp "$i" warn || iprange_="" + done + done + + NAMESERVERS_=`netGetNameservers warn` + GW_=`netGetDefaultGateway warn` + + + # grub + echo -n "" >"$TMP_" + local grub_write_="YES" + $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$grub_title_" --yesno "$grub_message_" 5 75 && \ + grubConfig || grub_write_="NO" + + + # get options + #local OPT_IPTABLES_="yes" + #local OPT_SSH_="yes" + #local OPT_DISTCC_="yes" + #local OPT_SQUID_="" + + local OPTIONS_TITLE_="Options" + local OPTIONS_MESSAGE_="Please give the appropriate options you want the clients to use: + +grml2hd - Make a non-interactive remote installation + + + +" +# local OPTIONS_MESSAGE_="Please give the appropriate options you want the clients to use: +# +#iptables - Only the server should be able to access the clients +#ssh - A ssh-key will be created on the server and distributed to the clients +#distcc - You want to use the clients as compile-farm (ssh options recommned) +# +#" + + local OPT_IPTABLES_DESC_="Start iptables on the clients" + local OPT_SSH_DESC_="Start ssh on the clients" + local OPT_DISTCC_DESC_="Start distcc on the clients" + local OPT_GRML2HD_DESC_="Remote install grml on the network clients" + # dialog options (enable if implemented) + #iptables "$OPT_IPTABLES_DESC_" off \ + #ssh "$OPT_SSH_DESC_" off \ + #distcc "$OPT_DISTCC_DESC_" off \ + echo -n "" >"$TMP_" + $DIALOG_ --clear --separate-output --backtitle "$BACK_TITLE_" --title "$OPTIONS_TITLE_" --checklist "$OPTIONS_MESSAGE_" 25 80 10 \ + grml2hd "$OPT_GRML2HD_DESC_" off \ + 2>$TMP_ || die "could not get terminalserver options" $? + while read tmp_option_; do + OPTIONS_="$OPTIONS_ $tmp_option_" + done <$TMP_ + + # parse options + for i in $OPTIONS_; do + case "$i" in + grml2hd) optGrml2Hd || return 1 ;; + esac + done + + echo -n "" >"$TMP_" + local OPTIONS_BOOTARG_MESSAGE_="Here you can add additional boot arguments for the clients seperated by spaces: + +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 + + +" + $DIALOG_ --clear --no-collapse --backtitle "$BACK_TITLE_" --title "$OPTIONS_TITLE_" --inputbox "$OPTIONS_BOOTARG_MESSAGE_" 0 0\ + 2>$TMP_ || die "problems getting additional boot arguments" + BOOT_ARGS_="$BOOT_ARGS_ $(<$TMP_)" + + writeConfig + if [ $grub_write_ == "YES" ]; then + grubWrite + fi + actionMkInitrd + notice "GRML terminalserver successfully configured" +} +# }}} + +# OPTIONS GETTING DIALOG {{{ +function optGrml2Hd +{ + local GRML2HD_TITLE_='Grml2hd options dialog' + local tmp_='' + local options_='BOOT_IMAGE=grml2hd' + + # get partition to install grml2hd on + OPTIONS_PARTITION_MSG_='Please give me the target partition where to install grml' + PARTITION_TITLE_='Partition selection' + echo -n "" >"$TMP_" + $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$PARTITION_TITLE_" --inputbox \ + "$OPTIONS_PARTITION_MSG_" 0 75 '/dev/hda1' 2>$TMP_ || die "problems getting partition" + tmp_="partition=$(<$TMP_)" + options_="$options_ $tmp_" + + # get filesystem type + OPTION_FS_TYPE_='Please give me the filesystem type' + FS_TITLE_='Filesystem selection' + echo -n "" >"$TMP_" + $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$FS_TITLE_" --inputbox \ + "$OPTION_FS_TYPE_" 0 75 'ext3' 2>$TMP_ || die "problems getting filesystem type" + tmp_="filesystem=$(<$TMP_)" + options_="$options_ $tmp_" + + # get where to save mbr + OPTION_MBR_='Please give me the location where to save the mbr' + MBR_TITLE_='Select location of mbr' + echo -n "" >"$TMP_" + $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$MBR_TITLE_" --inputbox \ + "$OPTION_MBR_" 0 75 '/dev/hda' 2>$TMP_ || die "problems getting location where to write mbr" + tmp_="mbr=$(<$TMP_)" + options_="$options_ $tmp_" + + # get first user + OPTION_USER_='Who should be the first user on the system' + USER_TITLE_='User selection' + echo -n "" >"$TMP_" + $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$USER_TITLE_" --inputbox \ + "$OPTION_USER_" 0 75 'grml' 2>$TMP_ || die "problems getting first user of system" + tmp_="user=$(<$TMP_)" + options_="$options_ $tmp_" + + BOOT_ARGS_="$options_" +} +#}}} + +# 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_ + local ret_=$? + execute "rm -rf $tmp_" warn + + return $ret_ +} + +function grubConfigWork +{ + local tmp_="$1" + + 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 allready listed press ! + +WARNING: DON't add all NIC's, 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_ + 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 + execute "cd $tmp_/grub*" warn || return 1 +cat >preset-menu < $PATH_/grub.img" warn || return 1 + return 0 +} + +function grubWrite +{ + local grub_title_="Grub configuration" + $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$grub_title_" --yesno \ + "Do you want to write your 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 must give me 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 (STRG-C for end)" + read + dd if=$PATH_/grub.img of="$target_" + done +} +# }}} + + +function removeTmpFiles +{ + execute "rm -f $TMP_" warn +} + +function actionClean +{ + for i in dhcpd.conf grub.img minirt26.gz; do + execute "rm -f $PATH_/$i*" + done + + for i in $CARDS_DETECTED_BY_DISCOVER $CONF_FILE_; do + execute "rm -f $i" + done + +} + + +### +### __MAIN +### + +while getopts "i:hv" opt; do + case "$opt" in + i) interface_=$OPTARG ;; + h) printUsage; exit ;; + v) let verbose_=$verbose_+1 ;; + ?) printUsage; exit 64 ;; + esac +done +shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter +setVerbose $verbose_ + +case "$1" in + help) printUsage; exit 0 ;; +esac + +checkRoot die 'You have to be root to use this program' +disableSyslog + +execute "mkdir -p $PATH_" die + +TMP_=`mktemp -t grml-terminalserver-config.XXXXXX` || die "Could not create tmpfile" $? +setExitFunction 'removeTmpFiles' + + +. $DEFAULT_CONFIG_ +. $CONFIG_ +# used config vars: +# MODULES_PATH_ +# MODULES_PATH_ROOT_DIFF_ +# KERNEL_VERSION_ +# ORIGINAL_INITRD_ +if [[ $MODULES_PATH_ == "" || $KERNEL_VERSION_ == "" || $ORIGINAL_INITRD_ == "" ]]; then + warn "MODULES_PATH_=\"$MODULES_PATH_\" \ +KERNEL_VERSION_=\"$KERNEL_VERSION_\" \ +ORIGINAL_INITRD_=\"$ORIGINAL_INITRD_\"" + die "False configuration, please update $CONFIG_" +fi + + +case "$1" in + interactive) actionInteractive ;; + grubConf) grubConfig ;; + grubConfWrite) grubConfig && grubWrite ;; + grubWrite) grubWrite ;; + grubMultiWrite) grubMultiWrite "$2" ;; + initrd) actionMkInitrd ;; + clean) actionClean ;; + *) actionInteractive ;; +esac + +removeTmpFiles +# END OF FILE +################################################################################ +# vim:foldmethod=marker diff --git a/grub_cards b/grub_cards new file mode 100644 index 0000000..fa69788 --- /dev/null +++ b/grub_cards @@ -0,0 +1,32 @@ +3c503 3Com_Etherlink2 on +3c503-shmem 3Com_Etherlink2 off +3c503-aui 3Com_Etherlink2_AUI off +3c507 3Com off +3c509 3Com on +3c529 3Com off +3c595 3Com off +3c90x 3Com on +cs89x0 Crystal_Semiconductor off +davicom DM9102/DM9009 off +depca DE100/DE200 off +eepro Intel_Ethernetexpress_Pro/10 off +eepro100 Intel_Ethernetexpress_Pro/100 on +epic100 SMC_83c170 on +exos205 EXOS205 off +ni5210 Racal-Interlan off +lance Lance_PCNet/AMD_HomePNA off +ne2100 Novell_NE2100/NE1500 off +ni6510 Racal-Interlan off +ni5010 Racal-Interlan off +ne NE1000/2000_ISA off +ns8390 NE2000_PCI_RTL8029 on +wd WD8003/8013_SMC8216/8416 off +otulip Old_tulip_clones off +rtl8139 Realtek8139/SMC1211/D-Link_DFE530TX/DFE538TX on +sis900 SIS900/SIS7016 on +sk-g16 Schneider_koch_G16 off +smc9000 SMC9000 off +tiara Tiara/Fujitsu_Lancard off +tulip Tulip/Tulip-clonse/Linksys/Intel_tulip/Compex on +via-rhine Rhine-1/Rhine-2/Dlink_DFE-530TX on +w89c840 Winbond_W89c840/Compex_RL100-ATX off diff --git a/linuxrc b/linuxrc new file mode 100755 index 0000000..ada7d6f --- /dev/null +++ b/linuxrc @@ -0,0 +1,921 @@ +#!/static/sh +# Filename: /linuxrc +# Purpose: minirt for kernel 2.6 +# Authors: (c) Klaus Knopper , (c) Michael Prokop +# Latest change: Die Apr 19 11:44:14 CEST 2005 [mika] +####################################################################################### + +# 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="insmod" +[ -x /modules/insmod ] && INSMOD="/modules/insmod" + +RMMOD="rmmod" +[ -x /modules/rmmod ] && RMMOD="/modules/rmmod" + +# Builin filesystems +#BUILTIN_FS="iso9660 ext2 ext3 reiserfs vfat reiser4" +BUILTIN_FS="iso9660 ext2 vfat" + +mountit(){ +# Usage: mountit src dst "options" +# Uses builtin mount of ash.grml + for fs in $BUILTIN_FS; do + test -b $1 && mount -t $fs $3 $1 $2 >/dev/null 2>&1 && return 0 + done + return 1 +} + +FOUND_SCSI="" +FOUND_GRML="" +INTERACTIVE="" + +# Clean input/output +exec >/dev/console &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 + +# 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} $@" +} + +# 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 "" +# Be verbose +#echo "${WHITE}Welcome to ${CYAN}G${YELLOW}R${WHITE}M${RED}L${WHITE}!${NORMAL}" +#echo "" +#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 only need the builtin commands and /static at this point +PATH=/static +export PATH + +umask 022 + +# Check if we are in interactive startup mode +case "$CMDLINE" in *BOOT_IMAGE=expert\ *) INTERACTIVE="yes"; :>/interactive; ;; esac +case "$CMDLINE" in *modules-disk*) INTERACTIVE="yes"; ;; esac +#case "$CMDLINE" in *BOOT_IMAGE=debug\ *|*\ debug\ *) DEBUG="yes"; ;; esac +case "$CMDLINE" in *debug*) DEBUG="yes"; ;; esac +# Does the user want to skip scsi detection? +NOSCSI="" +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=""; ;; 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 + +# WARNING: In Kernel 2.4.27, CD-Roms cease to work if both, ide-scsi and ide-cd, are loaded. :-( +#if test -n "$IDECD"; then +# Use ide-cd for ATAPI-only CD-Rom(s) +#$INSMOD /modules/scsi/ide-cd.ko >/dev/null 2>&1 +#$INSMOD /modules/scsi/ide-cd.ko +#else +# Check for IDE-SCSI capable CD-Rom(s) first +#$INSMOD /modules/scsi/ide-scsi.ko >/dev/null 2>&1 +#$INSMOD /modules/scsi/ide-scsi.ko +#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 + echo "${CRE}${BLUE}Starting intermediate shell stage $stage as requested by \"debug\" option.${NORMAL}" + echo "${CRE}${BLUE}Just exit the shell to continue boot process...${NORMAL}" + [ -x /static/sh ] && /static/sh || /bin/bash +fi +} + +# 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 +for i in "$@"; do +echo -n "${CRE}Probing ${TYPE}... ${WHITE}$i${NORMAL}" +if test -f /modules/scsi/$i && $INSMOD -f /modules/scsi/$i >/dev/null 2>&1 +then +# case "$i" in *ataraid*) ;; *) echo "${CRE} ${GREEN}Found ${TYPE} device(s) handled by ${MAGENTA}$i${GREEN}.${NORMAL}" ;; esac +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 +PROCPCI="`cat /proc/pci 2>/dev/null`" +#ISA_SCSI="aha1740.ko aha1542.ko aha152x.ko pas16.ko psi240i.ko qlogicfas.ko qlogicfc.ko seagate.ko t128.ko u14-34f.ko wd7000.ko" +ISA_SCSI="aha1740.o aha1542.o aha152x.o pas16.o psi240i.o qlogicfas.o qlogicfc.o seagate.o t128.o u14-34f.o wd7000.o" +SCSI_PROBE="$ISA_SCSI" +case "$PROCPCI" in *[Aa][Ii][Cc]-*|*[Aa][Hh][Aa]-*) SCSI_PROBE="$SCSI_PROBE aic7xxx.o" ;; esac +case "$PROCPCI" in *[Bb][Uu][Ss][Ll][Oo][Gg][Ii][Cc]*) SCSI_PROBE="$SCSI_PROBE BusLogic.ko" ;; esac +case "$PROCPCI" in *53[Cc]8*) SCSI_PROBE="$SCSI_PROBE ncr53c8xx.o" ;; esac +#case "$PROCPCI" in *53[Cc]9*) SCSI_PROBE="$SCSI_PROBE NCR53C9x.ko" ;; esac +case "$PROCPCI" in *53[Cc]406*) SCSI_PROBE="$SCSI_PROBE NCR53c406a.ko" ;; esac +case "$PROCPCI" in *[Ii][Nn][Ii][Tt][Ii][Oo]\ *|*[Ii][Nn][Ii]-[Aa]100[Uu]2[Ww]*) SCSI_PROBE="$SCSI_PROBE initio.ko" ;; esac +case "$PROCPCI" in *[Mm][Pp][Tt]*[Ss][Cc][Ss][Ii]*) SCSI_PROBE="$SCSI_PROBE mptscsih.ko" ;; esac +case "$PROCPCI" in *[Aa][Dd][Vv][Aa][Nn][Cc][Ee][Dd]\ [Ss][Yy][Ss]*) SCSI_PROBE="$SCSI_PROBE advansys.ko" ;; esac +case "$PROCPCI" in *[Aa][Tt][Pp]8|*[Aa][Ee][Cc]6*) SCSI_PROBE="$SCSI_PROBE atp870u.ko" ;; esac +case "$PROCPCI" in *[Dd][Tt][Cc]*) SCSI_PROBE="$SCSI_PROBE dtc.ko" ;; esac +case "$PROCPCI" in *[Ee][Aa][Tt][Aa]*) SCSI_PROBE="$SCSI_PROBE eata.ko" ;; esac +case "$PROCPCI" in *[Ff]*[Dd][Oo][Mm][Aa][Ii][Nn]*) SCSI_PROBE="$SCSI_PROBE fdomain.ko" ;; esac +case "$PROCPCI" in *[Gg][Dd][Tt]\ *) SCSI_PROBE="$SCSI_PROBE gdth.ko" ;; esac +case "$PROCPCI" in *[Mm][Ee][Gg][Aa][Rr][Aa][Ii][Dd]*) SCSI_PROBE="$SCSI_PROBE megaraid.ko" ;; esac +#case "$PROCPCI" in *[Pp][Cc][Ii]-22*) SCSI_PROBE="$SCSI_PROBE pci2220i.ko" ;; esac +#case "$PROCPCI" in *[Pp][Cc][Ii]-2000*) SCSI_PROBE="$SCSI_PROBE pci2000.ko" ;; esac +case "$PROCPCI" in *[Qq][Ll][Oo][Gg][Ii][Cc]*) SCSI_PROBE="$SCSI_PROBE qlogicisp.ko" ;; esac +case "$PROCPCI" in *53[Cc]974*) SCSI_PROBE="$SCSI_PROBE tmscsim.ko" ;; esac +case "$PROCPCI" in *[Uu][Ll][Tt][Rr][Aa][Ss][Tt][Oo][Rr]*) SCSI_PROBE="$SCSI_PROBE ultrastor.ko" ;; esac +case "$PROCPCI" in *3[Ww][Aa][Rr][Ee]*) SCSI_PROBE="$SCSI_PROBE 3w-xxxx.ko" ;; esac +# modules/scsi/3w-9xxx.ko +# modules/scsi/a100u2w.ko +# modules/scsi/aic7xxx_old_CAUTION.ko + +if test -n "$INTERACTIVE"; then +# Let the user select interactively +askmodules SCSI $(cd /modules/scsi; echo *.ko) +else +# these are the autoprobe-safe modules +MODULES="$SCSI_PROBE" +fi + +test -z "$NOSCSI" && test -n "$MODULES" && loadmodules SCSI $MODULES +# End of SCSI check + +## test -z "$NOSCSI" && \ +if checkbootparam scsi ; then + MODULE="$(getbootparam 'scsi' 2>/dev/null)" + if test "$MODULE" = "probe" ; then + echo "Bootoption scsi=probe found. Trying to autoprobe SCSI modules:" && \ + loadmodules SCSI $MODULES + else + [ -n "$MODULE" ] || echo "${RED}Neither a specific module nor option probe for SCSI module given. Skipping.${NORMAL}" + [ -n "$MODULE" ] && echo "Trying to load module ${WHITE}${MODULE}${NORMAL}." && \ + /modules/insmod "/modules/scsi/${MODULE}.ko" + fi +fi +# +#if checkbootparam module ; then +# MODULE="$(getbootparam 'module' 2>/dev/null)" +# # ehci-hcd ieee1394 ohci1394 ohci-hcd sbp2 uhci-hcd usbcore usb-storage +# [ -n "$MODULE" ] && echo "${BLUE}Trying to load module ${MAGENTA}${MODULE}${BLUE}.${NORMAL}" && \ +# /modules/insmod "/modules/div/${MODULE}.ko" +#fi + +#test -z "$NOSCSI" && \ +#/static/discover --disable-bus all --enable-bus scsi --type bridge --normalize-whitespace --data-path=linux/module/name --data-version=`uname -r` | grep -v '^ $' | uniq +#echo "pci:" +#/static/discover --disable-bus all --enable-bus pci --type bridge --normalize-whitespace --data-path=linux/module/name --data-version=`uname -r` | grep -v '^ $' | uniq +#echo "End of Debugging SCSI" +# +#echo "Commands are:" +#echo " +#/static/discover --disable-bus all --enable-bus scsi --type bridge --normalize-whitespace --data-path=linux/module/name --data-version=\`uname -r\` | grep -v '^ $' | uniq +#/static/discover --disable-bus all --enable-bus pci --type bridge --normalize-whitespace --data-path=linux/module/name --data-version=\`uname -r\` | grep -v '^ $' | uniq +#" +#echo "Starting ash:" +#/static/ash +#echo "End of starting ash" + +# Check for IDE-Raid devices +if test -z "$NOIDERAID"; then +( cd /modules/scsi; { $INSMOD ataraid.ko >/dev/null 2>&1 && $INSMOD silraid.ko >/dev/null 2>&1 ; } || $INSMOD medley.ko >/dev/null 2>&1 || $INSMOD pdcraid.ko >/dev/null 2>&1 ) +fi +# End of IDE-Raid check + +# Check for USB, use modules on bootfloppy first +if test -z "$NOUSB"; then +echo -n "${CRE}Checking for for USB..." +if test -f /modules/div/usbcore.ko; then +$INSMOD /modules/div/usbcore.ko >/dev/null 2>&1 +FOUNDUSB="" + +for i in $USB2 usb-uhci.ko usb-ohci.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 +else +# For an unknown reason, unloading usbcore hangs smetimes +# rmmod usbcore >/dev/null 2>&1 +true +fi +fi +echo -n "${CRE}" +fi +# End of USB check + +# Check for Firewire, use modules on bootfloppy first +if test -z "$NOFIREWIRE"; then +echo -n "${CRE}Checking for Firewire..." +if test -f /modules/div/ieee1394.ko; then +echo -n "${CRE}Loading ieee1394..." +$INSMOD /modules/div/ieee1394.ko >/dev/null 2>&1 +FOUNDFIREWIRE="" +for i in ohci1394.ko; do +echo -n "${CRE}Loading $i..." +test -f /modules/div/$i && $INSMOD /modules/div/$i >/dev/null 2>&1 && FOUNDFIREWIRE="yes" +done +if test -n "$FOUNDFIREWIRE"; then +echo -n "${CRE}Loading sbp2.ko..." +test -f /modules/scsi/sbp2.ko && $INSMOD /modules/scsi/sbp2.ko sbp2_serialize_io=1 >/dev/null 2>&1 +else +# For an unknown reason, unloading ieee1394 hangs smetimes +# echo -n "${CRE}${BLUE}Unloading ieee1394...${NORMAL}" +# rmmod ieee1394 >/dev/null 2>&1 +true +fi +fi +echo -n "${CRE}" +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." +if test -n "$FOUNDFIREWIRE"; then +# Wait for driver to register +sleep 2 +# Kernel 2.6 does this automatically +#case "$(cat /proc/version 2>/dev/null)" in *version\ 2.6.*) ;; *) for host in 0 1 2 3 4 5 6 7; do for channel in 0 1; do for id in 0 1 2 3 4 5 6 7; do echo "scsi add-single-device $host $channel $id 0" >/proc/scsi/scsi 2>/dev/null; done; done; done ;; esac +fi +# sleep 6 +echo " $SUCCESS" +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 +echo "before NFS" +for i in $cmdline; do case "$i" in nfsdir=*|NFSDIR=*) eval $i;; esac; done +[ -n "$nfsdir" ] && NFS="$nfsdir" +echo "nfsdir=$NFS" +# NFS +if [ -n "$NFS" ]; then + tmp_="$(getbootparam nfsdir)" + echo -n "checkbootparam nfsdir " + checkbootparam "nfsdir" && echo "OK" || echo "FAILED" + echo "getbootparam nfsdir=\"$tmp_\"" + + # put the mylibs into /lib for discover and udhcpc + cdir + + # starting hw-detection for network card + echo "Starting hw-detection" + kernel_version_=`uname -r` + modules_to_load=$(/static/discover --disable-bus all --enable-bus pci --type network --normalize-whitespace --data-path=linux/module/name --data-version=$kernel_version_ | grep -v '^ $' | uniq) + echo "trying to load the following network modules: \"$modules_to_load\"" + + # FIXME modprobe is buggy from busybox + modules_to_load=`echo $modules_to_load | xargs` + modLoad() + { + for mod in $@ ; do + tmp_="`modprobe -vn $mod`" + if [ $? -ne 0 ]; then + continue + fi + eval "$tmp_" + done + } + modLoad "$modules_to_load" + + # loading additional modules + modLoad sunrpc lockd af_packet nfs + + /static/udhcpc --foreground --quit --script=/static/udhcp-config.sh + #echo "press to start a system shell and configure your system" + #sh + + # recreate the old dir structures + rdir + #rm -rf /myusr /mylib + + log_begin_msg "${RED}Debug: NFS = ${NFS}${NORMAL}" + log_begin_msg -n "${CRE}${BLUE}Looking for GRML in: ${MAGENTA}$NFS${NORMAL} " + 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 -n "${CRE} ${GREEN}Accessing grml CDROM at ${MAGENTA}$NFS${GREEN}...${NORMAL}" + FOUND_GRML="$NFS" + break + fi + fi +fi +echo "after NFS" + + +# 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 + test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]" + 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 + # DEBUG + # echo "6" > /proc/sys/kernel/printk + # cloop: + #$INSMOD -f /modules/cloop.ko file=$1/$GRML_DIR/$GRML_NAME + #mountit /dev/cloop /GRML "-o ro" || FOUND_GRML="" + # squashfs: + #losetup /dev/loop0 $1/$GRML_DIR/$GRML_NAME + mount -t squashfs $1/$GRML_DIR/$GRML_NAME /GRML -o loop,ro || FOUND_GRML="" + fi + +# COMP="" +# case $(dd if=$1/$KNOPPIX_DIR/$KNOPPIX_NAME bs=4 count=1 2>/dev/null) in +# "#!/b") COMP=cloop +# $INSMOD /modules/cloop.o file=$1/$KNOPPIX_DIR/$KNOPPIX_NAME +# mountit /dev/cloop /KNOPPIX "-o ro" || FOUND_KNOPPIX="" +# ;; +# "hsqs") COMP=squashfs +# mount -t squashfs $1/$KNOPPIX_DIR/$KNOPPIX_NAME /KNOPPIX -o loop,ro || FOUND_KNOPPIX="" +# #losetup /dev/loop0 $1/$KNOPPIX_DIR/$KNOPPIX_NAME +# #mount -t squashfs /dev/loop0 /KNOPPIX -o loop,ro || FOUND_KNOPPIX="" +# ;; +# esac +} + +remount_grml() +{ + if test -f $TARGET/$GRML_DIR/$GRML_NAME; then + umount /GRML # unmount it + # echo "$RMMOD cloop" | /static/sh # release CD - ash crashes with parts of libc in memory -- FF + umount $SOURCE # unmount CD + [ -n "$SOURCE2" ] && umount $SOURCE2 # umount possible loop-device + mount_grml $TARGET + else + echo "${CRE} ${RED}Warning: Changing to $TARGET failed.${NORMAL}" + 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 reiserfs + /GRML/sbin/modprobe reiser4 + /GRML/sbin/modprobe ntfs # BE CAREFUL! - Only mount it read only! - FF + + if [ -n "$ISO_PATH" ] + then + LOOP_SOURCE="$TARGET.loop" + LOOP_SOURCE2="$LOOP_SOURCE" + TARGET_DEV="$LOOP_SOURCE$ISO_PATH" + /bin/mkdir $LOOP_SOURCE + /GRML/sbin/modprobe loop + + /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 + echo -n "${CRE} ${RED}Accessing grml CD-ROM failed. ${MAGENTA}$TARGET_DEV${RED} is not mountable.${NORMAL}" + 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 + echo -n "${CRE} ${RED}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 reiserfs + # /GRML/sbin/modprobe jbd + # /GRML/sbin/modprobe ext3 + /GRML/sbin/modprobe reiser4 + BUILTIN_FS="iso9660 ext3 ext2 reiserfs reiser4 vfat" + # we need to use mountit to prevent NTFS to be mounted! + if mountit $TARGET_DEV $TARGET "-o rw" + then + : + else + echo -n "${CRE} ${RED}Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${RED} is not mountable.${NORMAL}" + 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 + echo -n "${CRE} ${RED}Copying grml CD-ROM failed. Not enough free space on ${MAGENTA}${TARGET_DEV_DESC}${RED}. Found: ${MAGENTA}${FOUNDSPACE}k${RED} Need: ${MAGENTA}${SIZE}k${RED} ${NORMAL}" + sleep 2 + umount $TARGET + return 1 + fi + + # do the real copy + + echo "${CRE} ${GREEN}Copying grml CD-ROM to ${MAGENTA}$TARGET_DEV_DESC${GREEN}... Please be patient. ${NORMAL}" + 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 + else + /bin/cp -a -f $COPY $TARGET # Copy grml to $TARGET + fi + if [ $? -ne 0 ] + then + echo -n "${CRE} ${RED}Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${RED} possibly has not enough space left.${NORMAL}" + sleep 2 + return 1 + fi + # remount r/o + /bin/mount -n -o remount,ro $TARGET_DEV $TARGET + 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 test for possible hdboot/fromiso (which can be combined with toram / tohd) + 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 + if [ -n "$COPYTO" ] + then + copy_to $COPYTO && REAL_TARGET="$TARGET" + 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="" +$INSMOD /modules/unionfs.ko 2>/dev/null && UNIONFS="yes" + +# Enable kernel messages +echo "6" > /proc/sys/kernel/printk + +# Set paths +log_begin_msg "Setting paths" +PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:." +export PATH + +# 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 / +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 +log_begin_msg "Total memory found: $FOUNDMEM kB" ; echo " $SUCCESS" + +# 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 +MAXSIZE="$(expr $TOTALMEM - $MINLEFT)" +# Default ramdisk size for ramdisk +RAMSIZE="$(expr $TOTALMEM / 5)" +RAMSIZE="$(expr $RAMSIZE \* 4)" + +# FIXME +RAMSIZE="$(expr $RAMSIZE - 17400)" + +# Create additional dynamic ramdisk. +test -z "$RAMSIZE" -o "$RAMSIZE" -lt "$MINSIZE" && RAMSIZE="$MINSIZE" +mkdir -p /ramdisk +# tmpfs/varsize version, can use swap +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 && mv /tmp /tmp.old && ln -s /ramdisk/tmp /tmp && rm -rf /tmp.old +#/bin/mount -t tmpfs -o "size=${RAMSIZE}k" /ramdisk /ramdisk && mkdir -p /ramdisk/home /ramdisk/var && ln -s /ramdisk/home /ramdisk/var / + +stage=3 +rundebugshell +# unionfs +log_begin_msg "Creating unionfs and symlinks on ramdisk" +mkdir -p /UNIONFS +if test -n "$UNIONFS" && /bin/mount -t unionfs -o noatime,dirs=/ramdisk=rw:/GRML=ro /UNIONFS /UNIONFS; then + # 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/ + for i in bin boot etc sbin var lib opt root usr; do # Move directories to unionfs + if test -d /$i; then + mv /$i /$i.old && \ + /GRML/lib/ld-linux.so.2 --library-path /GRML/lib /GRML/bin/ln -snf /UNIONFS/$i /$i && \ + rm -rf /$i.old + else + ln -snf /UNIONFS/$i /$i + fi + done + #echo "${GREEN}done${NORMAL}" + 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 + log_failure_msg "ERROR: CANNOT UNITE READ-ONLY MEDIA AND INITIAL RAMDISK!" ; echo "$FAILED" + NOUNIONFS="yes" + /GRML/sbin/halt -f -n +fi + +chown grml.grml /home/grml +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 + +# umount /sys (remount in grml-autoconfig) +umount /sys + +stage=4 +rundebugshell +# Give control to the init process. +log_begin_msg "Starting init process." +rm -f /linuxrc +exit 0 + +else +echo "${CRE}${RED}Can't find grml filesystem, sorry.${NORMAL}" +echo "${RED}Dropping you to the busybox shell.${NORMAL}" +echo "${RED}Press reset button to quit.${NORMAL}" +echo "" +#echo "Additional builtin commands avaliable:" +#echo " cat mount umount" +#echo " insmod rmmod lsmod" +#echo "" +PS1="grml# " +export PS1 +echo "6" > /proc/sys/kernel/printk +# Allow signals +trap 1 2 3 15 +exec /static/sh +fi diff --git a/modcalc b/modcalc new file mode 100755 index 0000000..1c858b9 --- /dev/null +++ b/modcalc @@ -0,0 +1,66 @@ +#!/bin/sh +# "modtest" +# +# +# written by Michael Gebetsroither (michael.geb@gmx.at) +# +# 11.04.2005 - initial release (Michael Gebetsroither) +# +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, look at +# http://www.gnu.org/licenses/gpl.txt, or write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. + +TMP=`mktemp` + +MODULES_=$(awk '/ethernet/{print $3}' /lib/discover/pci.lst |sort |uniq |xargs) +MODULES_DEP_="$1" + +if [[ "$1" == "" ]]; then + echo "you have to give me the path to your modules.dep" >&2 + exit 1 +fi + +#for i in $MODULES_; do +# awk -F: '{if($1~/'"$i"'/) {print $1}}' /lib/modules/$KERNEL_VERSION_/modules.dep +#done > $TMP + +for i in $MODULES_; do + #awk -F: '{if($1~/'"$i"'/) {print $2}}' /lib/modules/$KERNEL_VERSION_/modules.dep + tmp_=`awk -F: '{if($1~/'"$i".ko'/) {print $0}}' $MODULES_DEP_` + echo "1-${tmp_%%:*}" + echo "${tmp_#*:}" |xargs -n1 echo |sed 's/://' +done \ +| sort | uniq | while read module relax; do + if [ -n "$module" ]; then + #echo "cp $module" "INITRD/modules/net/00_${module##*/}" + echo -n "$module" >> $TMP + echo -n "$relax" >> $TMP + echo >> $TMP + fi +done + +#for i in $MODULES_; do +# tmp_=`awk -F: '{if($1~/'"$i".ko'/) {print $0}}' /lib/modules/$KERNEL_VERSION_/modules.dep` +# echo first-match-$i--${tmp_%%:*} +# echo ${tmp_#*:} |xargs -n1 echo +# tmp_='' +#done \ +#|while read module relax; do +# echo "module=\"$module\" relax=\"$relax\"" +#done + +cat $TMP |sort |uniq +rm $TMP diff --git a/nfs-kernel-server b/nfs-kernel-server new file mode 100755 index 0000000..253514a --- /dev/null +++ b/nfs-kernel-server @@ -0,0 +1,144 @@ +#!/bin/sh +# +# nfs-kernel-server +# This shell script takes care of starting and stopping +# the kernel-mode NFS server. +# +# chkconfig: 345 60 20 +# description: NFS is a popular protocol for file sharing across TCP/IP \ +# networks. This service provides NFS server functionality, \ +# which is configured via the /etc/exports file. +# + +set -e + +# What is this? +DESC="NFS kernel daemon" +PREFIX=/usr + +# Exit if required binaries are missing. +[ -x $PREFIX/sbin/rpc.nfsd ] || exit 0 +[ -x $PREFIX/sbin/rpc.mountd ] || exit 0 +[ -x $PREFIX/sbin/exportfs ] || exit 0 +[ -x $PREFIX/sbin/rpc.svcgssd ] || exit 0 + +# Read config +DEFAULTFILE=/etc/default/nfs-kernel-server +RPCNFSDCOUNT=8 +RPCMOUNTDOPTS= +NEED_SVCGSSD=yes +RPCGSSDOPTS= +RPCSVCGSSDOPTS= +PROCNFSD_MOUNTPOINT=/proc/fs/nfsd +if [ -f $DEFAULTFILE ]; then + . $DEFAULTFILE +fi + +do_modprobe() { + modprobe -q "$1" || true +} + +do_mount() { + if ! grep -E -qs "$1\$" /proc/filesystems + then + return 1 + fi + if ! mountpoint -q "$2" + then + mount -t "$1" "$1" "$2" + return + fi + return 0 +} + +# See how we were called. +case "$1" in + start) + cd / # daemons should have root dir as cwd + # FIXME if grep -q '^/' /etc/exports + if [ -f /etc/exports ] + then + do_modprobe nfsd + do_mount nfsd $PROCNFSD_MOUNTPOINT || NEED_SVCGSSD=no + printf "Exporting directories for $DESC..." + $PREFIX/sbin/exportfs -r + echo "done." + + printf "Starting $DESC:" + if [ "$NEED_SVCGSSD" = yes ] + then + printf " svcgssd" + start-stop-daemon --start --quiet \ + --make-pidfile --pidfile /var/run/rpc.svcgssd.pid \ + --exec $PREFIX/sbin/rpc.svcgssd -- $RPCSVCGSSDOPTS + fi + + printf " nfsd" + start-stop-daemon --start --quiet \ + --exec $PREFIX/sbin/rpc.nfsd -- $RPCNFSDCOUNT + + printf " mountd" + + # make sure 127.0.0.1 is a valid source for requests + ClearAddr= + if [ -f /proc/net/rpc/auth.unix.ip/channel ] + then + fgrep -qs 127.0.0.1 /proc/net/rpc/auth.unix.ip/content || { + echo "nfsd 127.0.0.1 2147483647 localhost" >/proc/net/rpc/auth.unix.ip/channel + ClearAddr=yes + } + fi + + $PREFIX/bin/rpcinfo -u localhost nfs 3 >/dev/null 2>&1 || + RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3" + + [ -z "$ClearAddr" ] || echo "nfsd 127.0.0.1 1" >/proc/net/rpc/auth.unix.ip/channel + + start-stop-daemon --start --quiet \ + --exec $PREFIX/sbin/rpc.mountd -- $RPCMOUNTDOPTS + echo "." + else + echo "Not starting $DESC: No exports." + fi + ;; + + stop) + printf "Stopping $DESC: mountd" + start-stop-daemon --stop --oknodo --quiet \ + --name rpc.mountd --user 0 + if [ "$NEED_SVCGSSD" = yes ] + then + printf " svcgssd" + start-stop-daemon --stop --oknodo --quiet \ + --name rpc.svcgssd --user 0 + rm -f /var/run/rpc.svcgssd.pid + fi + printf " nfsd" + start-stop-daemon --stop --oknodo --quiet \ + --name nfsd --user 0 --signal 2 + echo "." + + printf "Unexporting directories for $DESC..." + $PREFIX/sbin/exportfs -au + echo "done." + ;; + + reload | force-reload) + printf "Re-exporting directories for $DESC..." + $PREFIX/sbin/exportfs -r + echo "done." + ;; + + restart) + $0 stop + sleep 1 + $0 start + ;; + + *) + echo "Usage: nfs-kernel-server {start|stop|reload|force-reload|restart}" + exit 1 + ;; +esac + +exit 0 diff --git a/rdir b/rdir new file mode 100755 index 0000000..44f57f5 --- /dev/null +++ b/rdir @@ -0,0 +1,12 @@ +#!/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 + diff --git a/shared_prog_vars b/shared_prog_vars new file mode 100644 index 0000000..51d927b --- /dev/null +++ b/shared_prog_vars @@ -0,0 +1,77 @@ +#!/bin/sh i like syntaxhighlighting ;) +# this is a shellscript fragment +# !!! DO NOT EDIT THIS FILE !!! +# only if you know what you are doing... + +### +## shared config vars +### + +# language +LANG_=en + +# main path from terminalserver +PATH_="/etc/grml/terminalserver" + +# config file produced from configuration program +CONF_FILE_="$PATH_/terminalserver.conf" + +# user editable config +CONFIG_="$PATH_/config" + +# 'data dir' from terminalserver +USR_SHARE_="/usr/share/grml-terminalserver" + +# defaults for vars in terminalserver.conf +DEFAULT_CONFIG_="$USR_SHARE_/default_config" + +# title for dialog +BACK_TITLE_="GRML TERMINAL-SERVER CONFIGURATION" + +# program to use for user questions (x)dialog +DIALOG_="dialog" + + +### +## grml-terminalserver +### + +# program to create $CONF_FILE_ +CONFIG_PROG_="/usr/sbin/grml-terminalserver-config" + +# vars for dhcpd +DHCPD_BIN_="/usr/sbin/dhcpd3" +DHCPD_CONFIG_FILE_="$PATH_/dhcpd.conf" +DHCPD_PID_=/var/run/dhcpd.pid + +# vars for tftpd +TFTPD_BIN_="/usr/sbin/in.tftpd" +TFTPD_DATA_DIR_="/var/lib/tftpboot" +TFTPD_PID_="/var/run/grml-tftpd.pid" + + +### +## grml-terminalserver-config +### + +# 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.96.tar.gz" + +# maximum initrd size +MAX_INITRD_SIZE_=16000 + +# path to uclibc +UCLIBC_PATH_="/usr/i386-uclibc-linux/lib" + +# this is where the terminalserver-config creates the initrd +INITRD_="$PATH_/mini-root" + +# only for this cards (kernel module names of drivers) drivers are copied into +# the initrd +CARDS_DETECTED_BY_DISCOVER="$PATH_/discover_netcards" diff --git a/templates/dhcpd_config b/templates/dhcpd_config new file mode 100644 index 0000000..56badbc --- /dev/null +++ b/templates/dhcpd_config @@ -0,0 +1,51 @@ +#!/bin/sh i like colors :) +# +# the following variables are available in the template: +# +# $INTERFACE_ (interface for the terminalserver) +# $IP_ (ip for the terminalserver to bind) +# $NETMASK_ (network mask) +# $GW_ (gateway) +# $NAMESERVERS_ (nameservers for the nodes) +# $IPRANGE_FROM_ (user configured iprange, first ip) +# $IPRANGE_TO_ (user configured iprange, last ip) +# $NETWORK_ (first ip in this subnet) +# $OPTIONS_ (options for grml-terminalserver) +# $BOOT_ARGS_ (boot arguments for the nodes) +# +# NOTE: +# templates are shellscript fragments and will be sourced from the +# terminalserver +# +# GLOBAL_README_END + +# +# this is the template to create the config file for the dhcpd server +# + +date_=`execute date warn` + +cat >"$DHCPD_CONFIG_FILE_" <"$TFTPD_DATA_DIR_/menu.lst" <"$TFTPD_DATA_DIR_/pxelinux.cfg/default" < + +[ -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 diff --git a/udhcpc b/udhcpc new file mode 100755 index 0000000..9485767 Binary files /dev/null and b/udhcpc differ