Commit 627fe3b4 by Michael H. Warfield Committed by Serge Hallyn

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: 's avatarMichael H. Warfield <mhw@WittsEnd.com> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 794fb287
...@@ -32,12 +32,28 @@ default_path=@LXCPATH@ ...@@ -32,12 +32,28 @@ default_path=@LXCPATH@
root_password=root root_password=root
# is this fedora? # is this fedora?
[ -f /etc/fedora-release ] && is_fedora=true # Alow for weird remixes like the Raspberry Pi
if [ -e /etc/redhat-release ]
if [ "$arch" = "i686" ]; then then
arch=i386 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 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() configure_fedora()
{ {
...@@ -62,9 +78,15 @@ NETWORKING=yes ...@@ -62,9 +78,15 @@ NETWORKING=yes
HOSTNAME=${name} HOSTNAME=${name}
EOF EOF
# set hostname on systemd Fedora systems
if [ $release -gt 14 ]; then
echo "${name}" > ${rootfs_path}/etc/hostname
fi
# set minimal hosts # set minimal hosts
cat <<EOF > $rootfs_path/etc/hosts cat <<EOF > $rootfs_path/etc/hosts
127.0.0.1 localhost $name 127.0.0.1 localhost $name
::1 localhost6.localdomain6 localhost6
EOF EOF
dev_path="${rootfs_path}/dev" dev_path="${rootfs_path}/dev"
...@@ -254,6 +276,8 @@ lxc.pts = 1024 ...@@ -254,6 +276,8 @@ lxc.pts = 1024
lxc.mount = $config_path/fstab lxc.mount = $config_path/fstab
lxc.cap.drop = sys_module mac_admin mac_override sys_time 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: # When using LXC with apparmor, uncomment the next line to run unconfined:
#lxc.aa_profile = unconfined #lxc.aa_profile = unconfined
...@@ -321,7 +345,7 @@ Mandatory args: ...@@ -321,7 +345,7 @@ Mandatory args:
Optional 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 -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 -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] -A,--arch NOT USED YET. Define what arch the container will be [i686,x86_64]
-h,--help print this help -h,--help print this help
EOF EOF
...@@ -366,7 +390,7 @@ fi ...@@ -366,7 +390,7 @@ fi
if [ -n "$needed_pkgs" ]; then if [ -n "$needed_pkgs" ]; then
echo "Missing commands: $needed_pkgs" 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 exit 1
fi fi
...@@ -375,14 +399,22 @@ if [ -z "$path" ]; then ...@@ -375,14 +399,22 @@ if [ -z "$path" ]; then
fi fi
if [ -z "$release" ]; then if [ -z "$release" ]; then
if [ "$is_fedora" ]; then if [ "$is_fedora" -a "$fedora_host_ver" ]; then
release=$(cat /etc/fedora-release |awk '/^Fedora/ {print $3}') release=$fedora_host_ver
else else
echo "This is not a fedora host and release missing, defaulting to 14. use -R|--release to specify release" echo "This is not a fedora host and release missing, defaulting to 17. use -R|--release to specify release"
release=14 release=17
fi fi
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 if [ "$(id -u)" != "0" ]; then
echo "This script should be run as 'root'" echo "This script should be run as 'root'"
exit 1 exit 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment