lxc-fedora.in revision 29ec8f8473c5e384a8feaddf61dee68b39d069d6
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# template script for generating fedora container for LXC
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# lxc: linux Container library
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# Daniel Lezcano <daniel.lezcano@free.fr>
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# Ramez Hanna <rhanna@informatiq.org>
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# This library is free software; you can redistribute it and/or
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# modify it under the terms of the GNU Lesser General Public
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# License as published by the Free Software Foundation; either
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# version 2.1 of the License, or (at your option) any later version.
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# This library is distributed in the hope that it will be useful,
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# but WITHOUT ANY WARRANTY; without even the implied warranty of
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# Lesser General Public License for more details.
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# You should have received a copy of the GNU Lesser General Public
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# License along with this library; if not, write to the Free Software
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski#Configurations
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski# is this fedora?
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski[ -f /etc/fedora-release ] && is_fedora=true
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski cat <<EOF > ${rootfs_path}/etc/sysconfig/network-scripts/ifcfg-eth0
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till MossakowskiBOOTPROTO=dhcp
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till MossakowskiHOSTNAME=${UTSNAME}
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till MossakowskiNM_CONTROLLED=no
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till Mossakowski cat <<EOF > ${rootfs_path}/etc/sysconfig/network
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till MossakowskiNETWORKING=yes
cbc7f7ea90538f481b528959e9b6cf837b0dd785Till MossakowskiHOSTNAME=${UTSNAME}
if [ $? -ne 0 ]; then
RELEASE_URL="http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/$release/Everything/$arch/os/Packages/fedora-release-$release-1.noarch.rpm"
mkdir -p $INSTALL_ROOT/var/lib/rpm
rpm --root $INSTALL_ROOT --initdb
if [ $? -ne 0 ]; then
rsync -a $cache/rootfs/ $rootfs_path/
flock -n -x 200
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
if [ ! -e $cache ]; then
flock -n -x 200
cat <<EOF
-p,--path path to where the container rootfs will be created, defaults to /var/lib/lxc. The container config will go under /var/lib/lxc in that case
-R,--release Fedora release for the new container. if the host is Fedora, then it will defaultto the host's release.
eval set -- "$options"
if [ -z "$path" ]; then
if [ -z "$release" ]; then
if [ "$is_fedora" ]; then
echo "This is not a fedora host and release missing, defaulting to 14. use -R|--release to specify release"
if [ ! -z $clean ]; then
echo "container is configured for lxc.network.type=veth and lxc.network.link=virbr0 (which is default if you have libvirt runnig)"