Compare commits

..

3 Commits

Author SHA1 Message Date
8b19927606 removed docker script, moved to single script 2025-10-24 14:14:47 +02:00
a88b84669b added ability to run script unattended (pass ROOT_PASSWORD variable from outside environment) 2025-10-24 13:48:59 +02:00
935aa95ec7 added postinstall scripts
they will be versioned and accessed through a git web interface instead of a static website
2025-04-20 23:07:55 +02:00
4 changed files with 58 additions and 11 deletions

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash
apt-get update
apt-get install -y xorriso genisoimage
cd /root/unattended
ISONAME=$(ls | grep "netinst.iso" | sort | tail -n1 | sed 's/netinst/unattended/')
genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ${ISONAME} isofiles
chown 1000:1000 ${ISONAME}

8
postinstall/init.service Normal file
View 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
View 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

View File

@@ -1,12 +1,15 @@
#!/usr/bin/env bash
# Get password from user prompt and set it in preseed
read -sp "Enter the root password: " ROOT_PASSWORD
if [ -z "$ROOT_PASSWORD" ]; then
read -sp "Enter the root password: " ROOT_PASSWORD
fi
cp -f template.cfg preseed.cfg
sed -i "s/ROOT_PASSWORD/${ROOT_PASSWORD}/" preseed.cfg
# Get the file name
ISONAME=$(ls | grep "netinst.iso" | sort | tail -n1)
UNAME=$(echo ${ISONAME} | sed 's/netinst/unattended/')
# Remove an already existing unattended iso of this same version, if existing
rm -f $(echo ${ISONAME} | sed 's/netinst/unattended/')
# Extract iso files
@@ -34,6 +37,6 @@ cd ..
# Repackage all the iso files
chmod a+w isofiles/isolinux/isolinux.bin
docker run --interactive --tty --rm --volume $(pwd):/root/unattended debian:buster /root/unattended/docker.sh
genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ${UNAME} isofiles
# Remove the extracted (temporary) files and the preseed with the plaintext password
sudo rm -rf isofiles preseed.cfg