aboutsummaryrefslogtreecommitdiffstats
path: root/main/util-vserver/alpine.patch
blob: d3727db8ae5cdcd9af25c09f7d5ea6bf1d2572e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
diff --git a/distrib/alpine/initpost b/distrib/alpine/initpost
index 4bb639d..969e20c 100644
--- a/distrib/alpine/initpost
+++ b/distrib/alpine/initpost
@@ -23,8 +23,8 @@ vdir="$cfgdir"/vdir
 
 cd "$vdir"
 
-echo ">>> Creating missing dirs..."
-$_CHROOT_SH mkdir proc sys dev home etc etc/rcL.d etc/rcK.d 2>/dev/null
+echo ">>> Creating missing dirs ..."
+$_CHROOT_SH mkdir proc sys dev home etc run 2>/dev/null
 
 # remove mtab which is a link
 if test -e "$vdir/etc/mtab"; then
@@ -32,40 +32,54 @@ if test -e "$vdir/etc/mtab"; then
 fi
 
 # trick to install busybox links and boot services
-echo ">>> Installing boot services..."
+echo ">>> Installing boot services ..."
 vserver="$1"
-$_VSERVER "$vserver" stop  &>/dev/null || true
-$_VSERVER "$vserver" start --rescue --rescue-init /bin/busybox sh -c '
-	/bin/busybox --install -s
-	if [ -x /sbin/rc-update ]; then
-	    /sbin/rc-update add syslog boot
-	    /bin/rmdir /etc/rcL.d /etc/rcK.d
-	else
-	    /sbin/rc_add -s 20 -k syslog
-	fi
-'
+$_CHROOT_SH mkdir /etc/runlevels 2>/dev/null
+$_CHROOT_SH mkdir /etc/runlevels/boot 2>/dev/null
+$_CHROOT_SH link /etc/init.d/syslog /etc/runlevels/boot/syslog
 
 # set up hostname
 if test -r "$cfgdir"/uts/nodename; then
-	echo ">>> Setting hostname..."
+	echo ">>> Setting hostname ..."
 	$_CHROOT_SH truncate /etc/hostname < "$cfgdir/uts/nodename"
 fi
 
 # create fstab
 echo -e "none\t/\tnone\tdefaults" | $_CHROOT_SH truncate /etc/fstab
 
-# create busybox style inittab
-cat <<EOF | $_CHROOT_SH truncate /etc/inittab
-::wait:/etc/init.d/rcL
-::ctrlaltdel:/etc/init.d/rcK
+# set up cmd.start and cmd stop if needed
+test -e "$1"/apps/init/style && initstyle=$(cat "$1"/apps/init/style)
+if test "$initstyle" == "openrc" -o "$initstyle" == "gentoo"; then
+	echo ">>> Installing openrc init-style magic ..."
+	$_CHROOT_SH mkdir /lib 2>/dev/null
+	$_CHROOT_SH mkdir /lib/rc 2>/dev/null
+	$_CHROOT_SH mkdir /lib/rc/sh 2>/dev/null
+
+	cat <<EOF | $_CHROOT_SH truncate /lib/rc/sh/init-vserver.sh
+#!/bin/sh
+
+RUNLEVEL=1 /sbin/rc sysinit && /sbin/rc boot || exit 1
+/sbin/rc \${1:-default}
+exit 0
+EOF
+	$_CHROOT_SH chmod 0755 /lib/rc/sh/init-vserver.sh
+
+	$_CHROOT_SH mkdir /etc/init.d 2>/dev/null
+	echo "exit 0" | $_CHROOT_SH truncate /etc/init.d/shutdown.sh
+	$_CHROOT_SH chmod 0755 /etc/init.d/shutdown.sh
+	echo "exit 0" | $_CHROOT_SH truncate /etc/init.d/reboot.sh
+	$_CHROOT_SH chmod 0755 /etc/init.d/reboot.sh
+
+else
+	echo ">>> Creating busybox style inittab ..."
+	# create busybox style inittab
+	cat <<EOF | $_CHROOT_SH truncate /etc/inittab
+::sysinit:/sbin/rc sysinit
+::wait:/sbin/rc default
+::ctrlaltdel:/sbin/rc shutdown
 ::ctrlaltdel:/usr/bin/killall5 -15
 EOF
 
-# set up cmd.start and cmd stop if needed
-test -e "$1"/apps/init/style && initstlye=$(cat "$1"/apps/init/style)
-if test "$initstlye" != "plain"; then
-	echo "/etc/init.d/rcL" > "$cfgdir/apps/init/cmd.start"
-	echo "/etc/init.d/rcK" > "$cfgdir/apps/init/cmd.stop"
 fi
 
 # vserver should not be running at this point but lets be sure
diff --git a/distrib/alpine/initpre b/distrib/alpine/initpre
index 58ea449..0257e20 100644
--- a/distrib/alpine/initpre
+++ b/distrib/alpine/initpre
@@ -20,14 +20,19 @@
 vdir="$1"/vdir
 . "$2"
 
+echo ">>> Adding /run to fstab ..."
+echo "none	/run		tmpfs	size=1m,mode=0755	0 0" >> "$1"/fstab
+
 # initstyle sanity
 initstyle=sysv
 test -e "$1"/apps/init/style && initstyle=$(cat "$1"/apps/init/style)
 
 echo ">>> Checking init-style ... $initstyle"
 
-if test "$initstyle" != "sysv" && test "$initstyle" != "plain" ; then
-	echo "!!! The init-style is not supported for Alpine Linux"
-	echo "!!! Please use sysv or plain"
-fi
+case "$initstyle" in
+	plain|openrc|gentoo) ;;
+	*)	echo "!!! The init-style $initstyle is not supported for Alpine Linux"
+		echo "!!! Please use plain or openrc"
+		;;
+esac