-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rootfs-overlay: add flashing script as rootfs-overlay
Add installer specific rootfs modifications, specifically the flashing script (haos-flash) and LED control. Signed-off-by: Stefan Agner <stefan@agner.ch>
- Loading branch information
Showing
5 changed files
with
82 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
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,4 @@ | ||
[Time] | ||
FallbackNTP=time.cloudflare.com | ||
# Speed-up boot as first attempt is done before network is up | ||
ConnectionRetrySec=10 |
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,53 @@ | ||
#!/bin/ash | ||
# shellcheck shell=dash | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
# Abort if already running | ||
if pidof dd | ||
then | ||
echo "dd already running, aborting..." | ||
exit 1 | ||
fi | ||
|
||
if [ "$1" = "dev" ]; then | ||
echo "Getting latest Home Assistant OS version from channel dev..." | ||
channel="https://version.home-assistant.io/dev.json" | ||
else | ||
echo "Getting latest Home Assistant OS version from channel stable..." | ||
channel="https://version.home-assistant.io/stable.json" | ||
fi | ||
|
||
version=$(curl --no-progress-meter -L "${channel}" | jq -r '.hassos.green') | ||
echo -n "Installing Home Assitant OS ${version} to " | ||
|
||
if [ "$1" = "dev" ]; then | ||
url="https://os-builds.home-assistant.io/${version}/haos_green-${version}.img.xz" | ||
else | ||
url="https://github.com/home-assistant/operating-system/releases/download/${version}/haos_green-${version}.img.xz" | ||
fi | ||
|
||
if [ -b /dev/mmcblk0 ] | ||
then | ||
echo "mmcblk0." | ||
device=/dev/mmcblk0 | ||
else | ||
echo "nowhere." | ||
echo "No storage media found, exiting." | ||
echo none > /sys/class/leds/yellow:heartbeat/trigger | ||
exit 1 | ||
fi | ||
|
||
echo timer > /sys/class/leds/yellow:heartbeat/trigger | ||
echo 100 > /sys/class/leds/yellow:heartbeat/delay_on | ||
echo 100 > /sys/class/leds/yellow:heartbeat/delay_off | ||
if curl --no-progress-meter -L "$url" | unxz --stdout | dd of=${device} bs=4M | ||
then | ||
echo "Successfully installed Home Assistant OS, shutting down the system" | ||
echo default-on > /sys/class/leds/yellow:heartbeat/trigger | ||
poweroff | ||
else | ||
echo "Error during Home Assistant OS installation." | ||
echo none > /sys/class/leds/yellow:heartbeat/trigger | ||
fi |
1 change: 1 addition & 0 deletions
1
rootfs-overlay/usr/lib/systemd/system-preset/70-haos-installer.preset
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 @@ | ||
enable systemd-time-wait-sync.service |
13 changes: 13 additions & 0 deletions
13
rootfs-overlay/usr/lib/systemd/system/install-autostart.service
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,13 @@ | ||
[Unit] | ||
Description=Autostart Home Assistant OS installation | ||
Wants=network-online.target time-sync.target | ||
After=network-online.target time-sync.target | ||
DefaultDependencies=no | ||
|
||
[Service] | ||
Type=idle | ||
ExecStart=-/usr/bin/haos-flash stable | ||
StandardOutput=journal+console | ||
|
||
[Install] | ||
WantedBy=basic.target |