added postinstall scripts
they will be versioned and accessed through a git web interface instead of a static website
This commit is contained in:
parent
e163e59d09
commit
935aa95ec7
8
postinstall/init.service
Normal file
8
postinstall/init.service
Normal file
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Postinstall Init
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/env bash /debian-postinstall-init.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
45
postinstall/init.sh
Normal file
45
postinstall/init.sh
Normal file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Sometimes the network is slow, wait a bit
|
||||
sleep 10
|
||||
|
||||
# Get the current DHCP network address (and gateway)
|
||||
NIC=$(ip link | grep "^2:" | awk '{print $2}' | tr -d ":")
|
||||
IP_ADDRESS=$(ip address show ${NIC} | grep -E "inet " | awk '{print $2}')
|
||||
NETMASK=$(echo ${IP_ADDRESS} | sed 's/.*\///')
|
||||
IP_ADDRESS=$(echo ${IP_ADDRESS} | sed 's/\/.*//')
|
||||
GATEWAY=$(ip route | grep "default" | awk '{print $3}')
|
||||
|
||||
# Network interfaces (static address)
|
||||
cat << EOF > /etc/network/interfaces
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
auto ${NIC}
|
||||
iface ${NIC} inet static
|
||||
address ${IP_ADDRESS}/${NETMASK}
|
||||
gateway ${GATEWAY}
|
||||
EOF
|
||||
|
||||
# Tabs instead of spaces, neat the file
|
||||
sed -i 's/ /\t/gm' /etc/network/interfaces
|
||||
|
||||
# Hosts file
|
||||
cat << EOF > /etc/hosts
|
||||
127.0.0.1 localhost localhost.localdomain
|
||||
::1 localhost localhost.localdomain
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
|
||||
${IP_ADDRESS} $(hostname --fqdn) $(hostname)
|
||||
EOF
|
||||
|
||||
# Tabs instead of spaces, neat the file
|
||||
sed -i 's/ /\t/gm' /etc/hosts
|
||||
|
||||
# Personalizations
|
||||
wget -O - https://45r.it/serversetup | bash
|
||||
|
||||
# Cleanup and reboot
|
||||
rm -rf /etc/systemd/system/multi-user.target.wants/postinstall-init.service /var/lib/systemd/system/postinstall-init.service /debian-postinstall-init.sh /.wget-hsts
|
||||
reboot
|
Loading…
Reference in New Issue
Block a user