#! /bin/ash
apk update
apk add --upgrade apk-tools
apk add --upgrade \
busybox \
busybox-doc \
busybox-extras \
busybox-initscripts \
busybox-suid \
curl \
curl-dev \
curl-doc \
doas \
doas-doc \
ip6tables \
ip6tables-openrc \
iptables \
iptables-openrc \
mosh-server \
musl \
musl-dev \
musl-locales \
musl-obstack \
musl-utils \
oidentd \
openssh \
openssh-doc \
openssh-server \
openssh-server-common \
openssh-server-pam \
openssh-sftp-server \
openssl \
openssl-dev \
sshguard \
sshguard-doc \
sshguard-openrc \
squid \
squid-doc \
ssl_client \
stunnel \
stunnel-doc \
stunnel-openrc \
gnutls-dev \
gnutls-utils \
linux-headers \
linux-virt

RUNNING_KERNEL=$(uname -r)
REBOOT_KERNEL=$(file -bL /boot/vmlinuz-virt | sed 's/.*version //;s/ .*//')
COUNTDOWN=$(($(date -d 23:59:59 +%s) - $(date +%s) + 1))
if test "$RUNNING_KERNEL" = "$REBOOT_KERNEL" ; then
  :
else
  for FILE in /dev/pts/*; do echo -e "Broadcast message from root@$HOSTNAME ($(tty)) ($(date)):\n\n\\7\033[30;37;5mSystem will reboot at midnight for kernel update.\033[0m" > $FILE; done
  reboot -d $COUNTDOWN &
  rm -rf /tmp/rebootneeded
  touch /tmp/rebootneeded
fi