openkubsd/bin/configure_template.sh

90 lines
2.4 KiB
Bash
Raw Permalink Normal View History

2023-06-08 21:01:37 +00:00
#!/bin/sh
set -x
FILE=$(mktemp /tmp/file.XXXXXXXXXXXXXXXXXXXXX)
cat <<EOF >$FILE
sed -i 's/^#X11Forwarding no/X11Forwarding yes/' /etc/ssh/sshd_config
echo "permit nopass keepenv user" > /etc/doas.conf
echo 'https://cdn.openbsd.org/pub/OpenBSD/' > /etc/installurl
if ! grep 'library_aslr=NO' /etc/rc.conf.local >/dev/null
then
echo 'library_aslr=NO' >> /etc/rc.conf.local
fi
2023-07-22 10:35:29 +00:00
pkg_add openbox neofetch xneko dillo firefox-esr chromium claws-mail-- thunar keepassxc-- lagrange clic catgirl dino aerc xfce4-terminal stumpwm xclip mousepad
2023-06-08 21:01:37 +00:00
2023-06-09 21:50:37 +00:00
# we want sshd to be started by rc.local
# so copied/mounted /home is ready
rcctl disable sshd
2023-06-14 11:55:22 +00:00
# enable sndiod with a higher buffer to prevent stuttering
rcctl enable sndiod
rcctl set sndiod flags -b34000
2023-06-14 11:37:48 +00:00
cat <<NESTED >/etc/stumpwmrc
(setf *startup-message* nil)
(defun st-kill-empty (a)
(if (= 0 (length (screen-windows (current-screen))))
(stumpwm:quit)))
(stumpwm:add-hook stumpwm:*destroy-window-hook* 'st-kill-empty)
NESTED
2023-06-08 21:01:37 +00:00
cat <<NESTED >/etc/rc.local
#!/bin/sh
HOST=\\\$(awk '/^host-name/ { print \\\$2}' /var/db/dhcpleased/vio0)
hostname "\\\${HOST}.kube"
2023-06-11 15:16:04 +00:00
# this triggers in non-templates
2023-06-08 21:01:37 +00:00
if sysctl hw.disknames | grep sd1 >/dev/null
then
2023-06-13 16:52:12 +00:00
mount -o noatime -u /usr/local
mount -o noatime -u /usr/X11R6
mount -o noatime -u /usr
mount -o noatime -u /tmp
mount -o noatime -u /var
mount -o noatime -u /
2023-06-09 21:50:37 +00:00
if ! dumpfs /dev/rsd1c >/dev/null 2>/dev/null
then
echo "Formatting the empty disk"
fdisk -iy sd1c
disklabel -d sd1
newfs /dev/rsd1c
mount /dev/sd1c /mnt/
cd /home/ && pax -rw -p e . /mnt && cd -
umount /mnt
fi
echo "fsck and mounting the disk on /home"
fsck_ffs -y /dev/rsd1c
2023-06-13 16:52:12 +00:00
2023-06-09 21:50:37 +00:00
mount -o rw,nodev,noatime,nosuid /dev/sd1c /home
2023-06-10 08:41:14 +00:00
install -d -o root /home/openkubsd/
if ! test -f /home/openkubsd/rc.local
then
printf '#!/bin/sh\n\n# use this file to add Kube specific boot commands\n' > /home/openkubsd/rc.local
chmod +x /home/openkubsd/rc.local
fi
/home/openkubsd/rc.local
2023-06-11 15:16:04 +00:00
install -d -o user /shared/
mount 10.100.0.1:/var/openkubsd/shared/\\\$(hostname -s) /shared/
2023-06-08 21:01:37 +00:00
fi
2023-06-09 21:50:37 +00:00
/etc/rc.d/sshd -f start
2023-06-08 21:01:37 +00:00
NESTED
chmod +x /etc/rc.local
2023-06-10 08:41:14 +00:00
# stop the template
halt
2023-06-08 21:01:37 +00:00
EOF
2023-06-14 11:37:48 +00:00
./connect.sh openbsd-template "xterm -e /bin/sh -c 'sleep 5 && exit'"
2023-06-11 15:16:46 +00:00
2023-06-08 21:01:37 +00:00
cat $FILE | ssh -o StrictHostKeyChecking=no root@openbsd-template.kube "cat >/$FILE"
ssh -o StrictHostKeyChecking=no root@openbsd-template.kube "sh /$FILE"
2023-06-11 15:16:46 +00:00
rm "$FILE"