Remove bindhome support from quantal 64 lxc template
This commit is contained in:
parent
bd05b44647
commit
7f7e3d8a51
1 changed files with 7 additions and 69 deletions
|
@ -78,10 +78,8 @@ EOF
|
||||||
rm -f $rootfs/etc/init/tty{5,6}.conf
|
rm -f $rootfs/etc/init/tty{5,6}.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$bindhome" ]; then
|
chroot $rootfs useradd --create-home -s /bin/bash vagrant
|
||||||
chroot $rootfs useradd --create-home -s /bin/bash vagrant
|
echo "vagrant:vagrant" | chroot $rootfs chpasswd
|
||||||
echo "vagrant:vagrant" | chroot $rootfs chpasswd
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -526,61 +524,20 @@ post_process()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_bindhome()
|
|
||||||
{
|
|
||||||
rootfs=$1
|
|
||||||
user=$2
|
|
||||||
|
|
||||||
# copy /etc/passwd, /etc/shadow, and /etc/group entries into container
|
|
||||||
pwd=`getent passwd $user` || { echo "Failed to copy password entry for $user"; false; }
|
|
||||||
echo $pwd >> $rootfs/etc/passwd
|
|
||||||
|
|
||||||
# make sure user's shell exists in the container
|
|
||||||
shell=`echo $pwd | cut -d: -f 7`
|
|
||||||
if [ ! -x $rootfs/$shell ]; then
|
|
||||||
echo "shell $shell for user $user was not found in the container."
|
|
||||||
pkg=`dpkg -S $(readlink -m $shell) | cut -d ':' -f1`
|
|
||||||
echo "Installing $pkg"
|
|
||||||
chroot $rootfs apt-get --force-yes -y install $pkg
|
|
||||||
fi
|
|
||||||
|
|
||||||
shad=`getent shadow $user`
|
|
||||||
echo "$shad" >> $rootfs/etc/shadow
|
|
||||||
|
|
||||||
# bind-mount the user's path into the container's /home
|
|
||||||
h=`getent passwd $user | cut -d: -f 6`
|
|
||||||
mkdir -p $rootfs/$h
|
|
||||||
|
|
||||||
# use relative path in container
|
|
||||||
h2=${h#/}
|
|
||||||
while [ ${h2:0:1} = "/" ]; do
|
|
||||||
h2=${h2#/}
|
|
||||||
done
|
|
||||||
echo "$h $h2 none bind 0 0" >> $path/fstab
|
|
||||||
|
|
||||||
# Make sure the group exists in container
|
|
||||||
grp=`echo $pwd | cut -d: -f 4` # group number for $user
|
|
||||||
grpe=`getent group $grp` || return 0 # if host doesn't define grp, ignore in container
|
|
||||||
chroot $rootfs getent group "$grpe" || echo "$grpe" >> $rootfs/etc/group
|
|
||||||
}
|
|
||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
$1 -h|--help [-a|--arch] [-b|--bindhome <user>] [--trim] [-d|--debug]
|
$1 -h|--help [-a|--arch] [--trim] [-d|--debug]
|
||||||
[-F | --flush-cache] [-r|--release <release>] [ -S | --auth-key <keyfile>]
|
[-F | --flush-cache] [-r|--release <release>] [ -S | --auth-key <keyfile>]
|
||||||
release: the ubuntu release (e.g. precise): defaults to host release on ubuntu, otherwise uses latest LTS
|
release: the ubuntu release (e.g. precise): defaults to host release on ubuntu, otherwise uses latest LTS
|
||||||
trim: make a minimal (faster, but not upgrade-safe) container
|
trim: make a minimal (faster, but not upgrade-safe) container
|
||||||
bindhome: bind <user>'s home into the container
|
|
||||||
The ubuntu user will not be created, and <user> will have
|
|
||||||
sudo access.
|
|
||||||
arch: the container architecture (e.g. amd64): defaults to host arch
|
arch: the container architecture (e.g. amd64): defaults to host arch
|
||||||
auth-key: SSH Public key file to inject into container
|
auth-key: SSH Public key file to inject into container
|
||||||
EOF
|
EOF
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
options=$(getopt -o a:b:hp:r:xn:FS:d -l arch:,bindhome:,help,path:,release:,trim,name:,flush-cache,auth-key:,debug -- "$@")
|
options=$(getopt -o a:b:hp:r:xn:FS:d -l arch:,help,path:,release:,trim,name:,flush-cache,auth-key:,debug -- "$@")
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
usage $(basename $0)
|
usage $(basename $0)
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -595,7 +552,6 @@ if [ -f /etc/lsb-release ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bindhome=
|
|
||||||
arch=$(arch)
|
arch=$(arch)
|
||||||
|
|
||||||
# Code taken from debootstrap
|
# Code taken from debootstrap
|
||||||
|
@ -626,7 +582,6 @@ do
|
||||||
-n|--name) name=$2; shift 2;;
|
-n|--name) name=$2; shift 2;;
|
||||||
-F|--flush-cache) flushcache=1; shift 1;;
|
-F|--flush-cache) flushcache=1; shift 1;;
|
||||||
-r|--release) release=$2; shift 2;;
|
-r|--release) release=$2; shift 2;;
|
||||||
-b|--bindhome) bindhome=$2; shift 2;;
|
|
||||||
-a|--arch) arch=$2; shift 2;;
|
-a|--arch) arch=$2; shift 2;;
|
||||||
-x|--trim) trim_container=1; shift 1;;
|
-x|--trim) trim_container=1; shift 1;;
|
||||||
-S|--auth-key) auth_key=$2; shift 2;;
|
-S|--auth-key) auth_key=$2; shift 2;;
|
||||||
|
@ -640,14 +595,6 @@ if [ $debug -eq 1 ]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$bindhome" ]; then
|
|
||||||
pwd=`getent passwd $bindhome`
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error: no password entry found for $bindhome"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$arch" == "i686" ]; then
|
if [ "$arch" == "i686" ]; then
|
||||||
arch=i386
|
arch=i386
|
||||||
|
@ -702,20 +649,11 @@ fi
|
||||||
|
|
||||||
post_process $rootfs $release $trim_container
|
post_process $rootfs $release $trim_container
|
||||||
|
|
||||||
if [ -n "$bindhome" ]; then
|
finalize_user vagrant
|
||||||
do_bindhome $rootfs $bindhome
|
|
||||||
finalize_user $bindhome
|
|
||||||
else
|
|
||||||
finalize_user vagrant
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "##"
|
echo "##"
|
||||||
if [ -n "$bindhome" ]; then
|
echo "# The default user is 'vagrant' with password 'vagrant'!"
|
||||||
echo "# Log in as user $bindhome"
|
echo "# Use the 'sudo' command to run tasks as root in the container."
|
||||||
else
|
|
||||||
echo "# The default user is 'vagrant' with password 'vagrant'!"
|
|
||||||
echo "# Use the 'sudo' command to run tasks as root in the container."
|
|
||||||
fi
|
|
||||||
echo "##"
|
echo "##"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
Loading…
Add table
Reference in a new issue