lxc-openmandriva.in revision 8ec981fc8b0105da5f071e40811e0c2472a6c3c9
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# template script for generating openmandriva container for LXC
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# lxc: linux Container library
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Alexander Khryukin <alexander@mezon.ru>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Vokhmin Alexey V <avokhmin@gmail.com>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# This library is free software; you can redistribute it and/or
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# modify it under the terms of the GNU Lesser General Public
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# License as published by the Free Software Foundation; either
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# version 2.1 of the License, or (at your option) any later version.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# This library is distributed in the hope that it will be useful,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# but WITHOUT ANY WARRANTY; without even the implied warranty of
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Lesser General Public License for more details.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# You should have received a copy of the GNU Lesser General Public
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# License along with this library; if not, write to the Free Software
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Detect use under userns (unsupported)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen echo "This template can't be used for unprivileged containers." 1>&2
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen echo "You may want to try the \"download\" template instead." 1>&2
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#Configurations
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#distro=cooker
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainencache_base=@LOCALSTATEDIR@/cache/lxc/openmandriva/$arch
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# is this openmandriva?
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen[ -f /etc/mandriva-release ] && is_openmandriva=true
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmkdir -p ${rootfs_path}/etc/sysconfig/network-scripts/
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen cat <<EOF > ${rootfs_path}/etc/sysconfig/network-scripts/ifcfg-eth0
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo SirainenBOOTPROTO=dhcp
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo SirainenNM_CONTROLLED=no
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo SirainenHOSTNAME=${utsname}
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen cat <<EOF > ${rootfs_path}/etc/sysconfig/network
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo SirainenNETWORKING=yes
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo SirainenHOSTNAME=${utsname}
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenecho "${utsname}" > ${rootfs_path}/etc/hostname
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen127.0.0.1 localhost.localdomain localhost $utsname
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen::1 localhost6.localdomain6 localhost6
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen mknod -m 666 ${dev_path}/null c 1 3
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen mknod -m 666 ${dev_path}/zero c 1 5
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen mknod -m 666 ${dev_path}/random c 1 8
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen mknod -m 666 ${dev_path}/urandom c 1 9
if [ $? -ne 0 ]; then
URPMI="/usr/sbin/urpmi.addmedia --urpmi-root $INSTALL_ROOT main http://abf.rosalinux.ru/downloads/$release/repository/$arch/main/release"
echo $URPMI
URPMI_BASE="/usr/sbin/urpmi --no-suggests --no-verify-rpm --ignorearch --root $INSTALL_ROOT --urpmi-root $INSTALL_ROOT --auto $PKG_LIST"
if [ $? -ne 0 ]; then
chroot ${rootfs_path} ln -s /dev/null /etc/systemd/system/systemd-udevd.service
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!' \
mkdir -p @LOCALSTATEDIR@/lock/subsys/
flock -x 9
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
grep -q "^lxc.rootfs" $config_path/config 2>/dev/null || echo "lxc.rootfs = $rootfs_path" >> $config_path/config
if [ ! -z ${ipv4} ]; then
if [ ! -z ${gw} ]; then
if [ ! -z ${ipv6} ]; then
if [ ! -z ${gw6} ]; then
if [ $? -ne 0 ]; then
if [ ! -e $cache ]; then
flock -x 9
cat <<EOF
-p,--path path to where the container rootfs will be created, defaults to @LXCPATH@. The container config will go under @LXCPATH@ in that case
-R,--release openmandriva2013.0/cooker/rosa2012.1 release for the new container. if the host is OpenMandriva, then it will default to the host's release.
-6,--ipv6 specify the ipv6 address to assign to the virtualized interface, eg. 2003:db8:1:0:214:1234:fe0b:3596/64
-P,--profile Profile name is the file name in /etc/lxc/profiles contained packages name for install to cache.
options=$(getopt -o hp:n:P:cR:4:6:g:d:A -l help,rootfs:,path:,name:,profile:,clean:,release:,ipv4:,ipv6:,gw:,dns:,arch: -- "$@")
eval set -- "$options"
if [ -z "$path" ]; then
if [ -z "$profile" ]; then
# check for 'lxc.rootfs' passed in through default config by lxc-create
if [ -z "$rootfs_path" ]; then
if [ ! -z $clean ]; then