Skip to content

Commit

Permalink
add reboot after firstboot example nmcclain#12
Browse files Browse the repository at this point in the history
  • Loading branch information
janoskut committed Dec 27, 2021
1 parent 23420c9 commit a236ca9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/reboot/firstboot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

LOGFILE="/boot/firstboot.log"

# Log everything: https://serverfault.com/a/103569/662521
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>${LOGFILE} 2>&1

# update APT packages
export DEBIAN_FRONTEND=noninteractive
apt-get update -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false
apt-get install -y upgrade

# set timezone and update time
timedatectl set-timezone UTC
ntpdate ntp.ubuntu.com

# Reboot delayed, so that we can exit with success to complete firstboot.service
systemd-run --no-block sh -c "sleep 3 && touch /boot/reboot && reboot"

echo "Done firstboot, exit, but reboot in 3 seconds"
exit 0

# check /boot/reboot and /boot/firstboot.log

0 comments on commit a236ca9

Please sign in to comment.