From: dlezcano Date: Mon, 16 Feb 2009 10:11:03 +0000 (+0000) Subject: Remove some pointless debian services X-Git-Tag: lxc_0_6_0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c952d1b9156ca3aecd74a3a7bde4b55a81641afe;p=thirdparty%2Flxc.git Remove some pointless debian services From: Daniel Lezcano Remove some debian services because they don't have sense in a container, like the hw clock or the unmount of the file systems. Signed-off-by: Daniel Lezcano --- diff --git a/scripts/lxc-debian.in b/scripts/lxc-debian.in index eba5ffc85..f0d57620b 100755 --- a/scripts/lxc-debian.in +++ b/scripts/lxc-debian.in @@ -16,6 +16,7 @@ INITTAB="/etc/inittab" HOSTNAME="/etc/hostname" FSTAB="/etc/fstab" SSHD_CONFIG="/etc/ssh/sshd_config" +PROFILE="/etc/profile" ################################################################################ # debian custom configuration files @@ -24,7 +25,7 @@ SSHD_CONFIG="/etc/ssh/sshd_config" # custom selinux write_debian_selinux() { - mkdir $ROOTFS/selinux + mkdir -p $ROOTFS/selinux echo 0 > $ROOTFS/selinux/enforce } @@ -107,6 +108,17 @@ ChallengeResponseAuthentication no EOF } +reconfigure_debian_packages() { + chroot $ROOTFS /usr/sbin/dpkg-reconfigure locales +} + +disable_debian_services() { + chroot $ROOTFS /usr/sbin/update-rc.d -f umountfs remove + chroot $ROOTFS /usr/sbin/update-rc.d -f hwclock.sh remove + chroot $ROOTFS /usr/sbin/update-rc.d -f hwclockfirst.sh remove +} + + ################################################################################ # lxc configuration files ################################################################################ @@ -147,8 +159,7 @@ cat < $MNTFILE EOF } -create() { - +collect_information() { # choose a container name, default is 'debian' echo -n "What is the name for the container ? [$NAME] " read _NAME_ @@ -184,9 +195,18 @@ create() { GATEWAY=$_GATEWAY_ fi - # the rootfs name will be build with the container name ROOTFS="./rootfs.$NAME" + # choose the rootfs + echo -n "Specify the location of the rootfs [$ROOTFS] " + read _ROOTFS_ + + if [ ! -z "$_ROOTFS_" ]; then + ROOTFS=$_ROOTFS_ + fi +} +install_debian() +{ # check if the rootfs does already exist if [ ! -e "$ROOTFS" ]; then mkdir -p @LOCALSTATEDIR@/lock/subsys/ @@ -217,7 +237,7 @@ create() { # download a mini debian into a cache echo "Downloading debian minimal ..." debootstrap --verbose --variant=minbase --arch=$ARCH \ - --include ifupdown,apache2,netbase,net-tools,iproute,openssh-server \ + --include ifupdown,locales,libui-dialog-perl,dialog,apache2,netbase,net-tools,iproute,openssh-server \ lenny $CACHE/partial-$ARCH http://ftp.debian.org/debian RESULT=$? @@ -237,36 +257,48 @@ create() { ) 200> "@LOCALSTATEDIR@/lock/subsys/lxc" fi -write_lxc_mounts +} + +create() { + + collect_information + + install_debian -write_lxc_configuration + write_lxc_mounts -write_debian_inittab + write_lxc_configuration -write_debian_hostname + write_debian_inittab -write_debian_fstab + write_debian_hostname -write_debian_network + write_debian_fstab -write_debian_sshd_config + write_debian_network -write_debian_selinux + write_debian_sshd_config -@BINDIR@/lxc-create -n $NAME -f $CONFFILE -RES=$? + write_debian_selinux -# remove the configuration files -rm -f $CONFFILE -rm -f $MNTFILE + reconfigure_debian_packages -if [ "$RES" != "0" ]; then - echo "Failed to create '$NAME'" - exit 1 -fi + disable_debian_services + + @BINDIR@/lxc-create -n $NAME -f $CONFFILE + RES=$? + + # remove the configuration files + rm -f $CONFFILE + rm -f $MNTFILE + + if [ "$RES" != "0" ]; then + echo "Failed to create '$NAME'" + exit 1 + fi -echo "Done." -echo -e "\nYou can run your container with the 'lxc-start -n $NAME'\n" + echo "Done." + echo -e "\nYou can run your container with the 'lxc-start -n $NAME'\n" } destroy() {