# XXX fixme : when creating a 32bits VM we need to call linux32 as appropriate...s
-DEFAULT_FCDISTRO=f33
+DEFAULT_FCDISTRO=f37
DEFAULT_PLDISTRO=lxc
DEFAULT_PERSONALITY=linux64
DEFAULT_MEMORY=3072
}
### return
-# ifcfg for redhat's
-# interfaces for older debian/uuntu
-# systemd for more recent debian/ubuntu
-function network_method () {
+# ifcfg for fedora up to 36
+# networkmanager for fedora starting with f37 (probably works with older as well...)
+# interfaces for older debian/uuntu
+# systemd for more recent debian/ubuntu
+function network_config_method () {
local fcdistro=$1; shift
case $fcdistro in
- f[0-9]*|centos[0-9]*|sl[0-9]*)
+ # have not used centos or scientific linux for a very long time
+ #f[0-9]*|centos[0-9]*|sl[0-9]*)
+ f2*|f3[0-6])
echo ifcfg ;;
+ f3[7-9]|f[4-9]*)
+ echo networkmanager ;;
wheezy|jessie|trusty|xenial|bionic)
echo interfaces ;;
focal|jammy)
echo systemd ;;
*)
- echo "Unknown network_method for distro $fcdistro" ;;
+ echo "Unknown network_config_method for distro $fcdistro" ;;
esac
}
fedora_configure_systemd $lxc
- local guest_ifcfg=${lxc_root}/etc/sysconfig/network-scripts/ifcfg-$VIF_GUEST
- mkdir -p $(dirname ${guest_ifcfg})
- # starting with f27, we go for NetworkManager
- # no more NM_CONTROLLED nonsense
- if [ -n "$NAT_MODE" ]; then
- write_guest_ifcfg_natip
- else
- write_guest_ifcfg_publicip
- fi > $guest_ifcfg
+ fedora_configure_network $lxc
[ -z "$IMAGE" ] && fedora_configure_yum $lxc $fcdistro $pldistro
return 0
}
+function fedora_configure_network() {
+ local lxc="$1"
+ case $(network_config_method $fcdistro) in
+ ifcfg)
+ # probably no longer useful
+ local guest_ifcfg=${lxc_root}/etc/sysconfig/network-scripts/ifcfg-$VIF_GUEST
+ mkdir -p $(dirname ${guest_ifcfg})
+ if [ -n "$NAT_MODE" ]; then
+ write_guest_ifcfg_natip
+ else
+ write_guest_ifcfg_publicip
+ fi > $guest_ifcfg
+ ;;
+ networkmanager)
+ local guest_keyfile=${lxc_root}/etc/NetworkManager/system-connections/'Wired connection 1.nmconnection'
+ mkdir -p $(dirname "${guest_keyfile}")
+ if [ -n "$NAT_MODE" ]; then
+ write_guest_networkmanager_natip
+ else
+ write_guest_networkmanager_publicip
+ fi > "$guest_keyfile"
+ chmod 600 "$guest_keyfile"
+ ;;
+ esac
+}
+
# this code of course is for guests that do run on systemd
function fedora_configure_systemd() {
set -e
# sed -i 's/After=dev-%i.device/After=/' ${lxc_root}/lib/systemd/system/getty\@.service
ln -sf /dev/null ${lxc_root}/etc/systemd/system/"getty@.service"
rm -f ${lxc_root}/etc/systemd/system/getty.target.wants/*service || :
-# can't seem to handle this one with systemctl
-# second part should trigger starting with fedora31, where the network target is not manually manageable
- chroot ${lxc_root} $personality chkconfig network on || chroot ${lxc_root} $personality systemctl enable NetworkManager
+ chroot ${lxc_root} $personality systemctl enable NetworkManager
}
# overwrite container yum config
function debian_configure () {
local lxc=$1; shift
local fcdistro=$1; shift
- case $(network_method $fcdistro) in
+ case $(network_config_method $fcdistro) in
interfaces)
local guest_interfaces=${lxc_root}/etc/network/interfaces
( [ -n "$NAT_MODE" ] \
EOF
}
+function uuid() {
+ python -c "import uuid; print(uuid.uuid1())"
+}
+# xxx this seems to be no longer needed ?
+function write_guest_networkmanager_natip() {
+ cat << EOF
+EOF
+}
+function write_guest_networkmanager_publicip() {
+ cat << EOF
+[connection]
+id=Wired connection 1
+uuid=$(uuid)
+type=ethernet
+autoconnect-priority=-999
+# setting this seems to be counter-productive
+# interface-name=${VIF_GUEST}
+
+[ipv4]
+address1=${GUEST_IP}/${MASKLEN},${GATEWAY}
+#dhcp-hostname=${GUEST_HOSTNAME}
+method=manual
+EOF
+}
+
##############################
function setup_lxc() {
### set up resolv.conf from host
# ubuntu precise and on, /etc/resolv.conf is a symlink to ../run/resolvconf/resolv.conf
[ -h $lxc_root/etc/resolv.conf ] && rm -f $lxc_root/etc/resolv.conf
- cp /etc/resolv.conf $lxc_root/etc/resolv.conf
+ ### since fedora36, our hosts use systemd-resolved, but the guests can't use that
+ # so the administrator has the option to create /etc/resolv.conf.containers
+ # and if that file exists it will be copied in the containers instead of /etc/resolv.conf
+ if [ -f /etc/resolv.conf.containers ]; then
+ cp /etc/resolv.conf.containers $lxc_root/etc/resolv.conf
+ else
+ cp /etc/resolv.conf $lxc_root/etc/resolv.conf
+ fi
### and /etc/hosts for at least localhost
[ -f $lxc_root/etc/hosts ] || echo "127.0.0.1 localhost localhost.localdomain" > $lxc_root/etc/hosts
[ -f /etc/sysconfig/network ] || /bin/echo NETWORKING=yes > /etc/sysconfig/network
# turn off regular crond, as plc invokes plc_crond
- /sbin/chkconfig crond off
+ /sbin/chkconfig crond off >& /dev/null
# customize root's prompt
/bin/cat << PROFILE > /root/.profile