add userinit script(s) support
Allow user to provide userinit.sh and/or userinit.d/*
scripts under /data/local to be run on each boot.
Change-Id: I96f3034bcdea8d4cc75929d21b69efa31c1cb108
diff --git a/config/common.mk b/config/common.mk
index 5438091..bd1f392 100644
--- a/config/common.mk
+++ b/config/common.mk
@@ -40,6 +40,10 @@
vendor/cm/prebuilt/common/etc/init.d/00banner:system/etc/init.d/00banner \
vendor/cm/prebuilt/common/bin/sysinit:system/bin/sysinit
+# userinit support
+PRODUCT_COPY_FILES += \
+ vendor/cm/prebuilt/common/etc/init.d/90userinit:system/etc/init.d/90userinit
+
# Compcache/Zram support
PRODUCT_COPY_FILES += \
vendor/cm/prebuilt/common/etc/init.local.rc:system/etc/init.local.rc \
diff --git a/prebuilt/common/etc/init.d/90userinit b/prebuilt/common/etc/init.d/90userinit
new file mode 100755
index 0000000..e8e6de0
--- /dev/null
+++ b/prebuilt/common/etc/init.d/90userinit
@@ -0,0 +1,15 @@
+#!/system/bin/sh
+# call userinit.sh and/or userinit.d/* scripts if present in /data/local
+
+if [ -e /data/local/userinit.sh ];
+then
+ log -p i -t userinit "Executing /data/local/userinit.sh";
+ logwrapper /system/bin/sh /data/local/userinit.sh;
+ setprop cm.userinit.active 1;
+fi;
+
+if [ -d /data/local/userinit.d ];
+then
+ logwrapper busybox run-parts /data/local/userinit.d;
+ setprop cm.userinit.active 1;
+fi;