Skip to content

Commit

Permalink
minor cleanup in template and add systemd_configure function with ope…
Browse files Browse the repository at this point in the history
…nmandriva-related tricks

Signed-off-by: Alexander Khryukin <alexander@mezon.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
  • Loading branch information
fedya authored and stgraber committed Oct 10, 2013
1 parent f1d8e7e commit edcf9b5
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions templates/lxc-openmandriva.in
Expand Up @@ -69,6 +69,7 @@ EOF

populate_dev()
{
echo -n "Create devices in /dev/"
dev_path="${rootfs_path}/dev"
rm -rf $dev_path
mkdir -p $dev_path
Expand All @@ -89,8 +90,7 @@ populate_dev()
mknod -m 600 ${dev_path}/initctl p
mknod -m 666 ${dev_path}/ptmx c 5 2
mkdir -m 755 ${dev_path}/net
mknod -m 666 ${dev_path}/net/tun c 10 200
return 0
mknod -m 666 ${dev_path}/net/tun c 10 200

}

Expand All @@ -99,7 +99,7 @@ set_guest_root_password()
[[ -z "$root_password" ]] && return # pass is empty, abort

echo -n " - setting guest root password.."
echo "root passwd is: $root_password"
echo -n "root passwd is: $root_password"
echo "root:$root_password" | chroot "$rootfs_path" chpasswd
echo "done."
}
Expand All @@ -114,10 +114,9 @@ create_chroot_openmandriva()
return 1
fi
# package list to install
PKG_LIST="basesystem-minimal locales locales-en initscripts urpmi cronie dhcp-client"
PKG_LIST="basesystem-minimal locales locales-en initscripts urpmi cronie dhcp-client kbd"
# download a mini openmandriva into a cache
echo "Downloading openmandriva minimal ..."
#URPMI="/usr/sbin/urpmi.addmedia --urpmi-root $INSTALL_ROOT main http://abf.rosalinux.ru/downloads/$distro/repository/$arch/main/release"
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"
Expand Down Expand Up @@ -150,9 +149,26 @@ copy_openmandriva()
update_openmandriva()
{
echo "automated update in progress..."
# chroot $cache/rootfs urpmi --auto --auto-update
urpmi --root $cache/rootfs urpmi-root $cache/rootfs --auto --auto-update --ignorearch
}

configure_openmandriva_systemd()
{
chroot ${rootfs_path} ln -s /dev/null /etc/systemd/system/proc-sys-fs-binfmt_misc.automount
chroot ${rootfs_path} ln -s /dev/null /etc/systemd/system/systemd-udevd.service
chroot ${rootfs_path} ln -s /dev/null /etc/systemd/system/systemd-udevd-control.socket
chroot ${rootfs_path} ln -s /dev/null /etc/systemd/system/systemd-udevd-kernel.socket
# remove numlock service
# KDGKBLED: Inappropriate ioctl for device
rm -f ${rootfs_path}/etc/systemd/system/getty@.service.d/enable-numlock.conf

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
}


install_openmandriva()
{
mkdir -p @LOCALSTATEDIR@/lock/subsys/
Expand Down Expand Up @@ -200,6 +216,7 @@ copy_configuration()
grep -q "^lxc.rootfs" $config_path/config 2>/dev/null || echo "lxc.rootfs = $rootfs_path" >> $config_path/config
cat <<EOF >> $config_path/config
lxc.utsname = $name
lxc.autodev = 1
lxc.tty = 4
lxc.pts = 1024
lxc.mount = $config_path/fstab
Expand All @@ -212,7 +229,7 @@ lxc.cap.drop = sys_module mac_admin mac_override sys_time
lxc.network.type = $lxc_network_type
lxc.network.flags = up
lxc.network.link = $lxc_network_link
lxc.network.name = veth0
lxc.network.name = eth0
lxc.network.mtu = 1500
EOF
if [ ! -z ${ipv4} ]; then
Expand Down Expand Up @@ -366,6 +383,10 @@ if [ ! -z "$clean" -a -z "$path" ]; then
exit 0
fi

if [ -z "${utsname}" ]; then
utsname=${name}
fi

type urpmi >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "'urpmi' command is missing"
Expand Down Expand Up @@ -425,6 +446,12 @@ if [ $? -ne 0 ]; then
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_openmandriva_systemd
fi

populate_dev
if [ $? -ne 0 ]; then
echo "failed to populated /dev/ devices"
Expand Down

0 comments on commit edcf9b5

Please sign in to comment.