diff --git a/templates/lxc-altlinux.in b/templates/lxc-altlinux.in index d526fa0..b3747c5 100644 --- a/templates/lxc-altlinux.in +++ b/templates/lxc-altlinux.in @@ -196,8 +196,8 @@ download_altlinux() # some scripts want to have /dev/null at least dev_path="$INSTALL_ROOT/dev" if [ ! -c "${dev_path}/null" ]; then - mkdir -p "${dev_path}" - mknod -m 666 "${dev_path}/null" c 1 3 + mkdir -p "${dev_path}" + mknod -m 666 "${dev_path}/null" c 1 3 fi $APT_GET install $PKG_LIST diff --git a/templates/lxc-centos.in b/templates/lxc-centos.in index eba5ec8..deccfe5 100644 --- a/templates/lxc-centos.in +++ b/templates/lxc-centos.in @@ -389,8 +389,8 @@ configure_centos_init() chroot ${rootfs_path} chkconfig network on if [ "$release" = "7" ]; then - # don't wait for the timeout - chroot ${rootfs_path} chkconfig systemd-remount-fs off + # don't wait for the timeout + chroot ${rootfs_path} chkconfig systemd-remount-fs off fi if [ -d ${rootfs_path}/etc/init ] @@ -435,13 +435,13 @@ download_centos() REPO_FILE=$INSTALL_ROOT/etc/yum.repos.d/lxc-centos-temp.repo mkdir -p $(dirname $REPO_FILE) if [ -n "$repo" ]; then - cat < $REPO_FILE + cat < $REPO_FILE [base] name=local repository baseurl="$repo" EOF elif [ ${basearch} = 'i386' ] || [ ${basearch} = 'x86_64' ]; then - cat < $REPO_FILE + cat < $REPO_FILE [base] name=CentOS-$release - Base mirrorlist=http://mirrorlist.centos.org/?release=$release&arch=$basearch&repo=os @@ -451,7 +451,7 @@ name=CentOS-$release - Updates mirrorlist=http://mirrorlist.centos.org/?release=$release&arch=$basearch&repo=updates EOF else - cat < $REPO_FILE + cat < $REPO_FILE [base] name=CentOS-$release - Base baseurl=http://mirror.centos.org/altarch/7/os/$basearch/ diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in index 5769b39..d446a84 100644 --- a/templates/lxc-debian.in +++ b/templates/lxc-debian.in @@ -797,14 +797,14 @@ fi if [ -n "$authkey" ]; then if [ ! -f "$authkey" ]; then - echo "SSH keyfile '$authkey' not found" - exit 1 + echo "SSH keyfile '$authkey' not found" + exit 1 fi # This is mostly to prevent accidental uage of the private key instead # of the public key. if [ "${authkey: -4}" != ".pub" ]; then - echo "SSH keyfile '$authkey' does not end with '.pub'" - exit 1 + echo "SSH keyfile '$authkey' does not end with '.pub'" + exit 1 fi fi @@ -812,8 +812,8 @@ release=${release:-stable} permanent_releases=('stable' 'testing' 'sid' 'unstable') if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then if ! wget "${MIRROR}/dists/${release}/Release" -O /dev/null 2> /dev/null; then - echo "Invalid release ${release} (not found in mirror)" - exit 1 + echo "Invalid release ${release} (not found in mirror)" + exit 1 fi fi diff --git a/templates/lxc-devuan.in b/templates/lxc-devuan.in index 76ed315..408a93e 100644 --- a/templates/lxc-devuan.in +++ b/templates/lxc-devuan.in @@ -743,14 +743,14 @@ fi if [ -n "$authkey" ]; then if [ ! -f "$authkey" ]; then - echo "SSH keyfile '$authkey' not found" - exit 1 + echo "SSH keyfile '$authkey' not found" + exit 1 fi # This is mostly to prevent accidental uage of the private key instead # of the public key. if [ "${authkey: -4}" != ".pub" ]; then - echo "SSH keyfile '$authkey' does not end with '.pub'" - exit 1 + echo "SSH keyfile '$authkey' does not end with '.pub'" + exit 1 fi fi @@ -758,8 +758,8 @@ release=${release:-stable} permanent_releases=('stable' 'testing' 'ceres' 'unstable') if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then if ! wget "${MIRROR}/dists/${release}/Release" -O /dev/null 2> /dev/null; then - echo "Invalid release ${release} (not found in mirror)" - exit 1 + echo "Invalid release ${release} (not found in mirror)" + exit 1 fi fi diff --git a/templates/lxc-gentoo.in b/templates/lxc-gentoo.in index 950f17c..7e07188 100644 --- a/templates/lxc-gentoo.in +++ b/templates/lxc-gentoo.in @@ -455,7 +455,7 @@ container_portage() printf "trying to guess portage distfiles dir from host ...\n" portage_distfiles_dir="$(portageq distdir 2>/dev/null)" if [ ! -d "${portage_distfiles_dir}" ]; then - portage_distfiles_dir="${portage_dir}/distfiles" + portage_distfiles_dir="${portage_dir}/distfiles" fi # if we are here, we have shared portage_dir diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in index 0aca315..402ec9f 100644 --- a/templates/lxc-kali.in +++ b/templates/lxc-kali.in @@ -746,14 +746,14 @@ fi if [ -n "$authkey" ]; then if [ ! -f "$authkey" ]; then - echo "SSH keyfile '$authkey' not found" - exit 1 + echo "SSH keyfile '$authkey' not found" + exit 1 fi # This is mostly to prevent accidental uage of the private key instead # of the public key. if [ "${authkey: -4}" != ".pub" ]; then - echo "SSH keyfile '$authkey' does not end with '.pub'" - exit 1 + echo "SSH keyfile '$authkey' does not end with '.pub'" + exit 1 fi fi diff --git a/templates/lxc-openmandriva.in b/templates/lxc-openmandriva.in index 2761cd5..a90717e 100644 --- a/templates/lxc-openmandriva.in +++ b/templates/lxc-openmandriva.in @@ -178,7 +178,7 @@ configure_openmandriva_systemd() unlink ${rootfs_path}/etc/systemd/system/default.target chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target sed -i 's!ConditionPathExists=/dev/tty0!ConditionPathExists=|/dev/tty0\nConditionVirtualization=|lxc!' \ - ${rootfs_path}/lib/systemd/system/getty\@.service + ${rootfs_path}/lib/systemd/system/getty\@.service } diff --git a/templates/lxc-opensuse.in b/templates/lxc-opensuse.in index 232e467..9faeca7 100644 --- a/templates/lxc-opensuse.in +++ b/templates/lxc-opensuse.in @@ -453,8 +453,8 @@ fi if grep -q Harlequin /etc/os-release || grep -q Tumbleweed /etc/os-release ; then BVER=`rpm -q --qf '%{version}\n' build` if [ $? -ne 0 -o "$BVER" -lt "20141120" ]; then - echo "Building openSUSE containers with your version of the build package is broken. Please install the update to version 20141120 or newer." - exit 1 + echo "Building openSUSE containers with your version of the build package is broken. Please install the update to version 20141120 or newer." + exit 1 fi fi @@ -465,43 +465,43 @@ if [ -z "$DISTRO" ]; then else echo "" case "$DISTRO" in - 13.1) - echo "Selected openSUSE 13.1" - ;; + 13.1) + echo "Selected openSUSE 13.1" + ;; - 13.2) - echo "Selected openSUSE 13.2" - ;; + 13.2) + echo "Selected openSUSE 13.2" + ;; - 42.1|leap/42.1|421) - echo "Selected openSUSE Leap 42.1" - DISTRO="leap/42.1" - ;; + 42.1|leap/42.1|421) + echo "Selected openSUSE Leap 42.1" + DISTRO="leap/42.1" + ;; - 42.2|leap/42.2|422) - echo "Selected openSUSE Leap 42.2" - DISTRO="leap/42.2" - ;; + 42.2|leap/42.2|422) + echo "Selected openSUSE Leap 42.2" + DISTRO="leap/42.2" + ;; - 42.3|leap/42.3|423) - echo "Selected openSUSE Leap 42.3" - DISTRO="leap/42.3" - ;; + 42.3|leap/42.3|423) + echo "Selected openSUSE Leap 42.3" + DISTRO="leap/42.3" + ;; - 15.0|leap/15.0|150|leap) - echo "Selected openSUSE Leap 15.0" - DISTRO="leap/15.0" - ;; + 15.0|leap/15.0|150|leap) + echo "Selected openSUSE Leap 15.0" + DISTRO="leap/15.0" + ;; - tumbleweed|factory) - echo "Selected openSUSE Leap Tumbleweed" - DISTRO="tumbleweed" - ;; + tumbleweed|factory) + echo "Selected openSUSE Leap Tumbleweed" + DISTRO="tumbleweed" + ;; - *) - echo "You have chosen an invalid release, quitting..." - exit 1 - ;; + *) + echo "You have chosen an invalid release, quitting..." + exit 1 + ;; esac fi diff --git a/templates/lxc-oracle.in b/templates/lxc-oracle.in index afb6902..44a441b 100644 --- a/templates/lxc-oracle.in +++ b/templates/lxc-oracle.in @@ -148,21 +148,21 @@ EOF # with newer systemd (OL7.2), getty service include container-getty.service # let that be the one who manage the getty service instead if [ ! -f $container_rootfs/usr/lib/systemd/system/container-getty@.service ]; then - # from mhw in the fedora template: We do need to disable the - # "ConditionalPathExists=/dev/tty0" line or no gettys are started on - # the ttys in the container. Lets do it in an override copy of the - # service so it can still pass rpm verifies and not be automatically - # updated by a new systemd version. - sed -e 's/^ConditionPathExists=/#LXC ConditionPathExists=/' \ - < $container_rootfs/usr/lib/systemd/system/getty\@.service \ - > $container_rootfs/etc/systemd/system/getty\@.service - # Setup getty service on the 4 ttys we are going to allow in the - # default config. Number should match lxc.tty - ( cd $container_rootfs/etc/systemd/system/getty.target.wants - for i in 1 2 3 4 ; do ln -sf ../getty\@.service getty@tty${i}.service; done ) - # We only want to spawn a getty on /dev/console in lxc, libvirt-lxc - # symlinks /dev/console to /dev/tty1 - sed -i '/Before=getty.target/a ConditionVirtualization=lxc' $container_rootfs/usr/lib/systemd/system/console-getty.service + # from mhw in the fedora template: We do need to disable the + # "ConditionalPathExists=/dev/tty0" line or no gettys are started on + # the ttys in the container. Lets do it in an override copy of the + # service so it can still pass rpm verifies and not be automatically + # updated by a new systemd version. + sed -e 's/^ConditionPathExists=/#LXC ConditionPathExists=/' \ + < $container_rootfs/usr/lib/systemd/system/getty\@.service \ + > $container_rootfs/etc/systemd/system/getty\@.service + # Setup getty service on the 4 ttys we are going to allow in the + # default config. Number should match lxc.tty + ( cd $container_rootfs/etc/systemd/system/getty.target.wants + for i in 1 2 3 4 ; do ln -sf ../getty\@.service getty@tty${i}.service; done ) + # We only want to spawn a getty on /dev/console in lxc, libvirt-lxc + # symlinks /dev/console to /dev/tty1 + sed -i '/Before=getty.target/a ConditionVirtualization=lxc' $container_rootfs/usr/lib/systemd/system/console-getty.service fi # disable some systemd services, set default boot, sigpwr target @@ -307,9 +307,9 @@ EOF # some of these might not exist in the image, so we silence chkconfig complaining # about the service file not being found for service in \ - acpid apmd auditd autofs cpuspeed dund gpm haldaemon hidd \ - ip6tables irqbalance iscsi iscsid isdn kdump kudzu \ - lm_sensors lvm2-monitor mdmonitor microcode_ctl \ + acpid apmd auditd autofs cpuspeed dund gpm haldaemon hidd \ + ip6tables irqbalance iscsi iscsid isdn kdump kudzu \ + lm_sensors lvm2-monitor mdmonitor microcode_ctl \ ntpd pcmcia postfix sendmail udev-post xfs ; do chroot $container_rootfs chkconfig 2>/dev/null $service off @@ -363,13 +363,13 @@ EOF # allow root login on console, tty[1-4], and pts/0 for libvirt echo "# LXC (Linux Containers)" >>$container_rootfs/etc/securetty - echo "lxc/console" >>$container_rootfs/etc/securetty + echo "lxc/console" >>$container_rootfs/etc/securetty for i in 1 2 3 4; do - echo "lxc/tty$i" >>$container_rootfs/etc/securetty + echo "lxc/tty$i" >>$container_rootfs/etc/securetty done echo "# For libvirt/Virtual Machine Monitor" >>$container_rootfs/etc/securetty for i in 0 1 2 3 4; do - echo "pts/$i" >>$container_rootfs/etc/securetty + echo "pts/$i" >>$container_rootfs/etc/securetty done # prevent mingetty from calling vhangup(2) since it fails with userns @@ -511,7 +511,7 @@ EOF lxc_network_hwaddr=`grep '^lxc.net.0.hwaddr' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` if [ -z "$lxc_network_hwaddr" ]; then - # generate a hwaddr for the container + # generate a hwaddr for the container # see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303 local hwaddr="00:16:3e:`dd if=/dev/urandom bs=8 count=1 2>/dev/null |od -t x8 | \ head -n1 | awk '{print $2}' | cut -c1-6 | \ @@ -850,19 +850,19 @@ eval set -- "$options" while true do case "$1" in - -h|--help) usage $0 && exit 0;; - -p|--path) cfg_dir=$2; shift 2;; - --rootfs) container_rootfs=$2; shift 2;; - -n|--name) name=$2; shift 2;; - -a|--arch) arch=$2; shift 2;; - -R|--release) container_release_version=$2; shift 2;; - -r|--rpms) user_pkgs=$2; shift 2;; - -u|--url) repourl=$2; shift 2;; - -t|--templatefs) template_rootfs=$2; shift 2;; - --patch) patch_rootfs=$2; shift 2;; - --baseurl) baseurl=$2; shift 2;; - --) shift 1; break ;; - *) break ;; + -h|--help) usage $0 && exit 0;; + -p|--path) cfg_dir=$2; shift 2;; + --rootfs) container_rootfs=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -a|--arch) arch=$2; shift 2;; + -R|--release) container_release_version=$2; shift 2;; + -r|--rpms) user_pkgs=$2; shift 2;; + -u|--url) repourl=$2; shift 2;; + -t|--templatefs) template_rootfs=$2; shift 2;; + --patch) patch_rootfs=$2; shift 2;; + --baseurl) baseurl=$2; shift 2;; + --) shift 1; break ;; + *) break ;; esac done diff --git a/templates/lxc-pld.in b/templates/lxc-pld.in index b748cb8..c7aa132 100644 --- a/templates/lxc-pld.in +++ b/templates/lxc-pld.in @@ -40,21 +40,21 @@ cache_base=@LOCALSTATEDIR@/cache/lxc/pld/$arch default_path=@LXCPATH@ if [ -e /etc/os-release ]; then - # This is a shell friendly configuration file. We can just source it. - # What we're looking for in here is the ID, VERSION_ID and the CPE_NAME - . /etc/os-release - echo "Host CPE ID from /etc/os-release: ${CPE_NAME}" + # This is a shell friendly configuration file. We can just source it. + # What we're looking for in here is the ID, VERSION_ID and the CPE_NAME + . /etc/os-release + echo "Host CPE ID from /etc/os-release: ${CPE_NAME}" fi if [ "${CPE_NAME}" != "" -a "${ID}" = "pld" -a "${VERSION_ID}" != "" ]; then - pld_host_ver=${VERSION_ID} - is_pld=true + pld_host_ver=${VERSION_ID} + is_pld=true elif [ -e /etc/pld-release ]; then - # Only if all other methods fail, try to parse the pld-release file. - pld_host_ver=$(sed -e '/PLD /!d' -e 's/^\([0-9.]*\)\sPLD.*/\1/' < /etc/pld-release) - if [ "$pld_host_ver" != "" ]; then - is_pld=true - fi + # Only if all other methods fail, try to parse the pld-release file. + pld_host_ver=$(sed -e '/PLD /!d' -e 's/^\([0-9.]*\)\sPLD.*/\1/' < /etc/pld-release) + if [ "$pld_host_ver" != "" ]; then + is_pld=true + fi fi # Map a few architectures to their generic PLD Linux repository archs. @@ -65,177 +65,177 @@ esac configure_pld() { - # disable selinux - mkdir -p $rootfs_path/selinux - echo 0 > $rootfs_path/selinux/enforce + # disable selinux + mkdir -p $rootfs_path/selinux + echo 0 > $rootfs_path/selinux/enforce - # configure the network using the dhcp - sed -i -e "s/^HOSTNAME=.*/HOSTNAME=${utsname}/" ${rootfs_path}/etc/sysconfig/network + # configure the network using the dhcp + sed -i -e "s/^HOSTNAME=.*/HOSTNAME=${utsname}/" ${rootfs_path}/etc/sysconfig/network - # set hostname on systemd - if [ $release = "3.0" ]; then - echo "${utsname}" > ${rootfs_path}/etc/hostname - fi + # set hostname on systemd + if [ $release = "3.0" ]; then + echo "${utsname}" > ${rootfs_path}/etc/hostname + fi - # set minimal hosts - test -e $rootfs_path/etc/hosts || \ - cat < $rootfs_path/etc/hosts + # set minimal hosts + test -e $rootfs_path/etc/hosts || \ + cat < $rootfs_path/etc/hosts 127.0.0.1 localhost.localdomain localhost $utsname ::1 localhost6.localdomain6 localhost6 EOF - dev_path="${rootfs_path}/dev" - rm -rf $dev_path - mkdir -p $dev_path - mknod -m 666 ${dev_path}/null c 1 3 - mknod -m 666 ${dev_path}/zero c 1 5 - mknod -m 666 ${dev_path}/random c 1 8 - mknod -m 666 ${dev_path}/urandom c 1 9 - mkdir -m 755 ${dev_path}/pts - mkdir -m 1777 ${dev_path}/shm - mknod -m 666 ${dev_path}/tty c 5 0 - mknod -m 666 ${dev_path}/tty0 c 4 0 - mknod -m 666 ${dev_path}/tty1 c 4 1 - mknod -m 666 ${dev_path}/tty2 c 4 2 - mknod -m 666 ${dev_path}/tty3 c 4 3 - mknod -m 666 ${dev_path}/tty4 c 4 4 - mknod -m 600 ${dev_path}/console c 5 1 - mknod -m 666 ${dev_path}/full c 1 7 - mknod -m 600 ${dev_path}/initctl p - mknod -m 666 ${dev_path}/ptmx c 5 2 + dev_path="${rootfs_path}/dev" + rm -rf $dev_path + mkdir -p $dev_path + mknod -m 666 ${dev_path}/null c 1 3 + mknod -m 666 ${dev_path}/zero c 1 5 + mknod -m 666 ${dev_path}/random c 1 8 + mknod -m 666 ${dev_path}/urandom c 1 9 + mkdir -m 755 ${dev_path}/pts + mkdir -m 1777 ${dev_path}/shm + mknod -m 666 ${dev_path}/tty c 5 0 + mknod -m 666 ${dev_path}/tty0 c 4 0 + mknod -m 666 ${dev_path}/tty1 c 4 1 + mknod -m 666 ${dev_path}/tty2 c 4 2 + mknod -m 666 ${dev_path}/tty3 c 4 3 + mknod -m 666 ${dev_path}/tty4 c 4 4 + mknod -m 600 ${dev_path}/console c 5 1 + mknod -m 666 ${dev_path}/full c 1 7 + mknod -m 600 ${dev_path}/initctl p + mknod -m 666 ${dev_path}/ptmx c 5 2 - if [ -n "${root_password}" ]; then - echo "setting root passwd to $root_password" - echo "root:$root_password" | chroot $rootfs_path chpasswd - fi + if [ -n "${root_password}" ]; then + echo "setting root passwd to $root_password" + echo "root:$root_password" | chroot $rootfs_path chpasswd + fi - return 0 + return 0 } configure_pld_init() { - # default powerfail action waits 2 minutes. for lxc we want it immediately - sed -i -e '/^pf::powerfail:/ s,/sbin/shutdown.*,/sbin/halt,' ${rootfs_path}/etc/inittab + # default powerfail action waits 2 minutes. for lxc we want it immediately + sed -i -e '/^pf::powerfail:/ s,/sbin/shutdown.*,/sbin/halt,' ${rootfs_path}/etc/inittab } configure_pld_systemd() { - unlink ${rootfs_path}/etc/systemd/system/default.target - chroot ${rootfs_path} ln -s /dev/null /etc/systemd/system/udev.service - chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target + unlink ${rootfs_path}/etc/systemd/system/default.target + chroot ${rootfs_path} ln -s /dev/null /etc/systemd/system/udev.service + chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target - # Actually, the After=dev-%i.device line does not appear in the - # Fedora 17 or Fedora 18 systemd getty@.service file. It may be left - # over from an earlier version and it's not doing any harm. We do need - # to disable the "ConditionalPathExists=/dev/tty0" line or no gettys are - # started on the ttys in the container. Lets do it in an override copy of - # the service so it can still pass rpm verifies and not be automatically - # updated by a new systemd version. -- mhw /\/\|=mhw=|\/\/ + # Actually, the After=dev-%i.device line does not appear in the + # Fedora 17 or Fedora 18 systemd getty@.service file. It may be left + # over from an earlier version and it's not doing any harm. We do need + # to disable the "ConditionalPathExists=/dev/tty0" line or no gettys are + # started on the ttys in the container. Lets do it in an override copy of + # the service so it can still pass rpm verifies and not be automatically + # updated by a new systemd version. -- mhw /\/\|=mhw=|\/\/ - sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \ - -e 's/After=dev-%i.device/After=/' \ - < ${rootfs_path}/lib/systemd/system/getty@.service \ - > ${rootfs_path}/etc/systemd/system/getty@.service + sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \ + -e 's/After=dev-%i.device/After=/' \ + < ${rootfs_path}/lib/systemd/system/getty@.service \ + > ${rootfs_path}/etc/systemd/system/getty@.service - # Setup getty service on the 4 ttys we are going to allow in the - # default config. Number should match lxc.tty.max - for i in 1 2 3 4; do - ln -sf ../getty@.service ${rootfs_path}/etc/systemd/system/getty.target.wants/getty@tty${i}.service - done + # Setup getty service on the 4 ttys we are going to allow in the + # default config. Number should match lxc.tty.max + for i in 1 2 3 4; do + ln -sf ../getty@.service ${rootfs_path}/etc/systemd/system/getty.target.wants/getty@tty${i}.service + done } download_pld() { - # check the mini pld was not already downloaded - INSTALL_ROOT=$cache/partial - mkdir -p $INSTALL_ROOT - if [ $? -ne 0 ]; then - echo "Failed to create '$INSTALL_ROOT' directory" - return 1 - fi + # check the mini pld was not already downloaded + INSTALL_ROOT=$cache/partial + mkdir -p $INSTALL_ROOT + if [ $? -ne 0 ]; then + echo "Failed to create '$INSTALL_ROOT' directory" + return 1 + fi - # download a mini pld into a cache - echo "Downloading PLD Linux minimal ..." - POLDEK="poldek --root $INSTALL_ROOT --noask --nohold --noignore" - PKG_LIST="basesystem filesystem pld-release rpm poldek vserver-packages rc-scripts pwdutils mingetty" + # download a mini pld into a cache + echo "Downloading PLD Linux minimal ..." + POLDEK="poldek --root $INSTALL_ROOT --noask --nohold --noignore" + PKG_LIST="basesystem filesystem pld-release rpm poldek vserver-packages rc-scripts pwdutils mingetty" - mkdir -p $INSTALL_ROOT@LOCALSTATEDIR@/lib/rpm - rpm --root $INSTALL_ROOT --initdb - $POLDEK -u $PKG_LIST + mkdir -p $INSTALL_ROOT@LOCALSTATEDIR@/lib/rpm + rpm --root $INSTALL_ROOT --initdb + $POLDEK -u $PKG_LIST - if [ $? -ne 0 ]; then - echo "Failed to download the rootfs, aborting." - return 1 - fi + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 + fi - mv "$INSTALL_ROOT" "$cache/rootfs" - echo "Download complete." + mv "$INSTALL_ROOT" "$cache/rootfs" + echo "Download complete." - return 0 + return 0 } copy_pld() { - # make a local copy of the minipld - echo -n "Copying rootfs to $rootfs_path ..." - cp -a $cache/rootfs/* $rootfs_path || return 1 - return 0 + # make a local copy of the minipld + echo -n "Copying rootfs to $rootfs_path ..." + cp -a $cache/rootfs/* $rootfs_path || return 1 + return 0 } update_pld() { - POLDEK="poldek --root $cache/rootfs --noask" - $POLDEK --upgrade-dist + POLDEK="poldek --root $cache/rootfs --noask" + $POLDEK --upgrade-dist } install_pld() { - mkdir -p @LOCALSTATEDIR@/lock/subsys/ - ( - flock -x 9 - if [ $? -ne 0 ]; then - echo "Cache repository is busy." - return 1 - fi + mkdir -p @LOCALSTATEDIR@/lock/subsys/ + ( + flock -x 9 + if [ $? -ne 0 ]; then + echo "Cache repository is busy." + return 1 + fi - echo "Checking cache download in $cache/rootfs ... " - if [ ! -e "$cache/rootfs" ]; then - download_pld - if [ $? -ne 0 ]; then - echo "Failed to download 'pld base'" - return 1 - fi - else - echo "Cache found. Updating..." - update_pld - if [ $? -ne 0 ]; then - echo "Failed to update 'pld base', continuing with last known good cache" - else - echo "Update finished" - fi - fi + echo "Checking cache download in $cache/rootfs ... " + if [ ! -e "$cache/rootfs" ]; then + download_pld + if [ $? -ne 0 ]; then + echo "Failed to download 'pld base'" + return 1 + fi + else + echo "Cache found. Updating..." + update_pld + if [ $? -ne 0 ]; then + echo "Failed to update 'pld base', continuing with last known good cache" + else + echo "Update finished" + fi + fi - echo "Copy $cache/rootfs to $rootfs_path ... " - copy_pld - if [ $? -ne 0 ]; then - echo "Failed to copy rootfs" - return 1 - fi + echo "Copy $cache/rootfs to $rootfs_path ... " + copy_pld + if [ $? -ne 0 ]; then + echo "Failed to copy rootfs" + return 1 + fi - return 0 - ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-pld + return 0 + ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-pld - return $? + return $? } copy_configuration() { - mkdir -p $config_path - grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs_path" >> $config_path/config - cat <> $config_path/config + mkdir -p $config_path + grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs_path" >> $config_path/config + cat <> $config_path/config # Most of below settings should be taken as defaults from # lxc.include = /usr/share/lxc/config/common.conf lxc.uts.name = $utsname @@ -276,46 +276,46 @@ lxc.cgroup.devices.allow = c 5:2 rwm lxc.cgroup.devices.allow = c 254:0 rm EOF - cat < $config_path/fstab + cat < $config_path/fstab proc proc proc nodev,noexec,nosuid 0 0 sysfs sys sysfs defaults 0 0 EOF - if [ $? -ne 0 ]; then - echo "Failed to add configuration" - return 1 - fi + if [ $? -ne 0 ]; then + echo "Failed to add configuration" + return 1 + fi - return 0 + return 0 } clean() { - if [ ! -e $cache ]; then - exit 0 - fi + if [ ! -e $cache ]; then + exit 0 + fi - # lock, so we won't purge while someone is creating a repository - ( - flock -x 9 - if [ $? != 0 ]; then - echo "Cache repository is busy." - exit 1 - fi + # lock, so we won't purge while someone is creating a repository + ( + flock -x 9 + if [ $? != 0 ]; then + echo "Cache repository is busy." + exit 1 + fi - echo -n "Purging the download cache for PLD Linux $release..." - rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 - exit 0 - ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-pld + echo -n "Purging the download cache for PLD Linux $release..." + rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 + exit 0 + ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-pld } usage() { - cat < - [-p|--path=] [-c|--clean] [-R|--release=] [--fqdn=] [-A|--arch=] - [-h|--help] + $1 -n|--name= + [-p|--path=] [-c|--clean] [-R|--release=] [--fqdn=] [-A|--arch=] + [-h|--help] Mandatory args: -n,--name container name, used to as an identifier for that container from now on Optional args: @@ -323,41 +323,41 @@ Optional args: --rootfs path for actual rootfs. -c,--clean clean the cache -R,--release PLD Linux release for the new container. if the host is PLD Linux, then it will default to the host's release. - --fqdn fully qualified domain name (FQDN) for DNS and system naming + --fqdn fully qualified domain name (FQDN) for DNS and system naming -A,--arch NOT USED YET. Define what arch the container will be [i686,x86_64] -h,--help print this help EOF - return 0 + return 0 } options=$(getopt -o hp:n:cR: -l help,path:,rootfs:,name:,clean,release:,fqdn: -- "$@") if [ $? -ne 0 ]; then - usage $(basename $0) - exit 1 + usage $(basename $0) + exit 1 fi eval set -- "$options" while :; do - case "$1" in - -h|--help) usage $0 && exit 0;; - -p|--path) path=$2; shift 2;; - --rootfs) rootfs=$2; shift 2;; - -n|--name) name=$2; shift 2;; - -c|--clean) clean=$2; shift 2;; - -R|--release) release=$2; shift 2;; - --fqdn) utsname=$2; shift 2;; - --) shift 1; break ;; - *) break ;; - esac + case "$1" in + -h|--help) usage $0 && exit 0;; + -p|--path) path=$2; shift 2;; + --rootfs) rootfs=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -c|--clean) clean=$2; shift 2;; + -R|--release) release=$2; shift 2;; + --fqdn) utsname=$2; shift 2;; + --) shift 1; break ;; + *) break ;; + esac done if [ ! -z "$clean" -a -z "$path" ]; then - clean || exit 1 - exit 0 + clean || exit 1 + exit 0 fi if [ -z "${utsname}" ]; then - utsname=${name} + utsname=${name} fi # This follows a standard "resolver" convention that an FQDN must have @@ -374,51 +374,51 @@ fi # utsname and hostname = Container_Name.Domain_Name if [ $(expr "$utsname" : '.*\..*\.') = 0 ]; then - if [ -n "$(dnsdomainname)" ]; then - utsname=${utsname}.$(dnsdomainname) - fi + if [ -n "$(dnsdomainname)" ]; then + utsname=${utsname}.$(dnsdomainname) + fi fi needed_pkgs="" type poldek >/dev/null 2>&1 if [ $? -ne 0 ]; then - needed_pkgs="poldek $needed_pkgs" + needed_pkgs="poldek $needed_pkgs" fi #type curl >/dev/null 2>&1 #if [ $? -ne 0 ]; then -# needed_pkgs="curl $needed_pkgs" +# needed_pkgs="curl $needed_pkgs" #fi if [ -n "$needed_pkgs" ]; then - echo "Missing commands: $needed_pkgs" - echo "Please install these using \"sudo poldek -u $needed_pkgs\"" - exit 1 + echo "Missing commands: $needed_pkgs" + echo "Please install these using \"sudo poldek -u $needed_pkgs\"" + exit 1 fi if [ -z "$path" ]; then - path=$default_path/$name + path=$default_path/$name fi if [ -z "$release" ]; then - if [ "$is_pld" -a "$pld_host_ver" ]; then - release=$pld_host_ver - else - echo "This is not a PLD Linux host and release missing, defaulting to 3.0. use -R|--release to specify release" - release=3.0 - fi + if [ "$is_pld" -a "$pld_host_ver" ]; then + release=$pld_host_ver + else + echo "This is not a PLD Linux host and release missing, defaulting to 3.0. use -R|--release to specify release" + release=3.0 + fi fi # pld th have systemd. We need autodev enabled to keep systemd from causing problems. if [ $release = 3.0 ]; then - auto_dev="0" + auto_dev="0" else - auto_dev="0" + auto_dev="0" fi if [ "$(id -u)" != "0" ]; then - echo "This script should be run as 'root'" - exit 1 + echo "This script should be run as 'root'" + exit 1 fi if [ -z "$rootfs" ]; then @@ -436,49 +436,49 @@ cache=$cache_base/$release revert() { - echo "Interrupted, so cleaning up" - lxc-destroy -n $name - # maybe was interrupted before copy config - rm -rf $path - rm -rf $default_path/$name - echo "exiting..." - exit 1 + echo "Interrupted, so cleaning up" + lxc-destroy -n $name + # maybe was interrupted before copy config + rm -rf $path + rm -rf $default_path/$name + echo "exiting..." + exit 1 } trap revert SIGHUP SIGINT SIGTERM copy_configuration if [ $? -ne 0 ]; then - echo "Failed write configuration file" - exit 1 + echo "Failed write configuration file" + exit 1 fi install_pld if [ $? -ne 0 ]; then - echo "Failed to install PLD Linux" - exit 1 + echo "Failed to install PLD Linux" + exit 1 fi configure_pld if [ $? -ne 0 ]; then - echo "Failed to configure PLD Linux for a container" - exit 1 + echo "Failed to configure PLD Linux for a container" + exit 1 fi # If the systemd configuration directory exists - set it up for what we need. if [ -d ${rootfs_path}/etc/systemd/system ]; then - configure_pld_systemd + configure_pld_systemd fi # This configuration (rc.sysinit) is not inconsistent with the systemd stuff # above and may actually coexist on some upgraded systems. Let's just make # sure that, if it exists, we update this file, even if it's not used... if [ -f ${rootfs_path}/etc/rc.sysinit ]; then - configure_pld_init + configure_pld_init fi if [ ! -z $clean ]; then - clean || exit 1 - exit 0 + clean || exit 1 + exit 0 fi echo "container rootfs and config created" diff --git a/templates/lxc-slackware.in b/templates/lxc-slackware.in index 5962475..9c0041a 100644 --- a/templates/lxc-slackware.in +++ b/templates/lxc-slackware.in @@ -499,8 +499,8 @@ mkdir -p /var/lock/subsys/ ( flock -n -x 9 if [ $? -ne 0 ]; then - echo "Cache repository is busy." - return 1 + echo "Cache repository is busy." + return 1 fi if [ "$arch" == "x86_64" ]; then @@ -508,7 +508,7 @@ if [ "$arch" == "x86_64" ]; then elif [ "$arch" == "arm" ]; then PKGMAIN=slackwarearm else - PKGMAIN=slackware + PKGMAIN=slackware fi export CONF=$cache/slackpkg-conf @@ -651,8 +651,8 @@ lxc.include = ${LXC_TEMPLATE_CONFIG}/slackware.common.conf EOF if [ $? -ne 0 ]; then - echo "Failed to add configuration." - return 1 + echo "Failed to add configuration." + return 1 fi return 0 @@ -661,15 +661,15 @@ return 0 clean() { if [ ! -e $cache ]; then - exit 0 + exit 0 fi # lock, so we won't purge while someone is creating a repository ( flock -n -x 9 if [ $? != 0 ]; then - echo "Cache repository is busy." - exit 1 + echo "Cache repository is busy." + exit 1 fi echo -n "Purging the download cache..." @@ -689,8 +689,8 @@ return 0 options=$(getopt -o hp:n:a:r:c -l help,rootfs:,path:,name:,arch:,release:,clean -- "$@") if [ $? -ne 0 ]; then - usage $(basename $0) - exit 1 + usage $(basename $0) + exit 1 fi eval set -- "$options" @@ -699,59 +699,59 @@ do case "$1" in -h|--help) usage $0 && exit 0;; -p|--path) path=$2; shift 2;; - --rootfs) rootfs=$2; shift 2;; - -a|--arch) arch=$2; shift 2;; - -r|--release) release=$2; shift 2;; - -n|--name) name=$2; shift 2;; - -c|--clean) clean=$2; shift 2;; + --rootfs) rootfs=$2; shift 2;; + -a|--arch) arch=$2; shift 2;; + -r|--release) release=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -c|--clean) clean=$2; shift 2;; --) shift 1; break ;; *) break ;; esac done if [ ! -z "$clean" -a -z "$path" ]; then - clean || exit 1 - exit 0 + clean || exit 1 + exit 0 fi type installpkg if [ $? -ne 0 ]; then - echo "'installpkg' command is missing." - exit 1 + echo "'installpkg' command is missing." + exit 1 fi type slackpkg if [ $? -ne 0 ]; then - echo "'slackpkg' command is missing." - exit 1 + echo "'slackpkg' command is missing." + exit 1 fi if [ -z "$path" ]; then - echo "'path' parameter is required." - exit 1 + echo "'path' parameter is required." + exit 1 fi if [ "$(id -u)" != "0" ]; then - echo "This script should be run as 'root'." - exit 1 + echo "This script should be run as 'root'." + exit 1 fi # If no release version was specified, use current release=${release:-current} if [ -z "$name" ]; then - # no name given? set a default one - name=slackwarecontainer + # no name given? set a default one + name=slackwarecontainer fi # detect rootfs config="$path/config" if [ -z "$rootfs" ]; then - if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then - rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config) - else - rootfs=$path/rootfs - fi + if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then + rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config) + else + rootfs=$path/rootfs + fi fi echo @@ -760,16 +760,16 @@ set -e install_slackware $rootfs if [ $? -ne 0 ]; then - echo "Failed to install slackware." - exit 1 + echo "Failed to install slackware." + exit 1 fi echo configure_slackware $cache/rootfs-$release-$arch $name if [ $? -ne 0 ]; then - echo "Failed to configure slackware for a container." - exit 1 + echo "Failed to configure slackware for a container." + exit 1 fi echo @@ -777,19 +777,19 @@ echo rootfs=$path/rootfs copy_slackware $rootfs if [ $? -ne 0 ]; then - echo "Failed to copy rootfs." - exit 1 + echo "Failed to copy rootfs." + exit 1 fi echo copy_configuration $path $rootfs $name if [ $? -ne 0 ]; then - echo "Failed to write configuration file." - exit 1 + echo "Failed to write configuration file." + exit 1 fi if [ ! -z $clean ]; then - clean || exit 1 - exit 0 + clean || exit 1 + exit 0 fi diff --git a/templates/lxc-sparclinux.in b/templates/lxc-sparclinux.in index e5e686f..fbf2168 100644 --- a/templates/lxc-sparclinux.in +++ b/templates/lxc-sparclinux.in @@ -233,9 +233,9 @@ EOF # allow root login on console, tty[1-4], and pts/0 for libvirt echo "# LXC (Linux Containers)" >>$container_rootfs/etc/securetty - echo "lxc/console" >>$container_rootfs/etc/securetty + echo "lxc/console" >>$container_rootfs/etc/securetty for i in 1 2 3 4; do - echo "lxc/tty$i" >>$container_rootfs/etc/securetty + echo "lxc/tty$i" >>$container_rootfs/etc/securetty done echo "# For libvirt/Virtual Machine Monitor" >>$container_rootfs/etc/securetty for i in 0 1 2 3 4; do diff --git a/templates/lxc-voidlinux.in b/templates/lxc-voidlinux.in index d74da38..00ff917 100644 --- a/templates/lxc-voidlinux.in +++ b/templates/lxc-voidlinux.in @@ -32,9 +32,9 @@ # Check if array $2 contains item $1 containsElement() { - local e - for e in "${@:2}"; do [[ "$1" == "$e" ]] && return 0; done - return 1 + local e + for e in "${@:2}"; do [[ "$1" == "$e" ]] && return 0; done + return 1 } # split comma-separated string into an array