Commit c952d1b9 by dlezcano

Remove some pointless debian services

From: Daniel Lezcano <daniel.lezcano@free.fr> 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: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 341a091c
...@@ -16,6 +16,7 @@ INITTAB="/etc/inittab" ...@@ -16,6 +16,7 @@ INITTAB="/etc/inittab"
HOSTNAME="/etc/hostname" HOSTNAME="/etc/hostname"
FSTAB="/etc/fstab" FSTAB="/etc/fstab"
SSHD_CONFIG="/etc/ssh/sshd_config" SSHD_CONFIG="/etc/ssh/sshd_config"
PROFILE="/etc/profile"
################################################################################ ################################################################################
# debian custom configuration files # debian custom configuration files
...@@ -24,7 +25,7 @@ SSHD_CONFIG="/etc/ssh/sshd_config" ...@@ -24,7 +25,7 @@ SSHD_CONFIG="/etc/ssh/sshd_config"
# custom selinux # custom selinux
write_debian_selinux() { write_debian_selinux() {
mkdir $ROOTFS/selinux mkdir -p $ROOTFS/selinux
echo 0 > $ROOTFS/selinux/enforce echo 0 > $ROOTFS/selinux/enforce
} }
...@@ -107,6 +108,17 @@ ChallengeResponseAuthentication no ...@@ -107,6 +108,17 @@ ChallengeResponseAuthentication no
EOF 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 # lxc configuration files
################################################################################ ################################################################################
...@@ -147,8 +159,7 @@ cat <<EOF > $MNTFILE ...@@ -147,8 +159,7 @@ cat <<EOF > $MNTFILE
EOF EOF
} }
create() { collect_information() {
# choose a container name, default is 'debian' # choose a container name, default is 'debian'
echo -n "What is the name for the container ? [$NAME] " echo -n "What is the name for the container ? [$NAME] "
read _NAME_ read _NAME_
...@@ -184,9 +195,18 @@ create() { ...@@ -184,9 +195,18 @@ create() {
GATEWAY=$_GATEWAY_ GATEWAY=$_GATEWAY_
fi fi
# the rootfs name will be build with the container name
ROOTFS="./rootfs.$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 # check if the rootfs does already exist
if [ ! -e "$ROOTFS" ]; then if [ ! -e "$ROOTFS" ]; then
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
...@@ -217,7 +237,7 @@ create() { ...@@ -217,7 +237,7 @@ create() {
# download a mini debian into a cache # download a mini debian into a cache
echo "Downloading debian minimal ..." echo "Downloading debian minimal ..."
debootstrap --verbose --variant=minbase --arch=$ARCH \ 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 lenny $CACHE/partial-$ARCH http://ftp.debian.org/debian
RESULT=$? RESULT=$?
...@@ -237,36 +257,48 @@ create() { ...@@ -237,36 +257,48 @@ create() {
) 200> "@LOCALSTATEDIR@/lock/subsys/lxc" ) 200> "@LOCALSTATEDIR@/lock/subsys/lxc"
fi 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 write_debian_selinux
RES=$?
# remove the configuration files reconfigure_debian_packages
rm -f $CONFFILE
rm -f $MNTFILE
if [ "$RES" != "0" ]; then disable_debian_services
echo "Failed to create '$NAME'"
exit 1 @BINDIR@/lxc-create -n $NAME -f $CONFFILE
fi 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 "Done."
echo -e "\nYou can run your container with the 'lxc-start -n $NAME'\n" echo -e "\nYou can run your container with the 'lxc-start -n $NAME'\n"
} }
destroy() { destroy() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment