-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathenable_dhcp.sh
executable file
·38 lines (32 loc) · 1.03 KB
/
enable_dhcp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
#
# Re-enable the default DHCP-based NetworkManager support. Use to revert the
# static IP configuration performed by the enable_static_ip.sh script.
#
# Example usage:
# enable_dhcp.sh
#
# WARNING: Do not use this script if there is a custom network configuration
# set up in /etc/network/interfaces as it will be overwritten.
set -e
if [[ ${UID} -ne 0 ]]; then
echo "This script must be run as root!"
exit 1
fi
if grep -qi kuiper "/etc/os-release"; then
cat <<-EOF > /etc/dhcpcd.conf
hostname
EOF
systemctl daemon-reload
systemctl restart dhcpcd.service
else
echo "Re-enabling DHCP via NetworkManager for all network interfaces"
cat <<-EOF > /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
EOF
# enable DHCP via NetworkManager (assumes the config file hasn't been touched much)
sed -i 's/^managed=true/managed=false/' /etc/NetworkManager/NetworkManager.conf
service network-manager restart
fi