From: grml User Date: Sat, 15 Sep 2007 16:23:11 +0000 (+0200) Subject: Add grml-live script X-Git-Tag: 0.0.1~69 X-Git-Url: http://git.grml.org/?p=grml-live.git;a=commitdiff_plain;h=cfd32a33aab0d28608bba9e34c65b2a1967be9b7 Add grml-live script --- diff --git a/TODO b/TODO deleted file mode 100644 index 5c0aa81..0000000 --- a/TODO +++ /dev/null @@ -1,6 +0,0 @@ -TODO for grml-live -================== - -* make all references to "grml" (hostname, usersetup,...) configurable -* replace 192.168.... mirrors with something generic and make it configurable -* provide buildprocess for boot/isolinux stuff diff --git a/debian/rules b/debian/rules index 69f95d3..290e4f4 100755 --- a/debian/rules +++ b/debian/rules @@ -30,11 +30,11 @@ install: build dh_testdir dh_testroot dh_clean -k - dh_installdirs etc/grml/fai/live-initramfs + dh_installdirs etc/grml/fai/live-initramfs usr/sbin # Add here commands to install the package into debian/grml-live. cp -a etc debian/grml-live/ - install -m 755 initramfs/scripts/init-top/grml debian/grml-live/etc/grml/fai/live-initramfs/grml + install -o root -m 755 grml-live debian/grml-live/usr/sbin/grml-live # Build architecture-independent files here. binary-indep: build install @@ -45,7 +45,7 @@ binary-arch: build install dh_testdir dh_testroot dh_installchangelogs - dh_installdocs TODO docs/grml-live.html + dh_installdocs docs/grml-live.html dh_installexamples dh_installman docs/grml-live.8 dh_link diff --git a/docs/grml-live.txt b/docs/grml-live.txt index 45c5278..33466b3 100644 --- a/docs/grml-live.txt +++ b/docs/grml-live.txt @@ -26,15 +26,25 @@ FAI uses a class based system. This gives you the flexibility to choose the packages you would like to include on your very own live-cd without having to deal with all the details in the core of the system. +Please notice that you should have a fast network connection as all the Debian +packages will be installed via network. If you want to use a local mirror +checkout +link:http://www.informatik.uni-koeln.de/fai/download/mkdebmirror[mkdebmirror] +and debmirror. + How to get your own live-cd - the easy, fast and simple way ----------------------------------------------------------- To get a small, Debian-stable and grml based live-cd: - # TARGET="/grml/chroot/grml_uncompressed" ; mkdir -p $TARGET + # export LANG=C ; export LC_MESSAGES=C + # TARGET="/grml/chroot/grml_uncompressed" + # CDDIR="/grml/chroot/grml_cd" + # mkdir -p $TARGET + # fai -v -C /etc/grml/fai -cGRML dirinstall $TARGET - # mksquashfs $TARGET/* /grml/chroot/grml_cd/live/grml.squashfs -noappend - # cd /grml/chroot/grml_cd/ + # mksquashfs $TARGET/* $CDDIR/live/grml.squashfs -noappend + # cd $CDDIR # mkisofs -V "my personal grml" -l -r -J -no-emul-boot -boot-load-size 4 \ -boot-info-table -c boot/isolinux/boot.cat \ -b boot/isolinux/isolinux.bin -o /grml/grml.iso . @@ -61,6 +71,20 @@ scripts for FAI/grml-live can be found. By default it is FAI_CONFIGDIR=/etc/grml/fai/config, a directory shipped by grml-live out-of-the-box so you shouldn't have to configure anything in this file. + /etc/grml/fai/make-fai-nfsroot.conf + +TODO + + /etc/grml/fai/NFSROOT + +TODO + + /etc/grml/fai/apt/sources.list + +This file specifies which mirrors should be used for retreiving the Debian +packages used for creating the ISO. If you want to use a local mirror you have +to adjust this file. + /etc/grml/fai/config/ The main directory for configuration of FAI/grml-live. More details below. @@ -72,7 +96,7 @@ FAI classes. /etc/grml/fai/config/debconf/ -This directory provides the files for presseding/configuration of debconf +This directory provides the files for preseeding/configuration of debconf through files. /etc/grml/fai/config/hooks/ @@ -84,21 +108,43 @@ installation process. /etc/grml/fai/config/package_config/ File with lists of software packages to be installed or removed. The different -classes describe what should find its way to your ISO. When running 'fai -v --cGRML dirinstall ...' only the files from the directory GRML/ will be taken, if -you use 'fai -v -cGRML,FOOBAR dirinstall ...' then the files of GRML/ **plus** -the files from FOOBAR/ will be taken. So just create a new class to adjust it to -your needs. Please notice that the directory GRML contains a package list -defining a minimum but still reasonable package configuration. +classes describe what should find its way to your ISO. When running 'fai -v -C +/etc/grml/fai -cGRML dirinstall ...' only the files from the directory GRML/ +will be taken, if you use 'fai -v -C /etc/grml/fai -cGRML,FOOBAR dirinstall ...' +then the files of GRML/ **plus** the files from FOOBAR/ will be taken. So just +create a new class to adjust it to your needs. Please notice that the directory +GRML contains a package list defining a minimum but still reasonable package +configuration. /etc/grml/fai/config/scripts/ Scripts for customising the ISO within build process. + /etc/grml/fai/live-initramfs/ + +This directory provides the files used for building the initramfs/initrd via +live-initramfs(8). + +TODO +---- + +* provide a wrapper script which runs all the necessary command in a single run +(named grml-live plus configuration file /etc/grml/grml-live.conf) + +* replace 192.168.... inside the configuration files for the Debian mirro with +something generic and make it configurable + +* provide buildprocess for boot/isolinux stuff + +* explain and provide configuration for use of NFSROOT + Bugs ---- -Please report feedback, link:http://grml.org/bugs/[bugreports] and wishes link:http://grml.org/contact/[to us]! + +Please report feedback, link:http://grml.org/bugs/[bugreports] and wishes +link:http://grml.org/contact/[to the grml-team]! Authors ------- Michael Prokop . + diff --git a/etc/grml/fai/config/scripts/GRML/05-hostname b/etc/grml/fai/config/scripts/GRML/05-hostname new file mode 100755 index 0000000..529614a --- /dev/null +++ b/etc/grml/fai/config/scripts/GRML/05-hostname @@ -0,0 +1,9 @@ +#!/bin/sh +set -u +set -e + +HOSTNAME='' +[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf +[ -n "$HOSTNAME" ] || HOSTNAME=grml + +echo "$HOSTNAME" > "$target"/etc/hostname diff --git a/etc/grml/fai/config/scripts/GRML/10-build-initramfs b/etc/grml/fai/config/scripts/GRML/10-build-initramfs index 1d5512e..38c0ba2 100755 --- a/etc/grml/fai/config/scripts/GRML/10-build-initramfs +++ b/etc/grml/fai/config/scripts/GRML/10-build-initramfs @@ -2,6 +2,7 @@ set -u set -e +cp /etc/grml/fai/live-initramfs/live.conf "$target/etc/live.conf" FILE=$(ls -1 "$target"/boot/vmlinuz-* | sort -r | head -1) KERNELVERSION=$(echo "${FILE##$target/boot/vmlinuz-}") chroot $target update-initramfs -c -t -k $KERNELVERSION diff --git a/etc/grml/fai/config/scripts/GRML/15-initsetup b/etc/grml/fai/config/scripts/GRML/15-initsetup new file mode 100755 index 0000000..bdd5dbd --- /dev/null +++ b/etc/grml/fai/config/scripts/GRML/15-initsetup @@ -0,0 +1,9 @@ +#!/bin/sh +set -u +set -e + +if grep -q "small" "$target"/etc/grml_version ; then + cp "$target"/etc/runlevel.conf.livecd.small "$target"/etc/runlevel.conf +else + cp "$target"/etc/runlevel.conf.livecd "$target"/etc/runlevel.conf +fi diff --git a/etc/grml/fai/config/scripts/GRML/20-sudo b/etc/grml/fai/config/scripts/GRML/20-sudo index 4bf8c76..3c648ea 100755 --- a/etc/grml/fai/config/scripts/GRML/20-sudo +++ b/etc/grml/fai/config/scripts/GRML/20-sudo @@ -2,6 +2,10 @@ set -u set -e +USERNAME='' +[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf +[ -n "$USERNAME" ] || USERNAME=grml + cat > "$target"/etc/sudoers << EOF # sudoers file. # This file MUST be edited with the "visudo" command as root. @@ -16,19 +20,19 @@ cat > "$target"/etc/sudoers << EOF # User privilege specification root ALL=(ALL) ALL -# WARNING: This allows the unprivileged grml user to start commands as root -# WARNING: This is totally insecure and (almost) makes grml a second root account. -# WARNING: Never allow external access to the grml user!!! -grml ALL=NOPASSWD: ALL +# WARNING: This allows the unprivileged $USERNAME user to start commands as root +# WARNING: This is totally insecure and (almost) makes $USERNAME a second root account. +# WARNING: Never allow external access to the $USERNAME user!!! +$USERNAME ALL=NOPASSWD: ALL # allow editing of files with editor: -# grml ALL=NOPASSWD: sudoedit +# $USERNAME ALL=NOPASSWD: sudoedit # usage examples: -# grml ALL=NOPASSWD: /sbin/hdparm -# grml ALL=NOPASSWD: /usr/sbin/hwinfo +# $USERNAME ALL=NOPASSWD: /sbin/hdparm +# $USERNAME ALL=NOPASSWD: /usr/sbin/hwinfo # Cmnd_Alias DEBIAN = /usr/bin/apt-get, /usr/bin/dpkg, /usr/bin/auto-apt, /usr/bin/apt-file -# grml ALL=NOPASSWD: DEBIAN +# $USERNAME ALL=NOPASSWD: DEBIAN # chroot ALL=NOPASSWD: /usr/sbin/chroot, /bin/su - chroot # chroot ALL=NOPASSWD: /usr/sbin/chroot, /bin/su - chroot diff --git a/etc/grml/fai/config/scripts/GRML/21-usersetup b/etc/grml/fai/config/scripts/GRML/21-usersetup index bc53220..30c01dc 100755 --- a/etc/grml/fai/config/scripts/GRML/21-usersetup +++ b/etc/grml/fai/config/scripts/GRML/21-usersetup @@ -2,11 +2,15 @@ set -u set -e -chroot "$target" addgroup --gid 1000 grml -chroot "$target" useradd -d /home/grml -m -s /bin/zsh -g 1000 grml +USERNAME='' +[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf +[ -n "$USERNAME" ] || USERNAME=grml + +chroot "$target" addgroup --gid 1000 $USERNAME +chroot "$target" useradd -d /home/$USERNAME -m -s /bin/zsh -g 1000 $USERNAME sed -i 's/^root::/root:*:/' "$target"/etc/shadow -sed -i 's/^grml::/grml:*:/' "$target"/etc/shadow +sed -i 's/^$USERNAME::/$USERNAME:*:/' "$target"/etc/shadow chroot "$target" chsh -s /bin/zsh root -chroot "$target" chsh -s /bin/zsh grml +chroot "$target" chsh -s /bin/zsh $USERNAME diff --git a/etc/grml/fai/config/scripts/GRML/30-fstab b/etc/grml/fai/config/scripts/GRML/30-fstab index 7b91a92..63af770 100755 --- a/etc/grml/fai/config/scripts/GRML/30-fstab +++ b/etc/grml/fai/config/scripts/GRML/30-fstab @@ -2,6 +2,10 @@ set -u set -e +USERNAME='' +[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf +[ -n "$USERNAME" ] || USERNAME=grml + cat > "$target"/etc/fstab << EOF # /etc/fstab - static file system information # @@ -10,8 +14,8 @@ none /proc/bus/usb usbfs defaults,noauto 0 sysfs /sys sysfs rw,nosuid,nodev,noexec 0 0 devpts /dev/pts devpts noauto,mode=0622 0 0 /dev/fd0 /mnt/floppy auto users,noauto,exec 0 0 -/dev/external /mnt/external auto users,noauto,exec,rw,uid=grml,gid=grml 0 0 -/dev/external1 /mnt/external1 auto users,noauto,exec,rw,uid=grml,gid=grml 0 0 +/dev/external /mnt/external auto users,noauto,exec,rw,uid=$USERNAME,gid=$USERNAME 0 0 +/dev/external1 /mnt/external1 auto users,noauto,exec,rw,uid=$USERNAME,gid=$USERNAME 0 0 /dev/cdrom /mnt/cdrom auto users,noauto,exec,ro 0 0 /dev/dvd /mnt/dvd auto users,noauto,exec,ro 0 0 # some other examples: diff --git a/etc/grml/fai/config/scripts/GRML/34-hosts b/etc/grml/fai/config/scripts/GRML/34-hosts index 63b1409..3d30bba 100755 --- a/etc/grml/fai/config/scripts/GRML/34-hosts +++ b/etc/grml/fai/config/scripts/GRML/34-hosts @@ -2,13 +2,17 @@ set -u set -e +HOSTNAME='' +[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf +[ -n "$HOSTNAME" ] || HOSTNAME=grml + cat > "$target"/etc/hosts << EOF -127.0.0.1 grml localhost +127.0.0.1 $HOSTNAME localhost # The following lines are desirable for IPv6 capable hosts # (added automatically by netbase upgrade) -::1 ip6-localhost ip6-loopback grml +::1 ip6-localhost ip6-loopback $HOSTNAME fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes diff --git a/initramfs/scripts/init-top/grml b/etc/grml/fai/live-initramfs/grml-script.init-top similarity index 100% rename from initramfs/scripts/init-top/grml rename to etc/grml/fai/live-initramfs/grml-script.init-top diff --git a/initramfs/live.conf b/etc/grml/fai/live-initramfs/live.conf similarity index 100% rename from initramfs/live.conf rename to etc/grml/fai/live-initramfs/live.conf diff --git a/etc/grml/fai/menu.lst b/etc/grml/fai/menu.lst deleted file mode 100644 index 38eada8..0000000 --- a/etc/grml/fai/menu.lst +++ /dev/null @@ -1,44 +0,0 @@ -# grub menu.lst for fai-cd - -# Boot automatically after some secs. -timeout 30 - -color light-gray/black light-gray/red -default 6 - -title | -root (cd) -title +------------------------------------------------------+ -root (cd) -title | FAI-CD (c) 2006, Thomas Lange, lange@debian.org | -root (cd) -title | _VERSIONSTRING_ | -root (cd) -title +------------------------------------------------------+ -root (cd) -title | -root (cd) -title | - -title boot from local disk -rootnoverify (hd0) -chainloader +1 - -title Fully Automatic Installation - demohost (pw: installme) -password installme -kernel /boot/vmlinuz boot=live FAI_FLAGS="verbose,createvt" FAI_ACTION=install ip=192.168.1.1:::::eth0:off hostname=demohost -initrd /boot/initrd.img - -title Fully Automatic Installation with GNOME (pw: installme) -password installme -kernel /boot/vmlinuz boot=live FAI_FLAGS="verbose,createvt" FAI_ACTION=install ip=192.168.1.1:::::eth0:off hostname=gnomehost -initrd /boot/initrd.img - -title Fully Automatic Installation - faiserver (pw: installme) -password installme -kernel /boot/vmlinuz boot=live FAI_FLAGS="verbose,createvt" FAI_ACTION=install ip=192.168.1.250::192.168.1.254:255.255.255.0::xxx:off hostname=faiserver -initrd /boot/initrd.img - -title FAI rescue system, no installation -kernel /boot/vmlinuz boot=live FAI_FLAGS="verbose,createvt" FAI_ACTION=sysinfo ip=192.168.1.1:::::eth0:off hostname=demohost -initrd /boot/initrd.img diff --git a/etc/grml/grml-live.conf b/etc/grml/grml-live.conf new file mode 100644 index 0000000..02feb1d --- /dev/null +++ b/etc/grml/grml-live.conf @@ -0,0 +1,33 @@ +# Filename: /etc/grml/grml-live.conf +# Purpose: main configuration file for grml-live +# Authors: grml-team (grml.org), (c) Michael Prokop +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2 or any later version. +# Latest change: Sat Sep 15 17:02:32 CEST 2007 [mika] +################################################################################ + +# unless this variable is set, grml-live won't execute anything! +# so set it to '1' if you want to use grml-live +EXECUTE=1 + +# output directory of the buildprocess files (the chroot), +# notice that you need suid,dev,rw permissions there: +TARGET="/dev/shm/fai" # FIXME / TODO +# mount -o remount,suid,dev,rw /dev/shm + +# which FAI classes do you want to use by default? +CLASSES="GRML" + +# directory of configuration files for FAI: +FAI_CONFIG=/etc/grml/fai + +# specify hostname of the live-system: +HOSTNAME=grml + +# specify user with UID 1000 on live-system: +USERNAME=grml + +# do you want to pass any additional arguments to FAI? +FAI_ARGS="" + +## END OF FILE ################################################################# diff --git a/grml-live b/grml-live new file mode 100755 index 0000000..2ecba76 --- /dev/null +++ b/grml-live @@ -0,0 +1,129 @@ +#!/bin/sh +# Filename: grml-live +# Purpose: build process script for generating a (grml based) Linux Live-ISO +# Authors: grml-team (grml.org), (c) Michael Prokop +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2 or any later version. +# Latest change: Sat Sep 15 18:22:07 CEST 2007 [mika] +################################################################################ + +# read configuration files, set some misc variables {{{ + +# exit on any error: +set -e + +# we need root permissions for the build-process: +if [ "$(id -u 2>/dev/null)" != 0 ] ; then + echo "Error: please run this script with uid 0 (root)." >&2 + exit 1 +fi + +VERBOSE='' +FORCE='' +DEBUG='' + +# source main configuration file: +. /etc/grml/grml-live.conf + +PN=$(basename $0) +TMPFILE=$(mktemp) +# }}} + +# clean exit {{{ +bailout() { + rm -f "$TMPFILE" + [ -n "$1" ] && EXIT="$1" || EXIT="1" + [ -n "$2" ] && echo "$2">&2 + exit "$EXIT" +} +trap bailout 1 2 3 15 +# }}} + +# check for important variables {{{ +[ -n "$FAI_CONFIG" ] || FAI_CONFIG=/etc/grml/fai +[ -n "$HOSTNAME" ] || HOSTNAME=grml +[ -n "$USERNAME" ] || USERNAME=grml +[ -n "$CLASSES" ] || CLASSES="GRML" +[ -n "$TARGET" ] || bailout 1 "${PN}: \$TARGET not specified. Please adjust /etc/grml/grml-live.conf. Exiting." +# }}} + +# usage information {{{ +usage() +{ + echo " +$PN - build process script for generating a (grml based) Linux Live-ISO + +Usage: $PN [-c ] [-t ] [-F] [-h|--help] [addiontalarguments_for_fai] + +Usage examples: + + $PN + $PN -c GRML -t /dev/shm/grml + $PN -c GRML,GRML_X -t /grml/chroot/grml_uncompressed + $PN -c GRML + +More details: man grml-live + /usr/share/doc/grml-live/grml-live.html + +Please send your bug reports, feedback,.. to the grml-team. +http://grml.org/bugs/ +" +} +# }}} + +# command line parsing {{{ + +while getopts ?c:f:t:Fhv: opt; do + case "$opt" in + c) CLASSES="$OPTARG" ;; + F) FORCE=1 ;; + h) usage ; bailout 0 ;; + t) TARGET="$OPTARG" ;; + v) VERBOSE=1 ;; + ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;; + esac +done +shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter +FAI_ARGS="$*" + +# }}} + +# some misc checks before executing FAI {{{ +[ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in /etc/grml/grml-live.conf or +specify it on the command line using the -c|--classes option." +[ -n "$TARGET" ] || bailout 1 "Error: \$TARGET unset, please set it in /etc/grml/grml-live.conf or +specify it on the command line using the -t|--target option." + +if [ "$EXECUTE" != '1' ] ; then + echo "Error: please set EXECUTE=1 in /etc/grml/grml-live.conf to really execute grml-live.">&2 + echo + echo "See 'man grml-live' for more details or execute '$PN --help'">&2 + echo + bailout 1 +fi +# }}} + +# ask user whether the setup is ok {{{ +if [ -z "$FORCE" ] ; then + echo + echo "$PN - check your configuration (or invoke using -F to force execution without prompting)" + echo + echo " FAI classes: $CLASSES" + echo " target / output directory: $TARGET" + [ -n "$FAI_ARGS" ] && echo " additional arguments for FAI: $FAI_ARGS" + echo + echo -n "Is this ok for you? [y/N] " + read a + if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then + bailout 1 "Exiting as requested." + fi + echo +fi +# }}} + +# execute FAI {{{ +echo fai -v -C "$FAI_CONFIG" -c"$CLASSES" dirinstall "$TARGET" $FAI_ARGS +# }}} + +## END OF FILE ################################################################# +# vim:foldmethod=marker ts=2 ft=sh ai expandtab tw=80 sw=2