drop enabled config variables from config file and use defaults
[grml-debootstrap.git] / grml-debootstrap
index 1cba99a..f3243c9 100755 (executable)
@@ -14,8 +14,29 @@ VERSION="${VERSION:-unknown}"
 MNTPOINT="/mnt/debootstrap.$$"
 
 # defaults
-VMSIZE="2G"
+CHROOT_SCRIPTS='yes'
+CONFFILES='/etc/debootstrap'
+DEBCONF='yes'
+DEBIAN_FRONTEND='noninteractive'
+DEBOOTSTRAP='debootstrap'
+EXTRAPACKAGES='yes'
 FORCE=''
+HOSTNAME='grml'
+INITRD='yes'
+INSTALL_NOTES='/etc/debootstrap/install_notes'
+LOCALES='yes'
+MIRROR='http://cdn.debian.net/debian'
+MKFS='mkfs.ext3'
+PACKAGES='yes'
+PRE_SCRIPTS='yes'
+RECONFIGURE='console-data'
+RELEASE='squeeze'
+RM_APTCACHE='yes'
+SCRIPTS='yes'
+SECURE='yes'
+TIMEZONE='Europe/Vienna'
+TUNE2FS='tune2fs -c0 -i0'
+VMSIZE="2G"
 
 # inside the chroot system locales might not be available, so use minimum:
 export LANG=C
@@ -46,7 +67,7 @@ Bootstrap options:
       --interactive      Use interactive mode (frontend).
       --nodebootstrap    Skip debootstrap, only do configuration to the target.
       --grub <device>    Target for grub installation. Usage example: /dev/sda
-      --arch <arch>      Architecture to use. Currently only i386 is supported.
+      --arch <arch>      Set target architecture, use for installing i386 on amd64.
       --filesystem <fs>  Filesystem that should be used when target is a partition
                          or Virtual Machine (see --vmfile).
       --insecure         Do not download and check Release file signatures.
@@ -66,12 +87,15 @@ Configuration options:
                              /etc/debootstrap/config
   -d, --confdir <path>     Place of config files for debootstrap, defaults
                              to /etc/debootstrap
-      --packages <file>    Install packages defined in specified list file.
+      --packages <file>    Install packages defined in specified list file
+                             instead of using /etc/debootstrap/packages.
       --nopackages         Skip installation of packages defined in
                              /etc/debootstrap/packages
       --debconf <file>     Pre-seed packages using specified pre-seed db file.
+      --grmlrepos          Enable Grml's Debian repository (deb.grml.org).
       --keep_src_list      Do not overwrite user provided apt sources.list.
       --hostname <name>    Hostname of Debian system.
+      --nopassword         Do not prompt for the root password.
       --password <pwd>     Use specified password as password for user root.
       --bootappend <line>  Add specified appendline to kernel whilst booting.
       --chroot-scripts <d> Execute chroot scripts from specified directory.
@@ -267,8 +291,10 @@ fi
 [ "$_opt_pre_scripts_set" ]     && PRE_SCRIPTS='yes'
 [ "$_opt_chroot_scripts_set" ]  && CHROOT_SCRIPTS='yes'
 [ "$_opt_keep_src_list" ]       && KEEP_SRC_LIST='yes'
+[ "$_opt_grmlrepos" ]           && GRMLREPOS='yes'
 [ "$_opt_hostname" ]            && HOSTNAME=$_opt_hostname
 [ "$_opt_password" ]            && ROOTPASSWORD=$_opt_password
+[ "$_opt_nopassword" ]          && NOPASSWORD='yes'
 [ "$_opt_bootappend" ]          && BOOT_APPEND=$_opt_bootappend
 [ "$_opt_grub" ]                && GRUB=$_opt_grub
 [ "$_opt_arch" ]                && ARCH=$_opt_arch
@@ -464,23 +490,28 @@ prompt_for_hostname()
 # ask for password {{{
 prompt_for_password()
 {
-     ROOTPW1='PW1'
-     ROOTPW2='PW2'
-     while [ "$ROOTPW1" != "$ROOTPW2" ]; do
-       ROOTPW1=$(dialog --insecure --stdout --title "${PN}" --passwordbox \
-       "Please enter the password for the root account:" 10 60)
-       [ $? -eq 0 ] || bailout
-       ROOTPW2=$(dialog --insecure --stdout --title "${PN}" --passwordbox \
-       "Please enter the password for the root account again for \
-       confirmation:" 10 60)
-       [ $? -eq 0 ] || bailout
-
-       if [ "$ROOTPW1" != "$ROOTPW2" ]; then
-         $(dialog --stdout --title "${PN}" --ok-label \
-         "Retry" --msgbox "Passwords do not match!" 10 60)
-       fi
-     done
-     ROOTPASSWORD="$ROOTPW1"
+  if [ "$_opt_nopassword" ] ; then
+    einfo "Skip asking for root password as requested."
+    return 0
+  fi
+
+  ROOTPW1='PW1'
+  ROOTPW2='PW2'
+  while [ "$ROOTPW1" != "$ROOTPW2" ]; do
+    ROOTPW1=$(dialog --insecure --stdout --title "${PN}" --passwordbox \
+    "Please enter the password for the root account:" 10 60)
+    [ $? -eq 0 ] || bailout
+    ROOTPW2=$(dialog --insecure --stdout --title "${PN}" --passwordbox \
+    "Please enter the password for the root account again for \
+    confirmation:" 10 60)
+    [ $? -eq 0 ] || bailout
+
+    if [ "$ROOTPW1" != "$ROOTPW2" ]; then
+      $(dialog --stdout --title "${PN}" --ok-label \
+      "Retry" --msgbox "Passwords do not match!" 10 60)
+    fi
+  done
+  ROOTPASSWORD="$ROOTPW1"
 }
 # }}}
 
@@ -888,7 +919,7 @@ prepare_vm() {
   ORIG_TARGET="$TARGET" # store for later reuse
 
   qemu-img create -f raw "${TARGET}" "${VMSIZE}"
-  echo 4 66 | mksh /usr/share/grml-debootstrap/bootgrub.mksh -A | dd of="$TARGET" conv=notrunc
+  echo 4 66 | /usr/share/grml-debootstrap/bootgrub.mksh -A | dd of="$TARGET" conv=notrunc
   dd if=/dev/zero bs=1 conv=notrunc count=64 seek=446 of="$TARGET"
   parted -s "${TARGET}" 'mkpart primary ext3 2M -1'
 
@@ -990,20 +1021,40 @@ preparechroot() {
   touch $CHROOT_VARIABLES
   chmod 600 $CHROOT_VARIABLES # make sure nobody except root can read it
   echo "# Configuration of ${PN}"                              > $CHROOT_VARIABLES
-  [ -n "$ARCH" ]          && echo "ARCH=$ARCH"                 >> $CHROOT_VARIABLES
-  [ -n "$GRUB" ]          && echo "GRUB=$GRUB"                 >> $CHROOT_VARIABLES
-  [ -n "$HOSTNAME" ]      && echo "HOSTNAME=$HOSTNAME"         >> $CHROOT_VARIABLES
-  [ -n "$INSTALL_NOTES" ] && echo "INSTALL_NOTES=$INSTALL_NOTES" >> $CHROOT_VARIABLES
-  [ -n "$ISODIR" ]        && echo "ISODIR=$ISO"                >> $CHROOT_VARIABLES
-  [ -n "$ISO" ]           && echo "ISO=$ISO"                   >> $CHROOT_VARIABLES
-  [ -n "$KEEP_SRC_LIST" ] && echo "KEEP_SRC_LIST=$KEEP_SRC_LIST" >> $CHROOT_VARIABLES
-  [ -n "$MIRROR" ]        && echo "MIRROR=$MIRROR"             >> $CHROOT_VARIABLES
-  [ -n "$PACKAGES" ]      && echo "PACKAGES=$PACKAGES"         >> $CHROOT_VARIABLES
-  [ -n "$RM_APTCACHE" ]   && echo "RM_APTCACHE=$RM_APTCACHE"   >> $CHROOT_VARIABLES
-  [ -n "$ROOTPASSWORD" ]  && echo "ROOTPASSWORD=$ROOTPASSWORD" >> $CHROOT_VARIABLES
+  [ -n "$ARCH" ]                && echo "ARCH=$ARCH"                               >> $CHROOT_VARIABLES
+  [ -n "$CHROOT_SCRIPTS" ]      && echo "CHROOT_SCRIPTS=$CHROOT_SCRIPTS"           >> $CHROOT_VARIABLES
+  [ -n "$CONFFILES" ]           && echo "CONFFILES=$CONFFILES"                     >> $CHROOT_VARIABLES
+  [ -n "$DEBCONF" ]             && echo "DEBCONF=$DEBCONF"                         >> $CHROOT_VARIABLES
+  [ -n "$DEBIAN_FRONTEND" ]     && echo "DEBIAN_FRONTEND=$DEBIAN_FRONTEND"         >> $CHROOT_VARIABLES
+  [ -n "$DEBOOTSTRAP" ]         && echo "DEBOOTSTRAP=$DEBOOTSTRAP"                 >> $CHROOT_VARIABLES
+  [ -n "$EXTRAPACKAGES" ]       && echo "EXTRAPACKAGES=$EXTRAPACKAGES"             >> $CHROOT_VARIABLES
+  [ -n "$FORCE" ]               && echo "FORCE=$FORCE"                             >> $CHROOT_VARIABLES
+  [ -n "$GRMLREPOS" ]           && echo "GRMLREPOS=$GRMLREPOS"                     >> $CHROOT_VARIABLES
+  [ -n "$GRUB" ]                && echo "GRUB=$GRUB"                               >> $CHROOT_VARIABLES
+  [ -n "$HOSTNAME" ]            && echo "HOSTNAME=$HOSTNAME"                       >> $CHROOT_VARIABLES
+  [ -n "$INITRD" ]              && echo "INITRD=$INITRD"                           >> $CHROOT_VARIABLES
+  [ -n "$INSTALL_NOTES" ]       && echo "INSTALL_NOTES=$INSTALL_NOTES"             >> $CHROOT_VARIABLES
+  [ -n "$ISODIR" ]              && echo "ISODIR=$ISO"                              >> $CHROOT_VARIABLES
+  [ -n "$ISO" ]                 && echo "ISO=$ISO"                                 >> $CHROOT_VARIABLES
+  [ -n "$KEEP_SRC_LIST" ]       && echo "KEEP_SRC_LIST=$KEEP_SRC_LIST"             >> $CHROOT_VARIABLES
+  [ -n "$LOCALES" ]             && echo "LOCALES=$LOCALES"                         >> $CHROOT_VARIABLES
+  [ -n "$MIRROR" ]              && echo "MIRROR=$MIRROR"                           >> $CHROOT_VARIABLES
+  [ -n "$MKFS" ]                && echo "MKFS=$MKFS"                               >> $CHROOT_VARIABLES
+  [ -n "$NOPASSWORD" ]          && echo "NOPASSWORD=true"                          >> $CHROOT_VARIABLES
+  [ -n "$PACKAGES" ]            && echo "PACKAGES=$PACKAGES"                       >> $CHROOT_VARIABLES
+  [ -n "$PRE_SCRIPTS" ]         && echo "PRE_SCRIPTS=$PRE_SCRIPTS"                 >> $CHROOT_VARIABLES
+  [ -n "$RECONFIGURE" ]         && echo "RECONFIGURE=$RECONFIGURE"                 >> $CHROOT_VARIABLES
+  [ -n "$RELEASE" ]             && echo "RELEASE=$RELEASE"                         >> $CHROOT_VARIABLES
+  [ -n "$RM_APTCACHE" ]         && echo "RM_APTCACHE=$RM_APTCACHE"                 >> $CHROOT_VARIABLES
+  [ -n "$ROOTPASSWORD" ]        && echo "ROOTPASSWORD=$ROOTPASSWORD"               >> $CHROOT_VARIABLES
+  [ -n "$SCRIPTS" ]             && echo "SCRIPTS=$SCRIPTS"                         >> $CHROOT_VARIABLES
+  [ -n "$SECURE" ]              && echo "SECURE=$SECURE"                           >> $CHROOT_VARIABLES
   [ -n "$SELECTED_PARTITIONS" ] && echo "SELECTED_PARTITIONS=$SELECTED_PARTITIONS" >> $CHROOT_VARIABLES
-  [ -n "$TARGET" ]        && echo "TARGET=$TARGET"             >> $CHROOT_VARIABLES
-  [ -n "$TARGET_UUID" ]   && echo "TARGET_UUID=$TARGET_UUID"   >> $CHROOT_VARIABLES
+  [ -n "$TARGET" ]              && echo "TARGET=$TARGET"                           >> $CHROOT_VARIABLES
+  [ -n "$TARGET_UUID" ]         && echo "TARGET_UUID=$TARGET_UUID"                 >> $CHROOT_VARIABLES
+  [ -n "$TIMEZONE" ]            && echo "TIMEZONE=$TIMEZONE"                       >> $CHROOT_VARIABLES
+  [ -n "$TUNE2FS" ]             && echo "TUNE2FS=$TUNE2FS"                         >> $CHROOT_VARIABLES
+  [ -n "$VMSIZE" ]              && echo "VMSIZE=$VMSIZE"                           >> $CHROOT_VARIABLES
 
   cp $VERBOSE $CONFFILES/chroot-script $MNTPOINT/bin/chroot-script
   chmod 755 $MNTPOINT/bin/chroot-script
@@ -1159,12 +1210,17 @@ umount_chroot() {
 
 # execute filesystem check {{{
 fscktool() {
-  if [ "$FSCK" = 'yes' ] ; then
-     [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
-     einfo "Checking filesystem on $TARGET using $FSCKTOOL"
-     $FSCKTOOL $TARGET
-     eend $?
-  fi
+ if [ -n "$VIRTUAL" ] ; then
+   einfo "Skipping filesystem check since we deploy a virtual machine."
+   return 0
+ fi
+
+ if [ "$FSCK" = 'yes' ] ; then
+   [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
+   einfo "Checking filesystem on $TARGET using $FSCKTOOL"
+   $FSCKTOOL $TARGET
+   eend $?
+ fi
 }
 # }}}
 
@@ -1202,4 +1258,4 @@ fi
 # }}}
 
 ## END OF FILE #################################################################
-# vim: ai tw=100 expandtab foldmethod=marker shiftwidth=3
+# vim: ai tw=100 expandtab foldmethod=marker shiftwidth=2