lxc-plamo.in revision 207bf0e475f1dc6e9a2dac2cee3a209b56427855
# template script for generating Plamo Linux container for LXC # lxc: linux Container library # KATOH Yasufumi <karma@jazz.email.ne.jp> # TAMUKI Shoichi <tamuki@linet.gr.jp> # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Detect use under userns (unsupported) [
"$arg" ==
"--" ] &&
break if [
"$arg" ==
"--mapped-uid" -o
"$arg" ==
"--mapped-gid" ];
then echo "This template can't be used for unprivileged containers." 1>&
2 echo "You may want to try the \"download\" template instead." 1>&
2 # Make sure the usual locations are in PATH cpufreqd cpufrequtils gpm"}
# check the mini plamo was not already downloaded echo "Failed to create '$ptcache' directory." # download a mini plamo into a cache echo "Downloading Plamo-$release minimal..." echo "Failed to download the rootfs, aborting." echo "Failed to download the rootfs, aborting." echo "Failed to download the rootfs, aborting." echo "Download complete." # make a local copy of the mini plamo echo "Cache repository is busy." echo "Checking cache download in $dlcache..." echo "Failed to download plamo $release base packages." echo "'installpkg' command is missing." echo "Installing 'installpkg' command into $dlcache/sbin..." echo "Installing packages to $rtcache..." echo "Failed to copy rootfs." # suppress log level output for udev < # What to do when power fails (shutdown to single user). > # What to do when power fails (shutdown). # configure the network using the dhcp echo "Setting root password to 'root'..." echo "Please change root password!" cat <<- EOF >> /tmp/netconfig.rconly RC=$rootfs/etc/rc.d/rc.inet1.tradnet INET1SCHEME=var/run/inet1-scheme rm -f $rootfs/etc/rc.d/rc.inet1.tradnet rm -f /tmp/netconfig.rconly cat <<- EOF >> $path/config || let ret++ if [ -f "@LXCTEMPLATECONFIG@/plamo.common.conf" ] ; then cat <<- "EOF" >> $path/config || let ret++ lxc.include = @LXCTEMPLATECONFIG@/plamo.common.conf # create the fstab (empty by default) touch $path/fstab || let ret++ echo "Failed to add configuration." # nothing do in Plamo Linux # bind-mount the user's path into the container's /home h=`getent passwd $bindhome | cut -d: -f6` echo "$h $rootfs/$h none bind 0 0" >> $path/fstab # copy /etc/passwd, /etc/shadow, and /etc/group entries into container if ! pwd=`getent passwd $bindhome` ; then echo "Warning: failed to copy password entry for $bindhome." echo $pwd >> $rootfs/etc/passwd echo `getent shadow $bindhome` >> $rootfs/etc/shadow [ -d $dlcache -a -d $rtcache ] || return 0 # lock, so we won't purge while someone is creating a repository echo "Cache repository is busy." echo "Purging the download cache..." rm -rf --one-file-system $dlcache $rtcache || return 1 ) 200> @LOCALSTATEDIR@/lock/subsys/lxc-plamo $prog [-h|--help] -p|--path=<path> -n|--name=<name> --rootfs=<rootfs> [--clean] [-r|--release=<release>] [-b|--bindhome=<user>] bindhome: bind <user>'s home into the container arch: x86 or x86_64: defaults to host arch path="" ; name="" ; rootfs="" arch=`uname -m | sed 's/i.86/x86/'` ; hostarch=$arch lopts=help,path:,name:,rootfs:,clean,release:,bindhome:,arch: if ! options=`getopt -o $sopts -l $lopts -- "$@"` ; then -h|--help) usage && exit 0 ;; -p|--path) path=$2 ; shift 2 ;; -n|--name) name=$2 ; shift 2 ;; --rootfs) rootfs=$2 ; shift 2 ;; -c|--clean) clean=1 ; shift 1 ;; -r|--release) release=$2 ; shift 2 ;; -b|--bindhome) bindhome=$2 ; shift 2 ;; -a|--arch) arch=$2 ; shift 2 ;; if [ $clean -eq 1 -a -z "$path" ] ; then if [ $hostarch == "x86" -a $arch == "x86_64" ] ; then echo "Can't create x86_64 container on x86." echo "'path' parameter is required." echo "'name' parameter is required." if [ `id -u` -ne 0 ] ; then echo "This script should be run as 'root'." cache=@LOCALSTATEDIR@/cache/lxc ptcache=$cache/partial-${prog##*-}-$release-$arch dlcache=$cache/cache-${prog##*-}-$release-$arch rtcache=$cache/rootfs-${prog##*-}-$release-$arch if [ -z "$rootfs" ] ; then if grep -q "^lxc.rootfs" $path/config ; then rootfs=`awk -F= '/^lxc.rootfs =/{ print $2 }' $path/config` if ! install_plamo ; then echo "Failed to install plamo $release." if ! configure_plamo ; then echo "Failed to configure plamo $release for a container." if ! copy_configuration ; then echo "Failed to write configuration file." if [ -n "$bindhome" ] ; then if [ $clean -eq 1 ] ; then