diff options
author | Ronan Le Martret <ronan.lemartret@iot.bzh> | 2017-02-15 16:34:51 +0100 |
---|---|---|
committer | ronan Le Martret <ronan@iot.bzh> | 2017-02-17 10:19:03 +0000 |
commit | 4ab8673b6a9ef67c377e36c811329725c9873fb8 (patch) | |
tree | 1afad5e2519641296ffe49088d1ddcd9c6446517 /meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts | |
parent | 0189ad4446fac4da23544520e295ade4511a1860 (diff) |
Added first boot service for AGL
* Allow script execution at the end of the boot.
* Yocto first boot service is install at for "sysinit.target" level.
AGL need to have a custom service, exec when target service system,
(SYSTEMD_SERVICE_AFTER), is up.
* All script inside directory "/etc/agl-postinsts" will be exec at
the first boot.
* After the first boot the service "run-agl-postinsts.service"
is disable.
Change-Id: Ib12b7e11b451b4a41c4a31f5cda3686679fe9c08
Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
(cherry picked from commit 67f1d7f631f20dfb4be3765ec32dfcd237d649c5)
Diffstat (limited to 'meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts')
-rwxr-xr-x | meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts b/meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts new file mode 100755 index 000000000..7c2effa70 --- /dev/null +++ b/meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Copyright 2017 IoT.bzh. + +# Author: Ronan Le Martret <ronan.lemartret@iot.bzh> +# + +# The following script will run all the scriptlets found in #SYSCONFDIR#/agl-postinsts. + +agl_pi_dir="#SYSCONFDIR#/agl-postinsts" + +POSTINST_LOGGING=1 +LOGFILE=/var/log/agl-postinstall.log + +[ -e $LOGFILE ] && mv ${LOGFILE} ${LOGFILE}.old.$(date +%F--%H%M.%S) + +append_log=">>$LOGFILE 2>&1" + +exec_postinst_scriptlets() { + for i in `ls $agl_pi_dir`; do + i=$agl_pi_dir/$i + echo "Running postinst $i..." + [ "$POSTINST_LOGGING" = "1" ] && eval echo "Running postinst $i..." $append_log + if [ -x $i ]; then + eval sh -c $i $append_log + rm $i + else + echo "ERROR: postinst $i failed." + [ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i failed." $append_log + remove_agl_pi_dir=0 + fi + done +} + +remove_agl_pi_dir=1 +exec_postinst_scriptlets + +# since all postinstalls executed successfully, remove the postinstalls directory +if [ $remove_agl_pi_dir = 1 ]; then + rm -rf $agl_pi_dir +fi |