-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheadless
34 lines (27 loc) · 876 Bytes
/
headless
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
#!/bin/bash
CFG_FILE=$(ls /boot/headless* 2>/dev/null)
if [ "$CFG_FILE" != "" ]; then
echo "Headless mode enabled"
echo "Disabling initial-setup service"
systemctl stop initial-setup.service
systemctl disable initial-setup.service
CFG_OPTS=$(grep '[0-9]' "$CFG_FILE")
if [ "$CFG_OPTS" != "" ]; then
IPADDR=$(sed -n 's/IPADDR=//p' $CFG_FILE)
NETMASK=$(sed -n 's/NETMASK=//p' $CFG_FILE)
GATEWAY=$(sed -n 's/GATEWAY=//p' $CFG_FILE)
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=$IPADDR
NETMASK=$NETMASK
GATEWAY=$GATEWAY
BOOTPROTO=static
ONBOOT=yes
NM_CONTROLLED=yes
EOF
systemctl restart NetworkManager.service
fi
fi
# Always disable headless-check.service after first use.
echo "Disabling initial-setup service"
systemctl disable headless-check.service