1
1
mirror of https://github.com/OpenVoiceOS/OpenVoiceOS synced 2025-06-05 22:19:21 +02:00

MycroftOS: Firstboot systemd system

- System to run sccripts at the very first boot. Now currently used
  only for resizing the partion using the full SD size.
- Can be expanded to run other scripts to prepare stuff at the
  very first boot.
This commit is contained in:
Peter Steenbergen
2019-09-27 09:12:17 +02:00
parent d7e7dddf58
commit 091f5720e6
7 changed files with 63 additions and 0 deletions

View File

@ -1,4 +1,5 @@
menu "Mycroft A.I. Personal Assistant"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/firstboot-service/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-mycroft/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/mycroft-service/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/mycroft-splash/Config.in"

View File

@ -187,6 +187,7 @@ BR2_PACKAGE_HOST_PYTHON_CYTHON=y
BR2_PACKAGE_HOST_PYTHON_LXML=y
BR2_PACKAGE_HOST_PYTHON_SIX=y
BR2_PACKAGE_HOST_PYTHON_XLRD=y
BR2_PACKAGE_FIRSTBOOT_SERVICE=y
BR2_PACKAGE_PYTHON_MYCROFT=y
BR2_PACKAGE_MYCROFT_SERVICE=y
BR2_PACKAGE_MYCROFT_SPLASH=y

View File

@ -0,0 +1,8 @@
config BR2_PACKAGE_FIRSTBOOT_SERVICE
bool "firstboot-service"
help
A systemd service that only runs on first boot
which can be used to run certain scripts that
prepare the rootfs. For now being used to auto
expand the filesystem over the full size of the
SD card.

View File

@ -0,0 +1,4 @@
#!/bin/bash
#
/usr/sbin/resizeSD &&
rm /etc/firstboot

View File

@ -0,0 +1,24 @@
################################################################################
#
# firstboot-service
#
################################################################################
FIRSTBOOT_SERVICE_VERSION = 0.1.0
FIRSTBOOT_SERVICE_SITE = $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/firstboot-service
FIRSTBOOT_SERVICE_SITE_METHOD = local
FIRSTBOOT_SERVICE_LICENSE = Apache License 2.0
FIRSTBOOT_SERVICE_LICENSE_FILES = LICENSE
define FIRSTBOOT_SERVICE_INSTALL_TARGET_CMDS
$(INSTALL) -m 0755 $(@D)/resizeSD $(TARGET_DIR)/usr/sbin/
$(INSTALL) -m 0755 $(@D)/firstboot $(TARGET_DIR)/usr/sbin/
$(INSTALL) -D -m 644 $(@D)/firstboot.service \
$(TARGET_DIR)/usr/lib/systemd/system/firstboot.service
mkdir -p $(TARGET_DIR)/etc/systemd/system/sysinit.target.wants
ln -fs ../../../../usr/lib/systemd/system/firstboot.service \
$(TARGET_DIR)/etc/systemd/system/sysinit.target.wants/firstboot.service
touch $(TARGET_DIR)/etc/firstboot
endef
$(eval $(generic-package))

View File

@ -0,0 +1,16 @@
[Unit]
Description=First Boot run script
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service
Before=sysinit.target shutdown.target
ConditionPathIsReadWrite=/etc
ConditionFirstBoot=yes
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/resizeSD
[Install]
WantedBy=sysinit.target

View File

@ -0,0 +1,9 @@
#!/bin/bash
#
printf "Resize data partition ..."
parted /dev/mmcblk0 unit % resizepart 2 100% &&
partprobe /dev/mmcblk0 &&
sync &&
resize2fs /dev/mmcblk0p2 &&
echo "[OK]"