Init wrapper : fixed some issues
[platform/adaptation/system-plugin.git] / scripts / init.wrapper
1 #!/bin/sh
2
3 PATH=/bin:/usr/bin:/sbin:/usr/sbin
4
5 SYSTEM_MNT=/opt
6 SYS_BLK_DIR=/sys/class/block
7
8 mount -o nosuid,strictatime,mode=755 -t devtmpfs devtmpfs /dev
9 mount -o nosuid,noexec,nodev -t sysfs sysfs /sys
10 mount -o nosuid,noexec,nodev -t proc proc /proc
11
12 #Find devices with label or partlabel
13 ROOTFS=`/sbin/blkid -L rootfs`
14 if [ x$ROOTFS = "x" ]
15 then
16     ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs -o device`
17 fi
18
19 DATAFS=`/sbin/blkid -L system-data`
20 if [ x$DATAFS = "x" ]
21 then
22     DATAFS=`/sbin/blkid -t PARTLABEL=system-data -o device`
23 fi
24
25 #Fsck, resize, mount devices
26 if [ x$ROOTFS = "x" ]
27 then
28     echo "Warning : There is no rootfs partition."
29 else
30     /sbin/fsck -y $ROOTFS
31     /usr/bin/mount -o remount,rw $ROOTFS
32     /sbin/resize2fs -f $ROOTFS
33     /usr/bin/mount -o remount,ro $ROOTFS
34 fi
35
36 if [ x$DATAFS = "x" ]
37 then
38     echo "Warning : There is no system-data partition."
39 else
40     /usr/bin/mount | grep "$DATAFS " > /dev/null
41
42     if [ $? = "0" ]
43     then
44         /usr/bin/umount -l "$DATAFS"
45     fi
46     /sbin/fsck -y $DATAFS
47     /sbin/resize2fs -f $DATAFS
48     /usr/bin/mount $DATAFS $SYSTEM_MNT
49 fi
50
51 INIT=/usr/lib/systemd/systemd
52 if [ $$ = 1 ]; then
53         [ "$INIT" ] && exec "$INIT" "$@"
54 fi
55
56 echo "======================================================================"
57 echo "[/sbin/init] WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
58 echo "This Message should never be printed. ($INIT execution failure?)"
59 echo "======================================================================"
60 exec /bin/sh