summaryrefslogtreecommitdiffstats
path: root/share/scripts/debconf
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xshare/scripts/debconf172
1 files changed, 87 insertions, 85 deletions
diff --git a/share/scripts/debconf b/share/scripts/debconf
index 4878d98..6fab784 100755
--- a/share/scripts/debconf
+++ b/share/scripts/debconf
@@ -123,6 +123,15 @@ Chroot ()
${@}
}
+CIDR ()
+{
+ x=${1##*255.}
+ set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*}
+
+ x=${1%%$3*}
+ echo $(( $2 + (${#x}/4) ))
+}
+
Upgrade_system ()
{
DIRECTORY="${1}"
@@ -238,11 +247,11 @@ Debootstrap ()
# FIXME: trim down, debootstrap variants?
case "${MODE}" in
debian)
- INCLUDE="${INCLUDE},ifupdown,locales,libui-dialog-perl,dialog,isc-dhcp-client,netbase,net-tools,iproute,wget"
+ INCLUDE="${INCLUDE},locales,libui-dialog-perl,dialog,isc-dhcp-client,netbase,net-tools,iproute,wget"
;;
progress-linux)
- INCLUDE="${INCLUDE},apt-utils,ifupdown,locales-all,libui-dialog-perl,dialog,isc-dhcp-client,netbase,net-tools,iproute,openssh-server,wget"
+ INCLUDE="${INCLUDE},apt-utils,locales-all,libui-dialog-perl,dialog,isc-dhcp-client,netbase,net-tools,iproute,openssh-server,wget"
;;
esac
@@ -735,91 +744,9 @@ EOF
Configure_network ()
{
- # Create /etc/network/interfaces
-
DIRECTORY="${1}"
-cat > "${DIRECTORY}/etc/network/interfaces.tmp" << EOF
-# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
-# /usr/share/doc/ifupdown/examples for more information.
-EOF
-
- for NUMBER in $(seq 0 ${NETWORK_NUMBER})
- do
- eval IPV4_COMMENT="$`echo NETWORK${NUMBER}_IPV4_COMMENT`"
- eval IPV4_METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`"
- eval IPV4_ADDRESS="$`echo NETWORK${NUMBER}_IPV4_ADDRESS`"
- eval IPV4_GATEWAY="$`echo NETWORK${NUMBER}_IPV4_GATEWAY`"
- eval IPV4_NETMASK="$`echo NETWORK${NUMBER}_IPV4_NETMASK`"
- eval IPV4_POST_UP="$`echo NETWORK${NUMBER}_IPV4_POST_UP`"
- eval IPV4_POST_DOWN="$`echo NETWORK${NUMBER}_IPV4_POST_DOWN`"
-
- if [ -z "${IPV4_METHOD}" ]
- then
- continue
- fi
-
- echo >> "${DIRECTORY}/etc/network/interfaces.tmp"
-
- if [ -n "${IPV4_COMMENT}" ]
- then
- echo "# ${IPV4_COMMENT}" >> "${DIRECTORY}/etc/network/interfaces.tmp"
- fi
-
- case "${IPV4_METHOD}" in
- none)
-
-cat >> "${DIRECTORY}/etc/network/interfaces.tmp" << EOF
-iface eth${NUMBER} inet manual
-EOF
-
- ;;
-
- dhcp)
-
-cat >> "${DIRECTORY}/etc/network/interfaces.tmp" << EOF
-auto eth${NUMBER}
-iface eth${NUMBER} inet dhcp
-EOF
-
- ;;
-
- static)
-
-cat >> "${DIRECTORY}/etc/network/interfaces.tmp" << EOF
-auto eth${NUMBER}
-iface eth${NUMBER} inet static
- address ${IPV4_ADDRESS}
-EOF
-
- if [ -n "${IPV4_GATEWAY}" ]
- then
- echo " gateway ${IPV4_GATEWAY}" >> "${DIRECTORY}/etc/network/interfaces.tmp"
- fi
-
- if [ -n "${IPV4_NETMASK}" ]
- then
- echo " netmask ${IPV4_NETMASK}" >> "${DIRECTORY}/etc/network/interfaces.tmp"
- fi
-
- if [ -n "${IPV4_POST_UP}" ]
- then
- echo " post-up ${IPV4_POST_UP}" >> "${DIRECTORY}/etc/network/interfaces.tmp"
- fi
-
- if [ -n "${IPV4_POST_DOWN}" ]
- then
- echo " post-down ${IPV4_POST_DOWN}" >> "${DIRECTORY}/etc/network/interfaces.tmp"
- fi
- ;;
- esac
-
- NUMBER="$((${NUMBER} + 1))"
- done
-
- mv "${DIRECTORY}/etc/network/interfaces.tmp" "${DIRECTORY}/etc/network/interfaces"
-
- # create /etc/resolv.conf
+ # Create /etc/resolv.conf
rm -f "${DIRECTORY}/etc/resolv.conf.tmp"
if [ -n "${NAMESERVER_DOMAIN}" ]
@@ -897,6 +824,80 @@ EOF
mv "${DIRECTORY}/etc/hosts.tmp" "${DIRECTORY}/etc/hosts"
}
+Configure_systemd_networkd ()
+{
+ # FIXME: postup/postdown: multi-interface route
+
+ DIRECTORY="${1}"
+
+ # Enable systemd-networkd
+ chroot "${DIRECTORY}" apt purge --yes ifupdown || true
+
+ rm -f "${DIRECTORY}/etc/network/interfaces"
+ rmdir --ignore-fail-on-non-empty --parents "${DIRECTORY}"/etc/network/* > /dev/null 2>&1 || true
+
+ chroot "${DIRECTORY}" systemctl enable systemd-networkd
+
+ for NUMBER in $(seq 0 ${NETWORK_NUMBER})
+ do
+ eval IPV4_COMMENT="$`echo NETWORK${NUMBER}_IPV4_COMMENT`"
+ eval IPV4_METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`"
+ eval IPV4_ADDRESS="$`echo NETWORK${NUMBER}_IPV4_ADDRESS`"
+ eval IPV4_GATEWAY="$`echo NETWORK${NUMBER}_IPV4_GATEWAY`"
+ eval IPV4_NETMASK="$`echo NETWORK${NUMBER}_IPV4_NETMASK`"
+# eval IPV4_POST_UP="$`echo NETWORK${NUMBER}_IPV4_POST_UP`"
+# eval IPV4_POST_DOWN="$`echo NETWORK${NUMBER}_IPV4_POST_DOWN`"
+
+ if [ -z "${IPV4_METHOD}" ]
+ then
+ continue
+ fi
+
+ IPV4_SUFFIX="$(CIDR ${IPV4_NETMASK})"
+ IPV4_CIDR="${IPV4_ADDRESS}/${IPV4_SUFFIX}"
+
+cat > "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network" << EOF
+[Match]
+Name=eth${NUMBER}
+
+[Network]
+EOF
+
+ if [ -n "${IPV4_COMMENT}" ]
+ then
+ echo "Description=${IPV4_COMMENT}" >> "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network"
+ fi
+
+ case "${IPV4_METHOD}" in
+ dhcp)
+
+cat >> "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network" << EOF
+DHCP=ipv4
+EOF
+
+ ;;
+
+ static)
+
+cat >> "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network" << EOF
+DHCP=no
+Address=${IPV4_CIDR}
+EOF
+
+ if [ -n "${IPV4_GATEWAY}" ]
+ then
+
+cat >> "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network" << EOF
+Gateway=${IPV4_GATEWAY}
+EOF
+
+ fi
+ esac
+
+ NUMBER="$((${NUMBER} + 1))"
+ done
+}
+
Commands ()
{
DIRECTORY="${1}"
@@ -1045,6 +1046,7 @@ fi
Configure_system "${MACHINES}/${NAME}"
Configure_network "${MACHINES}/${NAME}"
+Configure_systemd_networkd "${MACHINES}/${NAME}" # FIXME
Cleanup_system "${MACHINES}/${NAME}"
Commands "${MACHINES}/${NAME}"