diff options
Diffstat (limited to 'meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts')
-rwxr-xr-x | meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts | 41 | ||||
-rw-r--r-- | meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts.service | 15 |
2 files changed, 56 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 diff --git a/meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts.service b/meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts.service new file mode 100644 index 000000000..d1b506308 --- /dev/null +++ b/meta-agl/recipes-devtools/run-agl-postinsts/run-agl-postinsts/run-agl-postinsts.service @@ -0,0 +1,15 @@ +[Unit] +Description=Run pending agl postinsts +DefaultDependencies=no +After=#SYSTEMD_SERVICE_AFTER# +ConditionPathExistsGlob=#SYSCONFDIR#/agl-postinsts + +[Service] +Type=oneshot +ExecStart=#SBINDIR#/run-agl-postinsts +ExecStartPost=#BASE_BINDIR#/systemctl disable run-agl-postinsts.service +RemainAfterExit=No +TimeoutSec=0 + +[Install] +WantedBy=multi-user.target |