forked from nmcclain/raspberian-firstboot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add reboot after firstboot example nmcclain#12
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |