# Authors: grml-team (grml.org), (c) Klaus Knopper <knopper@knopper.net>, (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2.
-# Latest change: Son Apr 15 12:20:14 CEST 2007 [mika]
+# Latest change: Mon Apr 16 19:32:25 CEST 2007 [mika]
################################################################################
# {{{ path, variables, signals, umask, zsh
*) continue ;;
# *) NONEFOUND='1'; continue ;;
esac
-
+
# use a swapfile
if [ -z "$NOSWAP" ] ; then
mount -o "$MOUNTOPTS" -t $f $p $m 2>>$DEBUG || continue
fi
mount -o remount,ro $m 2>>$DEBUG && MOUNTED=1
fi
-
+
# use a image as home
IMAGE="$(/bin/ls -1d $m/[Gg][Rr][Mm][Ll].[Ii][Mm][Gg] 2>/dev/null)"
if [ -z "$GRML_IMG" -a -n "$IMAGE" -a -f "$IMAGE" ]; then
fi
fi
eend 0
-
+
# Umount, if not in use
[ -n "$MOUNTED" ] && umount -r $m 2>/dev/null
-
+
done <<EOT
$(cat /etc/fstab)
EOT
EOF
chmod 755 /etc/init.d/xstartup
- sed -i 's#^6:.*#6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /bin/zsh"#' /etc/inittab
+ # adjust inittab for xstartup
+ if grep -q '^6:' /etc/inittab ; then
+ sed -i 's|^6:.*|6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /bin/zsh"|' /etc/inittab
+ else # just append tty6 to inittab if no definition is present:
+ echo '6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /bin/zsh"' >> /etc/inittab
+ fi
/sbin/telinit q ; eend $?
# {{{ grml2hd: automatic installation
config_grml2hd(){
+if stringinstring "BOOT_IMAGE=grml2hd " "$CMDLINE" ; then
+
if checkbootparam "user" ; then
- NEWUSER=''
- NEWUSER="$(getbootparam 'user' 2>>$DEBUG)"
- sed -i "s/^NEWUSER=.*/NEWUSER=$NEWUSER/" /etc/grml2hd/config || export GRML2HD_FAIL=1
+ NEWUSER=''
+ NEWUSER="$(getbootparam 'user' 2>>$DEBUG)"
+ sed -i "s/^NEWUSER=.*/NEWUSER=$NEWUSER/" /etc/grml2hd/config || export GRML2HD_FAIL=1
fi
if checkbootparam "filesystem" ; then
- FILESYSTEM=''
- FILESYSTEM="$(getbootparam 'filesystem' 2>>$DEBUG)"
- sed -i "s/^FILESYSTEM=.*/FILESYSTEM=$FILESYSTEM/" /etc/grml2hd/config || export GRML2HD_FAIL=1
+ FILESYSTEM=''
+ FILESYSTEM="$(getbootparam 'filesystem' 2>>$DEBUG)"
+ sed -i "s/^FILESYSTEM=.*/FILESYSTEM=$FILESYSTEM/" /etc/grml2hd/config || export GRML2HD_FAIL=1
fi
if checkbootparam "partition" ; then
- PARTITION=''
- PARTITION="$(getbootparam 'partition' 2>>$DEBUG)"
- # notice: the following checks whether the given partition is available, if not the skip
- # execution of grml2hd as it might result in data loss...
- if [ -r $PARTITION ] ; then
- sed -i "s#^PARTITION=.*#PARTITION=$PARTITION#" /etc/grml2hd/config || export GRML2HD_FAIL=1
- else
- ewarn "Partition $PARTITION does not exist. Skipping execution of grml2hd therefore." ; eend 1
- fi
+ PARTITION=''
+ PARTITION="$(getbootparam 'partition' 2>>$DEBUG)"
+ # notice: the following checks whether the given partition is available, if not the skip
+ # execution of grml2hd as it might result in data loss...
+ if [ -r $PARTITION ] ; then
+ sed -i "s#^PARTITION=.*#PARTITION=$PARTITION#" /etc/grml2hd/config || export GRML2HD_FAIL=1
+ else
+ ewarn "Partition $PARTITION does not exist. Skipping execution of grml2hd therefore." ; eend 1
+ fi
fi
if checkbootparam "mbr" ; then
- BOOT_PARTITION=''
- BOOT_PARTITION="$(getbootparam 'mbr' 2>>$DEBUG)"
- sed -i "s#^BOOT_PARTITION=.*#BOOT_PARTITION=$BOOT_PARTITION#" /etc/grml2hd/config || export GRML2HD_FAIL=1
+ BOOT_PARTITION=''
+ BOOT_PARTITION="$(getbootparam 'mbr' 2>>$DEBUG)"
+ sed -i "s#^BOOT_PARTITION=.*#BOOT_PARTITION=$BOOT_PARTITION#" /etc/grml2hd/config || export GRML2HD_FAIL=1
fi
-if stringinstring "BOOT_IMAGE=grml2hd " "$CMDLINE" ; then
- cat>|/usr/bin/grml2hd_noninteractive<<EOF
+cat>|/usr/bin/grml2hd_noninteractive<<EOF
#!/bin/sh
GRML2HD_NONINTERACTIVE='yes' grml2hd
EOF
- chmod 755 /usr/bin/grml2hd_noninteractive
- einfo "Bootparameter grml2hd found. Running automatic installation via grml2hd using /etc/grml2hd/config." && eend 0
- if [ -z "$GRML2HD_FAIL" ] ; then
- screen /usr/bin/grml2hd_noninteractive ; einfo "Invoking a shell, just exit to continue booting..." ; /bin/zsh
- else
- ewarn "There was an error adjusting /etc/grml2hd/config. Skipping execution of grml2hd for security reasons." ; eend 1
+
+chmod 755 /usr/bin/grml2hd_noninteractive
+einfo "Bootoption grml2hd found. Running automatic installation via grml2hd using /etc/grml2hd/config." && eend 0
+if [ -z "$GRML2HD_FAIL" ] ; then
+ screen /usr/bin/grml2hd_noninteractive ; einfo "Invoking a shell, just exit to continue booting..." ; /bin/zsh
+else
+ ewarn "There was an error adjusting /etc/grml2hd/config. Skipping execution of grml2hd for security reasons." ; eend 1
+fi
+
+fi # if stringinstring "BOOT_IMAGE=grml2hd ...
+}
+# }}}
+
+# {{{ debootstrap: automatic installation
+config_debootstrap(){
+
+if stringinstring "BOOT_IMAGE=debian2hd " "$CMDLINE" ; then
+
+einfo "Bootoption debian2hd found. Setting up environment for automatic installation via grml-debootstrap." ; eend 0
+
+if ! [ -x /usr/sbin/grml-debootstrap ] ; then
+ eerror "Bootoption debian2hd found, but grml-debootstrap is not available." ; eend 1
+ eerror "Dropping you to a shell, just exit it to continue booting." ; eend 1
+ /bin/zsh
+fi
+
+if checkbootparam "partition" ; then
+ PARTITION=''
+ PARTITION="$(getbootparam 'partition' 2>>$DEBUG)"
+ # notice: the following checks whether the given partition is available, if not the skip
+ # execution of grml-debootstrap as it might result in data loss...
+ if ! [ -r $PARTITION ] ; then
+ eerror "Partition $PARTITION does not exist. Skipping execution of grml-debootstrap therefore." ; eend 1
fi
+else
+ eerror "No bootoption partition found, can not continue execution of grml-debootstrap." ; eend 1
+ exit 0
+fi
+
+if checkbootparam "grub" ; then
+ GRUB=''
+ GRUB="$(getbootparam 'grub' 2>>$DEBUG)"
+fi
+
+if checkbootparam "groot" ; then
+ GROOT=''
+ GROOT="$(getbootparam 'groot' 2>>$DEBUG)"
+fi
+
+if checkbootparam "release" ; then
+ RELEASE=''
+ RELEASE="$(getbootparam 'release' 2>>$DEBUG)"
fi
+
+if checkbootparam "mirror" ; then
+ MIRROR=''
+ MIRROR="$(getbootparam 'mirror' 2>>$DEBUG)"
+fi
+
+if checkbootparam "password" ; then
+ PASSWORD=''
+ PASSWORD="$(getbootparam 'password' 2>>$DEBUG)"
+fi
+
+# now check which options are available
+if [ -n "PARTITION" ] ; then
+ PARTITIONCMD="--target $PARTITION"
+else
+ PARTITIONCMD=''
+ ewarn "Partion not set via bootoption. Skipping execution of grml-debootstrap therefore."; eend 1
+fi
+[ -n "$GRUB" ] && GRUBCMD="--grub $GRUB" || GRUBCMD=''
+[ -n "$GROOT" ] && GROOTCMD="--groot $GROOT" || GROOTCMD=''
+[ -n "$RELEASE" ] && RELEASECMD="--release $RELEASE" || RELEASECMD=''
+[ -n "$MIRROR" ] && MIRRORCMD="--mirror $MIRROR" || MIRRORCMD=''
+[ -n "$PASSWORD" ] && PASSWORDCMD="--password $PASSWORD" ] || PASSWORDCMD=''
+
+# and finally write script and execute it
+cat>|/usr/bin/grml-debootstrap_noninteractive<<EOF
+#!/bin/sh
+AUTOINSTALL='yes' grml-debootstrap $PARTITIONCMD $GRUBCMD $GROOTCMD $RELEASECMD $MIRRORCMD $PASSWORDCMD
+EOF
+
+chmod 750 /usr/bin/grml-debootstrap_noninteractive
+
+screen /usr/bin/grml-debootstrap_noninteractive
+einfo "Invoking a shell, just exit to continue booting..."
+/bin/zsh
+
+fi # stringinstring "BOOT_IMAGE=debian2hd
}
# }}}