|
|
0d20ef |
From 7b8b3767102ea1e2b1f47e20d1bdb0bb69e3626b Mon Sep 17 00:00:00 2001
|
|
|
0d20ef |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
0d20ef |
Date: Mon, 3 Nov 2014 21:15:59 +0100
|
|
|
0d20ef |
Subject: [PATCH] customize: firstboot: make sure to run Linux scripts only
|
|
|
0d20ef |
once
|
|
|
0d20ef |
|
|
|
0d20ef |
If a script does not finish, hangs, etc, it would be executed again at
|
|
|
0d20ef |
the next boot, since the injected firstboot.sh helper removes it only
|
|
|
0d20ef |
after it finished.
|
|
|
0d20ef |
|
|
|
0d20ef |
Before executing a script, move it to another internal subdirectory
|
|
|
0d20ef |
(scripts-done) and execute it from there, so it is not run again by
|
|
|
0d20ef |
firstboot.sh. The downside is that now scripts are executed only once
|
|
|
0d20ef |
at all, so if a script fails it will not be attempted at the next boot.
|
|
|
0d20ef |
|
|
|
0d20ef |
Also, remove all the files found in scripts-done, as they have been run
|
|
|
0d20ef |
(or at least attempted) in a previous boot.
|
|
|
0d20ef |
|
|
|
0d20ef |
This fixes RHBZ#1159651.
|
|
|
0d20ef |
|
|
|
0d20ef |
(cherry picked from commit f8ed15462fbb03c5b19972361f2a2e6fed4c5f02)
|
|
|
0d20ef |
---
|
|
|
0d20ef |
customize/firstboot.ml | 11 ++++++++---
|
|
|
0d20ef |
1 file changed, 8 insertions(+), 3 deletions(-)
|
|
|
0d20ef |
|
|
|
0d20ef |
diff --git a/customize/firstboot.ml b/customize/firstboot.ml
|
|
|
0d20ef |
index 142eab4..1b92194 100644
|
|
|
0d20ef |
--- a/customize/firstboot.ml
|
|
|
0d20ef |
+++ b/customize/firstboot.ml
|
|
|
0d20ef |
@@ -46,6 +46,7 @@ module Linux = struct
|
|
|
0d20ef |
### END INIT INFO
|
|
|
0d20ef |
|
|
|
0d20ef |
d=%s/scripts
|
|
|
0d20ef |
+d_done=%s/scripts-done
|
|
|
0d20ef |
logfile=~root/virt-sysprep-firstboot.log
|
|
|
0d20ef |
|
|
|
0d20ef |
echo \"$0\" \"$@\" 2>&1 | tee $logfile
|
|
|
0d20ef |
@@ -53,16 +54,20 @@ echo \"Scripts dir: $d\" 2>&1 | tee $logfile
|
|
|
0d20ef |
|
|
|
0d20ef |
if test \"$1\" = \"start\"
|
|
|
0d20ef |
then
|
|
|
0d20ef |
+ mkdir -p $d_done
|
|
|
0d20ef |
for f in $d/* ; do
|
|
|
0d20ef |
if test -x \"$f\"
|
|
|
0d20ef |
then
|
|
|
0d20ef |
+ # move the script to the 'scripts-done' directory, so it is not
|
|
|
0d20ef |
+ # executed again at the next boot
|
|
|
0d20ef |
+ mv $f $d_done
|
|
|
0d20ef |
echo '=== Running' $f '===' 2>&1 | tee $logfile
|
|
|
0d20ef |
- $f 2>&1 | tee $logfile
|
|
|
0d20ef |
- rm -f $f
|
|
|
0d20ef |
+ $d_done/$(basename $f) 2>&1 | tee $logfile
|
|
|
0d20ef |
fi
|
|
|
0d20ef |
done
|
|
|
0d20ef |
+ rm -f $d_done/*
|
|
|
0d20ef |
fi
|
|
|
0d20ef |
-" firstboot_dir
|
|
|
0d20ef |
+" firstboot_dir firstboot_dir
|
|
|
0d20ef |
|
|
|
0d20ef |
let firstboot_service = sprintf "\
|
|
|
0d20ef |
[Unit]
|
|
|
0d20ef |
--
|
|
|
0d20ef |
1.8.3.1
|
|
|
0d20ef |
|