From: Michael H. Warfield Date: Tue, 14 May 2013 21:45:12 +0000 (-0400) Subject: lxc-fedora-template: autodev, hostname, ARM archs, Raspberry Pi fixes X-Git-Tag: lxc-1.0.0.alpha1~1^2~211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=627fe3b4c3a65535eb53c3d63794705d8f6322d4;p=thirdparty%2Flxc.git lxc-fedora-template: autodev, hostname, ARM archs, Raspberry Pi fixes This took a lot longer for me to get around to it... Sorry. Patch to the lxc-fedora template. I didn't get any further comments from my earlier proposal, weeks ago, and did get one addition based on comments about properly setting the hostname in /etc/hostname, which I've added. I could have broken them into separate patches but most are pretty small and minor. Changes: * Map armv6l and armv7l architectures to "arm" for yum and repos to function properly. * Detect Fedora Remix distros with no "/etc/fedora-release" file (Raspberry Pi) and find proper release versions when "remix" part of the file context. * Change default Fedora container on non-Fedora hosts to Fedora 17. * Added code for autodev for Fedora systemd containers. * Added code to set /etc/hostname for Fedora > 14 (systemd). * Fix a few typos. Regards, Mike -- Michael H. Warfield (AI4NB) | (770) 985-6132 | mhw@WittsEnd.com /\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/ NIC whois: MHW9 | An optimist believes we live in the best of all PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it! -- Signed-off-by: Michael H. Warfield Signed-off-by: Serge Hallyn --- diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in index 59f453be9..710039c5b 100644 --- a/templates/lxc-fedora.in +++ b/templates/lxc-fedora.in @@ -32,12 +32,28 @@ default_path=@LXCPATH@ root_password=root # is this fedora? -[ -f /etc/fedora-release ] && is_fedora=true - -if [ "$arch" = "i686" ]; then - arch=i386 +# Alow for weird remixes like the Raspberry Pi +if [ -e /etc/redhat-release ] +then + fedora_host_ver=$( sed -e '/^Fedora /!d' -e 's/Fedora.*\srelease\s*\([0-9][0-9]*\)\s.*/\1/' < /etc/redhat-release ) + if [ "$fedora_host_ver" != "" ] + then + is_fedora=true + fi fi +# Map a few architectures to their generic Fedora repository archs. +# The two ARM archs are a bit of a guesstimate for the v5 and v6 +# archs. V6 should have hardware floating point (Rasberry Pi). +# The "arm" arch is safer (no hardware floating point). So +# there may be cases where we "get it wrong" for some v6 other +# than RPi. +case "$arch" in +i686) arch=i386 ;; +armv3l|armv4l|armv5l) arch=arm ;; +armv6l|armv7l|armv8l) arch=armhfp ;; +esac + configure_fedora() { @@ -62,9 +78,15 @@ NETWORKING=yes HOSTNAME=${name} EOF + # set hostname on systemd Fedora systems + if [ $release -gt 14 ]; then + echo "${name}" > ${rootfs_path}/etc/hostname + fi + # set minimal hosts cat < $rootfs_path/etc/hosts 127.0.0.1 localhost $name +::1 localhost6.localdomain6 localhost6 EOF dev_path="${rootfs_path}/dev" @@ -254,6 +276,8 @@ lxc.pts = 1024 lxc.mount = $config_path/fstab lxc.cap.drop = sys_module mac_admin mac_override sys_time +lxc.autodev = $auto_dev + # When using LXC with apparmor, uncomment the next line to run unconfined: #lxc.aa_profile = unconfined @@ -321,7 +345,7 @@ Mandatory args: Optional args: -p,--path path to where the container rootfs will be created, defaults to @LXCPATH@. The container config will go under @LXCPATH@ in that case -c,--clean clean the cache - -R,--release Fedora release for the new container. if the host is Fedora, then it will defaultto the host's release. + -R,--release Fedora release for the new container. if the host is Fedora, then it will default to the host's release. -A,--arch NOT USED YET. Define what arch the container will be [i686,x86_64] -h,--help print this help EOF @@ -366,7 +390,7 @@ fi if [ -n "$needed_pkgs" ]; then echo "Missing commands: $needed_pkgs" - echo "Please install these using \"sudo apt-get install $needed_pkgs\"" + echo "Please install these using \"sudo yum install $needed_pkgs\"" exit 1 fi @@ -375,14 +399,22 @@ if [ -z "$path" ]; then fi if [ -z "$release" ]; then - if [ "$is_fedora" ]; then - release=$(cat /etc/fedora-release |awk '/^Fedora/ {print $3}') + if [ "$is_fedora" -a "$fedora_host_ver" ]; then + release=$fedora_host_ver else - echo "This is not a fedora host and release missing, defaulting to 14. use -R|--release to specify release" - release=14 + echo "This is not a fedora host and release missing, defaulting to 17. use -R|--release to specify release" + release=17 fi fi +# Fedora 15 and above run systemd. We need autodev enabled to keep +# systemd from causing problems. +if [ $release -gt 14 ]; then + auto_dev="1" +else + auto_dev="0" +fi + if [ "$(id -u)" != "0" ]; then echo "This script should be run as 'root'" exit 1