introduced prerun scripts. 61/34361/1
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 26 Jan 2015 07:15:08 +0000 (16:15 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 26 Jan 2015 07:17:28 +0000 (16:17 +0900)
This script is executed from initramfs.
It is very useful for manipulating some files on rootfs before init.
(Configuration files, ...)

Change-Id: I31cd697f3415e7903e670aa44c32c700f0f54091
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
filesystem/etc/emulator/prerun [new file with mode: 0644]
filesystem/etc/emulator/prerun.d/model-config.sh [moved from filesystem/etc/emulator/model-config.sh with 77% similarity, mode: 0644]
filesystem/usr/lib/systemd/system/emul-common-preinit.service

diff --git a/filesystem/etc/emulator/prerun b/filesystem/etc/emulator/prerun
new file mode 100644 (file)
index 0000000..c46dfc1
--- /dev/null
@@ -0,0 +1,17 @@
+# This script is executed in initramfs.
+
+if [ ! -z $1 ]; then
+        NEW_ROOT=$1
+else
+        NEW_ROOT=
+fi
+
+if [ -d $NEW_ROOT/etc/emulator/prerun.d ]; then
+  for i in $NEW_ROOT/etc/emulator/prerun.d/*.sh; do
+    if [ -r $i ]; then
+      . $i
+    fi
+  done
+  unset i
+fi
+
old mode 100755 (executable)
new mode 100644 (file)
similarity index 77%
rename from filesystem/etc/emulator/model-config.sh
rename to filesystem/etc/emulator/prerun.d/model-config.sh
index 96a29e1..ebcd392
@@ -1,13 +1,25 @@
-#!/bin/sh
+if [ ! -z $1 ]; then
+        NEW_ROOT=$1
+        # if NEW_ROOT is passed, it executed by initramfs.
+        # So, we should prepare some core utils.
+        /bin/busybox ln -sf /bin/busybox /bin/ln
+        ln -sf /bin/busybox /bin/sed
+        ln -sf /bin/busybox /bin/grep
+        ln -sf /bin/busybox /bin/cut
+        ln -sf /bin/busybox /bin/tr
+        ln -sf /bin/busybox /bin/expr
+        ln -sf /bin/busybox /bin/readlink
+else
+        NEW_ROOT=
+fi
 
 CMDLINE=/proc/cmdline
-XML=/etc/config/model-config.xml
-
+XML=$(readlink -f $NEW_ROOT/etc/config/model-config.xml)
 
 echo -e "[${_G} model config setting ${C_}]"
 
 # display resolution
-if grep --silent "video=" $CMDLINE ; then
+if grep -q "video=" $CMDLINE ; then
         echo -e "[${_G} modify the resolution value of platform features: ${C_}]"
 
         VIDEO=`sed s/.*video=// $CMDLINE | cut -d ' ' -f1`
@@ -38,7 +50,7 @@ if grep --silent "video=" $CMDLINE ; then
 fi
 
 # dot per inch
-if grep --silent "dpi=" $CMDLINE ; then
+if grep -q "dpi=" $CMDLINE ; then
         echo -e "[${_G} modify the dpi value of platform features: ${C_}]"
 
         DPI=`sed s/.*dpi=// $CMDLINE | cut -d ' ' -f1`
index 3ad24cf..dd5e101 100644 (file)
@@ -7,8 +7,10 @@ Before=basic.target
 [Service]
 Type=oneshot
 
-# platform features
-ExecStartPre=/bin/sh -c '/etc/emulator/model-config.sh'
+# execute prerun scripts.
+# it is not necessary because it is already executed from initramfs.
+# but we execute it again for sure.
+ExecStartPre=/bin/sh -c '. /etc/emulator/prerun'
 # W/A for alarm-service
 ExecStart=/bin/touch /dev/rtc1