From 8766df6b2bc16f18237149dca0813e20fea634b5 Mon Sep 17 00:00:00 2001
From: j1nx
Date: Fri, 2 Apr 2021 12:22:46 +0200
Subject: [PATCH] Re-Initiate the firstboot system utilizing a different
approach ovos-config as tool, starting of with expiring the default passwd
---
.../lib/systemd/system/ovos-firstboot.service | 16 ++++++++++++++++
.../rootfs-overlay/usr/sbin/ovos-config | 10 ++++++++++
2 files changed, 26 insertions(+)
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/system/ovos-firstboot.service
create mode 100644 buildroot-external/rootfs-overlay/usr/sbin/ovos-config
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/ovos-firstboot.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/ovos-firstboot.service
new file mode 100644
index 00000000..35900ce5
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/ovos-firstboot.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=OVOS First boot run script
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=systemd-remount-fs.service
+Before=sysinit.target shutdown.target
+ConditionPathIsReadWrite=/etc
+ConditionPathExists=/etc/firstboot
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/sbin/ovos-config
+
+[Install]
+WantedBy=sysinit.target
diff --git a/buildroot-external/rootfs-overlay/usr/sbin/ovos-config b/buildroot-external/rootfs-overlay/usr/sbin/ovos-config
new file mode 100644
index 00000000..14fef768
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/sbin/ovos-config
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Check for first boot flag file
+if [ -f "/etc/firstboot" ]; then
+ echo "[INFO] Expiring the mycroft user's password!"
+ passwd --expire mycroft
+
+ echo "[INFO] Removing firstboot flag!"
+ rm /etc/firstboot
+fi