lxc-altlinux.in revision 96283b546081e7ff709968378fca25cb44f1ab6c
181N/A# template script for generating altlinux container for LXC 181N/A# lxc: linux Container library 181N/A# Alexey Shabalin <shaba@altlinux.org> 181N/A# This library is free software; you can redistribute it and/or 181N/A# modify it under the terms of the GNU Lesser General Public 181N/A# License as published by the Free Software Foundation; either 181N/A# version 2.1 of the License, or (at your option) any later version. 181N/A# This library is distributed in the hope that it will be useful, 181N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 181N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 181N/A# Lesser General Public License for more details. 2199N/A# You should have received a copy of the GNU Lesser General Public 3339N/A# License along with this library; if not, write to the Free Software 2199N/A# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 3339N/A# Detect use under userns (unsupported) 1715N/A echo "This template can't be used for unprivileged containers." 1>&
2 526N/A echo "You may want to try the \"download\" template instead." 1>&
2 181N/A# Make sure the usual locations are in PATH 181N/A # disable selinux in altlinux 181N/A cat <<EOF > ${rootfs_path}/etc/net/ifaces/veth0/options 526N/A cat <<EOF > ${rootfs_path}/etc/net/ifaces/veth0/ipv4address 526N/A cat <<EOF > ${rootfs_path}/etc/net/ifaces/veth0/ipv4route 526N/A cat <<EOF > ${rootfs_path}/etc/net/ifaces/veth0/resolv.conf 3339N/A cat <<EOF > ${rootfs_path}/etc/net/ifaces/veth0/ipv6address 3339N/A cat <<EOF > ${rootfs_path}/etc/net/ifaces/veth0/ipv6route 3339N/A cat <<EOF > ${rootfs_path}/etc/sysconfig/network 3339N/A127.0.0.1 localhost.localdomain localhost $name 3339N/A # Allow to login at virsh console. loginuid.so doen't work in the absence of auditd. 3339N/A # Allow root to login at virsh console 416N/A# chroot ${rootfs_path} chkconfig keytable off 181N/A# touch file for fastboot 526N/A # check the mini altlinux was not already downloaded 526N/A # download a mini altlinux into a cache 526N/A echo "Downloading altlinux minimal ..." 526N/A# PKG_LIST="basesystem apt apt-conf-sisyphus etcnet openssh-server passwd sysklogd net-tools e2fsprogs" 526N/A echo "Failed to download the rootfs, aborting." 526N/A echo "Download complete." 526N/A # make a local copy of the minialtlinux 2958N/A # i prefer rsync (no reason really) 181N/A echo "Cache repository is busy." 181N/A echo "Failed to download 'altlinux base'" 416N/A echo "Cache found. Updating..." 181N/A echo "Failed to update 'altlinux base', continuing with last known good cache" 181N/A echo "Failed to copy rootfs" 3339N/Alxc.mount = $config_path/fstab 3339N/Alxc.cap.drop = sys_module mac_admin mac_override sys_time 181N/A# When using LXC with apparmor, uncomment the next line to run unconfined: 3339N/A#lxc.aa_profile = unconfined 181N/Alxc.network.type = $lxc_network_type 181N/Alxc.network.link = $lxc_network_link 181N/Alxc.network.name = veth0 181N/Alxc.network.ipv4 = $ipv4 3339N/Alxc.network.ipv4.gateway = $gw 416N/Alxc.network.ipv6 = $ipv6 416N/Alxc.network.ipv6.gateway = $gw6 416N/Alxc.cgroup.devices.deny = a 416N/Alxc.cgroup.devices.allow = c 1:3 rwm 416N/Alxc.cgroup.devices.allow = c 1:5 rwm 526N/Alxc.cgroup.devices.allow = c 5:1 rwm 526N/Alxc.cgroup.devices.allow = c 5:0 rwm 526N/Alxc.cgroup.devices.allow = c 4:0 rwm 416N/Alxc.cgroup.devices.allow = c 4:1 rwm 416N/Alxc.cgroup.devices.allow = c 1:9 rwm 416N/Alxc.cgroup.devices.allow = c 1:8 rwm 416N/Alxc.cgroup.devices.allow = c 136:* rwm 416N/Alxc.cgroup.devices.allow = c 5:2 rwm 416N/Alxc.cgroup.devices.allow = c 10:135 rwm 181N/Aproc proc proc nodev,noexec,nosuid 0 0 416N/Asysfs sys sysfs defaults 0 0 416N/A echo "Failed to add configuration" 416N/A # lock, so we won't purge while someone is creating a repository 3339N/A echo "Cache repository is busy." 2199N/A $1 -n|--name=<container_name> 2199N/A [-p|--path=<path>] [-c|--clean] [-R|--release=<ALTLinux_release>] 2199N/A [-4|--ipv4=<ipv4 address>] [-6|--ipv6=<ipv6 address>] 2199N/A [-g|--gw=<gw address>] [-d|--dns=<dns address>] 2199N/A [-P|--profile=<name of the profile>] [--rootfs=<path>] 2199N/A [-A|--arch=<arch of the container>] 2199N/A -n,--name container name, used to as an identifier for that container from now on 2199N/A -p,--path path to where the container rootfs will be created, defaults to @LXCPATH@. The container config will go under @LXCPATH@ in that case 2199N/A -R,--release ALTLinux release for the new container. if the host is ALTLinux, then it will defaultto the host's release. 2199N/A -4,--ipv4 specify the ipv4 address to assign to the virtualized interface, eg. 192.168.1.123/24 2199N/A -6,--ipv6 specify the ipv6 address to assign to the virtualized interface, eg. 2003:db8:1:0:214:1234:fe0b:3596/64 2199N/A -g,--gw specify the default gw, eg. 192.168.1.1 2199N/A -G,--gw6 specify the default gw, eg. 2003:db8:1:0:214:1234:fe0b:3596 2199N/A -d,--dns specify the DNS server, eg. 192.168.1.2 2199N/A -P,--profile Profile name is the file name in /etc/lxc/profiles contained packages name for install to cache. 2199N/A -A,--arch NOT USED YET. Define what arch the container will be [i686,x86_64] -g|--
gw)
gw=$
2;
shift 2;;
echo "'apt-get' command is missing" echo "This is not a ALTLinux host and release missing, use -R|--release to specify release" if [
"$(id -u)" !=
"0" ];
then echo "This script should be run as 'root'" # check for 'lxc.rootfs' passed in through default config by lxc-create echo "A container with that name exists, chose a different name" echo "failed to install altlinux" echo "failed to configure altlinux for a container" echo "failed write configuration file" echo "container rootfs and config created"