summaryrefslogtreecommitdiffstats
path: root/share/scripts/debconf
diff options
context:
space:
mode:
Diffstat (limited to 'share/scripts/debconf')
-rwxr-xr-xshare/scripts/debconf217
1 files changed, 164 insertions, 53 deletions
diff --git a/share/scripts/debconf b/share/scripts/debconf
index fbabab4..46f0381 100755
--- a/share/scripts/debconf
+++ b/share/scripts/debconf
@@ -139,15 +139,6 @@ 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}"
@@ -474,11 +465,14 @@ EOF
if [ -n "${DIG}" ]
then
- IPV4_ADDRESS1="$(${DIG} +short ${NAME} | tail -n1)"
+ IPV4_ADDRESS1="$(${DIG} A +short ${NAME} | tail -n1)"
IPV4_ADDRESS1_PART1="$(echo ${IPV4_ADDRESS1} | cut -d. -f1)"
IPV4_ADDRESS1_PART2="$(echo ${IPV4_ADDRESS1} | cut -d. -f2)"
IPV4_ADDRESS1_PART3="$(echo ${IPV4_ADDRESS1} | cut -d. -f3)"
IPV4_ADDRESS1_PART4="$(echo ${IPV4_ADDRESS1} | cut -d. -f4)"
+
+ IPV6_ADDRESS1="$(${DIG} AAAA +short ${NAME} | tail -n1)"
+ # TODO: address parts
fi
sed -e "s|@NAME@|${NAME}|g" \
@@ -487,6 +481,7 @@ EOF
-e "s|@IPV4_ADDRESS1_PART2@|${IPV4_ADDRESS1_PART2}|g" \
-e "s|@IPV4_ADDRESS1_PART3@|${IPV4_ADDRESS1_PART3}|g" \
-e "s|@IPV4_ADDRESS1_PART4@|${IPV4_ADDRESS1_PART4}|g" \
+ -e "s|@IPV6_ADDRESS1@|${IPV6_ADDRESS1}|g" \
"${FILE}" >> "${DIRECTORY}/preseed.cfg"
done
@@ -631,27 +626,50 @@ Configure_network ()
fi
# Create /etc/hosts
- case "${NETWORK1_IPV4_METHOD}" in
- none|dhcp)
+ rm -f "${DIRECTORY}/etc/hosts.tmp"
-cat > "${DIRECTORY}/etc/hosts.tmp" << EOF
-127.0.0.1 localhost ${NAME}
+ if [ -n "${NETWORK1_IPV4_ADDRESS}" ]
+ then
-# The following lines are desirable for IPv6 capable hosts
-::1 ip6-localhost ip6-loopback
-fe00::0 ip6-localnet
-ff00::0 ip6-mcastprefix
-ff02::1 ip6-allnodes
-ff02::2 ip6-allrouters
+cat >> "${DIRECTORY}/etc/hosts.tmp" << EOF
+${NETWORK1_IPV4_ADDRESS} ${NAME}
EOF
- ;;
+ fi
+
+ if [ -n "${NETWORK1_IPV6_ADDRESS}" ]
+ then
+
+cat >> "${DIRECTORY}/etc/hosts.tmp" << EOF
+${NETWORK1_IPV6_ADDRESS} ${NAME}
+EOF
- static)
+ fi
+
+ if [ -n "${NETWORK1_IPV4_ADDRESS}" ] || [ -n "${NETWORK1_IPV6_ADDRESS}" ]
+ then
+ echo >> "${DIRECTORY}/etc/hosts.tmp"
+ fi
+
+ if [ -z "${NETWORK1_IPV4_ADDRESS}" ] && [ -z "${NETWORK1_IPV6_ADDRESS}" ]
+ then
+ # localhost only
+
+cat > "${DIRECTORY}/etc/hosts.tmp" << EOF
+127.0.0.1 localhost ${NAME}
+::1 localhost ${NAME}
+EOF
+
+ else
cat > "${DIRECTORY}/etc/hosts.tmp" << EOF
127.0.0.1 localhost
-${NETWORK1_IPV4_ADDRESS} ${NAME}
+::1 localhost
+EOF
+
+ fi
+
+cat >> "${DIRECTORY}/etc/hosts.tmp" << EOF
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
@@ -661,9 +679,6 @@ ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
- ;;
- esac
-
mv "${DIRECTORY}/etc/hosts.tmp" "${DIRECTORY}/etc/hosts"
}
@@ -684,54 +699,66 @@ Configure_systemd_networkd ()
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
+ eval IPV6_COMMENT="$`echo NETWORK${NUMBER}_IPV6_COMMENT`"
+ eval IPV6_METHOD="$`echo NETWORK${NUMBER}_IPV6_METHOD`"
+ eval IPV6_ADDRESS="$`echo NETWORK${NUMBER}_IPV6_ADDRESS`"
+ eval IPV6_GATEWAY="$`echo NETWORK${NUMBER}_IPV6_GATEWAY`"
+ eval IPV6_NETMASK="$`echo NETWORK${NUMBER}_IPV6_NETMASK`"
+ eval IPV6_POST_UP="$`echo NETWORK${NUMBER}_IPV6_POST_UP`"
+ eval IPV6_POST_DOWN="$`echo NETWORK${NUMBER}_IPV6_POST_DOWN`"
- IPV4_SUFFIX="$(CIDR ${IPV4_NETMASK})"
- IPV4_CIDR="${IPV4_ADDRESS}/${IPV4_SUFFIX}"
+ if [ "${IPV4_METHOD}" != "none" ] || [ "${IPV6_METHOD}" != "none" ]
+ then
cat > "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
[Match]
Name=eno${NUMBER}
+EOF
+
+ fi
+
+ if [ -n "${IPV4_METHOD}" ] && [ "${IPV4_METHOD}" != "none" ]
+ then
+
+cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
[Network]
EOF
- if [ -n "${IPV4_COMMENT}" ]
- then
- echo "Description=${IPV4_COMMENT}" >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network"
- fi
+ if [ -n "${IPV4_COMMENT}" ]
+ then
+ echo "Description=${IPV4_COMMENT}" >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network"
+ fi
- case "${IPV4_METHOD}" in
- dhcp)
+ case "${IPV4_METHOD}" in
+ dhcp)
cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
DHCP=ipv4
EOF
- ;;
+ ;;
- static)
+ static)
cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
DHCP=no
-Address=${IPV4_CIDR}
+Address=${IPV4_ADDRESS}/${IPV4_NETMASK}
EOF
- if [ -n "${IPV4_GATEWAY}" ]
- then
+ if [ -n "${IPV4_GATEWAY}" ]
+ then
cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
Gateway=${IPV4_GATEWAY}
EOF
- fi
- esac
+ fi
+ ;;
+ esac
- if [ -n "${IPV4_POST_UP}" ]
- then
+ if [ -n "${IPV4_POST_UP}" ]
+ then
cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-up-eno${NUMBER}.service" << EOF
[Unit]
@@ -747,11 +774,11 @@ ExecStart=/bin/sh -c "${IPV4_POST_UP}"
WantedBy=multi-user.target
EOF
- chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-up-eno${NUMBER}.service
- fi
+ chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-up-eno${NUMBER}.service
+ fi
- if [ -n "${IPV4_POST_DOWN}" ]
- then
+ if [ -n "${IPV4_POST_DOWN}" ]
+ then
cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-down-eno${NUMBER}.service" << EOF
[Unit]
@@ -767,7 +794,90 @@ ExecStart=/bin/sh -c "${IPV4_POST_DOWN}"
WantedBy=multi-user.target
EOF
- chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-down-eno${NUMBER}.service
+ chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-down-eno${NUMBER}.service
+ fi
+ fi
+
+ if [ -n "${IPV6_METHOD}" ] && [ "${IPV6_METHOD}" != "none" ]
+ then
+
+cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
+
+[Network]
+EOF
+
+ if [ -n "${IPV6_COMMENT}" ]
+ then
+ echo "Description=${IPV6_COMMENT}" >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network"
+ fi
+
+ case "${IPV6_METHOD}" in
+ dhcp)
+
+cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
+DHCP=ipv6
+EOF
+
+ ;;
+
+ static)
+
+cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
+DHCP=no
+Ipv6AcceptRA=no
+Address=${IPV6_ADDRESS}/${IPV6_NETMASK}
+EOF
+
+ if [ -n "${IPV6_GATEWAY}" ]
+ then
+
+cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
+Gateway=${IPV6_GATEWAY}
+EOF
+
+ fi
+ ;;
+ esac
+
+ if [ -n "${IPV6_POST_UP}" ]
+ then
+
+cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv6-post-up-eno${NUMBER}.service" << EOF
+[Unit]
+Description=${SOFTWARE} IPV6_POST_UP
+After=network-online.target
+Wants=network-online.target
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -c "${IPV6_POST_UP}"
+
+[Install]
+WantedBy=multi-user.target
+EOF
+
+ chroot "${DIRECTORY}" systemctl enable cnt-ipv6-post-up-eno${NUMBER}.service
+ fi
+
+ if [ -n "${IPV6_POST_DOWN}" ]
+ then
+
+cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv6-post-down-eno${NUMBER}.service" << EOF
+[Unit]
+Description=${SOFTWARE} IPV6_POST_DOWN
+After=network.target
+Wants=network.target
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -c "${IPV6_POST_DOWN}"
+
+[Install]
+WantedBy=multi-user.target
+EOF
+
+ chroot "${DIRECTORY}" systemctl enable cnt-ipv6-post-down-eno${NUMBER}.service
+ fi
fi
NUMBER="$((${NUMBER} + 1))"
@@ -796,8 +906,9 @@ Commands ()
for NUMBER in $(seq 2 ${NETWORK_NUMBER})
do
eval IPV4_METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`"
+ eval IPV6_METHOD="$`echo NETWORK${NUMBER}_IPV6_METHOD`"
- if [ -z "${IPV4_METHOD}" ]
+ if [ -z "${IPV4_METHOD}" ] && [ -z "${IPV6_METHOD}" ]
then
continue
fi