From: wchang kim Date: Thu, 3 Nov 2016 11:27:18 +0000 (+0900) Subject: Description : Applying init.wrapper to init process. X-Git-Tag: submit/tizen/20161129.011323~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=512fc76fbd4b4e1904cbdc5bcbaf1af753f450b3;p=platform%2Fadaptation%2Fsystem-plugin.git Description : Applying init.wrapper to init process. In order to apply RO filesystem for rootfs, we should mount /opt for rw region. init.wrapper do this job. Change-Id: I0f546486fa5729bbf4412f86500b0ed43a0ecb3f Signed-off-by: Woochang Kim --- diff --git a/packaging/system-plugin.spec b/packaging/system-plugin.spec index 885fbea..2887f7a 100644 --- a/packaging/system-plugin.spec +++ b/packaging/system-plugin.spec @@ -105,6 +105,14 @@ BuildArch: noarch %description profile_ivi This package provides ivi specific system configuration files. +%package init_wrapper +Summary: Support init.wrapper booting. +Requires: %{name} = %{version}-%{release} +BuildArch: noarch + +%description init_wrapper +This package provides init.wrapper and init symlink file for init wrapper booting. + %prep %setup -q @@ -185,6 +193,10 @@ install -m 644 units/offline-update.service %{buildroot}%{_unitdir} ln -s ../offline-update.service %{buildroot}%{_unitdir}/system-update.target.wants/offline-update.service ln -s %{_datadir}/upgrade %{buildroot}/system-update +# init_wrapper +mkdir -p %{buildroot}%{_sbindir} +install -m 755 scripts/init.wrapper %{buildroot}%{_sbindir} + %clean rm -rf %{buildroot} @@ -312,3 +324,11 @@ echo 'RemainAfterExit=yes' >> /usr/lib/systemd/system/user\@.service %files profile_ivi %{_unitdir}/ivi-network.service %{_unitdir}/multi-user.target.wants/ivi-network.service + + +%files init_wrapper +%{_sbindir}/init.wrapper + +%posttrans init_wrapper +rm -f /sbin/init +ln -s /sbin/init.wrapper /sbin/init diff --git a/scripts/init.wrapper b/scripts/init.wrapper new file mode 100644 index 0000000..a2f9379 --- /dev/null +++ b/scripts/init.wrapper @@ -0,0 +1,45 @@ +#!/bin/sh + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +SYSTEM_MNT=/opt +SYS_BLK_DIR=/sys/class/block + +/usr/bin/mount -t proc none /proc +/usr/bin/mount -t sysfs none /sys + +DISK_LIST=`ls $SYS_BLK_DIR` + +for BLK_NAME in $DISK_LIST +do +lsblk -r -n -d --output LABEL,PARTLABEL /dev/$BLK_NAME | grep -qi "system-data" +if [ $? = "0" ] +then +SYSTEM_DISK=/dev/$BLK_NAME +break +fi +done + +if [ "$SYSTEM_DISK" == "" ] +then + echo "Warning : There is no system-data partition." +else + /usr/bin/mount | grep "$SYSTEM_MNT " > /dev/null + + if [ $? = "0" ] + then + /usr/bin/umount -l "$SYSTEM_MNT" + fi + + /usr/bin/mount $SYSTEM_DISK $SYSTEM_MNT +fi + +INIT=/usr/lib/systemd/systemd +if [ $$ = 1 ]; then + [ "$INIT" ] && exec "$INIT" "$@" +fi + +echo "======================================================================" +echo "[/sbin/init] WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" +echo "This Message should be never printed. ($INIT execution failure?)" +echo "======================================================================"