##// END OF EJS Templates
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig

Fichier de la dernière révision:

r71:b855bcffebe1
r71:b855bcffebe1
Show More
20-networking.sh
72 lines | 2.2 KiB | application/x-sh | BashLexer
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 #
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 # Setup Networking
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 #
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 # Load utility functions
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 . ./functions.sh
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Install and setup hostname
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 install_readonly files/network/hostname $R/etc/hostname
Jan Wagner
code cleanup and even more spliting
r70 sed -i "s/^rpi2-jessie/${HOSTNAME}/" $R/etc/hostname
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Install and setup hosts
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 install_readonly files/network/hosts $R/etc/hosts
Jan Wagner
code cleanup and even more spliting
r70 sed -i "s/rpi2-jessie/${HOSTNAME}/" $R/etc/hosts
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Setup hostname entry with static IP
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 if [ "$NET_ADDRESS" != "" ] ; then
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 NET_IP=$(echo ${NET_ADDRESS} | cut -f 1 -d'/')
sed -i "s/^127.0.1.1/${NET_IP}/" $R/etc/hosts
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 fi
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Remove IPv6 hosts
if [ "$ENABLE_IPV6" = false ] ; then
sed -i -e "/::[1-9]/d" -e "/^$/d" $R/etc/hosts
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 fi
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Install hint about network configuration
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 install_readonly files/network/interfaces $R/etc/network/interfaces
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Install configuration for interface eth0
install_readonly files/network/eth.network $R/etc/systemd/network/eth.network
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 if [ "$ENABLE_DHCP" = true ] ; then
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Enable DHCP configuration for interface eth0
sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" $R/etc/systemd/network/eth.network
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56
Jan Wagner
code cleanup and even more spliting
r70 # Set DHCP configuration to IPv4 only
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 if [ "$ENABLE_IPV6" = false ] ; then
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 sed -i "s/DHCP=.*/DHCP=v4/" $R/etc/systemd/network/eth.network
Jan Wagner
spliting more files, fix-uboot, fix-fbturbo, fix-locale
r67 fi
Jan Wagner
code cleanup and even more spliting
r70
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 else # ENABLE_DHCP=false
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Set static network configuration for interface eth0
sed -i\
-e "s|DHCP=.*|DHCP=no|"\
-e "s|Address=\$|Address=${NET_ADDRESS}|"\
-e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\
-e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\
-e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\
-e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
-e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
-e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
$R/etc/systemd/network/eth.network
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 fi
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Remove empty settings from network configuration
sed -i "/.*=\$/d" $R/etc/systemd/network/eth.network
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 # Enable systemd-networkd service
chroot_exec systemctl enable systemd-networkd
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Install host.conf resolver configuration
install_readonly files/network/host.conf $R/etc/host.conf
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 # Enable network stack hardening
if [ "$ENABLE_HARDNET" = true ] ; then
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Install sysctl.d configuration files
Jan Wagner
vknecht-master-merge
r68 install_readonly files/sysctl.d/82-rpi-net-hardening.conf $R/etc/sysctl.d/82-rpi-net-hardening.conf
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56
Jan Wagner
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
r71 # Setup resolver warnings about spoofed addresses
sed -i "s/^# spoof warn/spoof warn/" $R/etc/host.conf
Filip Pytloun
Refactor: split bootstrap actions and allow custom
r56 fi