lxc-cirros.in revision 58a46e06210a6321c530735f15f66eb648c4657d
# template script for generating ubuntu container for LXC
#
# This script consolidates and extends the existing lxc ubuntu scripts
#
# Copyright � 2013 Canonical Ltd.
# Author: Scott Moser <scott.moser@canonical.com>
#
# it under the terms of the GNU General Public License version 2, as
# published by the Free Software Foundation.
# This program 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 General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
TEMP_D=""
TMP_FILE=""
BUILD="standard"
DEF_VERSION="released"
case "${UNAME_M}" in
*) DEF_ARCH="i386";;
esac
shift
done
return 1
}
cat <<EOF
${0##*/} [options]
-a | --arch A architecture to use [${ARCHES}]
default: ${DEF_ARCH}
-h | --help this usage
-v | --verbose increase verbosity
-S | --auth-key K insert auth key 'K'
-v | --version V version [${STREAMS[*]}]
default: ${DEF_VERSION}
-u | --userdata U user-data file
EOF
}
}
local level=${1}; shift;
error "${@}"
}
k="${arg%%=*}"
v="${arg#*=}"
ret="${ret} \"${k}\": \"$v\","
done
ret="${ret%,} }"
echo "$ret"
}
{
# Template used to create this container: cirros
lxc.rootfs = $rootfs
#lxc.mount = $path/fstab
lxc.pivotdir = lxc_putold
lxc.tty = 4
lxc.pts = 1024
lxc.utsname = $name
lxc.arch = $arch
lxc.cap.drop = sys_module mac_admin mac_override sys_time
# When using LXC with apparmor, uncomment the next line to run unconfined:
#lxc.aa_profile = unconfined
# To support container nesting on an Ubuntu host, uncomment next two lines:
#lxc.aa_profile = lxc-container-default-with-nesting
#lxc.hook.mount = /usr/share/lxc/hooks/mountcgroups
lxc.cgroup.devices.deny = a
# Allow any mknod (but not using the node)
lxc.cgroup.devices.allow = c *:* m
lxc.cgroup.devices.allow = b *:* m
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
# /dev/{,u}random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# rtc
lxc.cgroup.devices.allow = c 254:0 rwm
# fuse
lxc.cgroup.devices.allow = c 10:229 rwm
# tun
lxc.cgroup.devices.allow = c 10:200 rwm
# full
lxc.cgroup.devices.allow = c 1:7 rwm
# hpet
lxc.cgroup.devices.allow = c 10:228 rwm
# kvm
lxc.cgroup.devices.allow = c 10:232 rwm
EOF
}
iid="iid-local01"
}
return 0
}
file="cirros-$ver-$arch-lxc.tar.gz"
outd="${cached}/${dlpath%/*}"
return 0
fi
return 1;
}
}
short_opts="a:n:p:S:huV"
long_opts="arch:,auth-key:,name:,path:,userdata:,verbose,version:"
eval set -- "${getopt_out}" ||
arch="${DEF_ARCH}"
version="${DEF_VERSION}"
authkey_f=""
authkeys=""
userdata=""
seed=true
path=""
while [ $# -ne 0 ]; do
--) shift; break;;
esac
shift;
done
fail "must be run as root"
fi
esac
fi
if [ -n "$authkey_f" ]; then
if [ ! -f "$authkey_f" ]; then
echo "--auth-key=${authkey_f} must reference a file"
exit 1
fi
fi
# oopsie - some cirros tarballs ship random as a blockdev, breaking
# dropbear.
fi
if false; then
else
# disable ec2, because its annoying
fi
# vi: ts=4 expandtab