20
# PID of init; may not always be 1. Use for sending signals
21
# and checking if init is running.
22
PID="$(pidof /sbin/init || true)"
20
# PID of init; may not always be 1 but this code isn't run in
21
# these cases (Hurd). Use for sending signals and checking if
24
25
# Create /run/initctl if not present, and also create compatibility
26
if [ "$INITCTL" ] && [ ! -p "$INITCTL" ]
27
if [ ! -p "$INITCTL" ]
28
29
# Create new control channel
29
30
echo "sysvinit: creating $INITCTL"
31
32
mkfifo -m 600 $INITCTL
33
# Replace old control channel (if present) with symlink
34
if [ -e "$OLDINITCTL" ]; then
35
ln -s "$INITCTL" "$OLDINITCTL.new"
36
mv "$OLDINITCTL.new" "$OLDINITCTL"
39
# Reopen control channel (uses new channel).
40
if ! ischroot && [ -n "$PID" ]
35
# Replace old control channel with symlink
36
ln -s "$INITCTL" "$OLDINITCTL.new"
37
mv "$OLDINITCTL.new" "$OLDINITCTL"
39
# Reopen control channel (uses new channel).
42
# Tell init to re-exec itself. We loop on failure to reduce
43
# the chance of a race before the new control channel is
45
echo -n "sysvinit: restarting..."
46
for delay in 0 1 2 3 4 5 6 fail;
47
if [ ! -f /etc/inittab ]
49
cp -p /usr/share/sysvinit/inittab /etc/inittab
52
# Tell init to re-exec itself. We loop on failure because to reduce
53
# the chance of a race before the new control channel is opened.
54
if ! ischroot && [ -n "$PID" ]
56
echo -n "sysvinit: restarting..."
57
for delay in 0 1 2 3 4 5 6 fail;
53
if [ "$delay" = "fail" ]
64
if [ "$delay" = "fail" ]
76
echo "Not restarting sysvinit: chroot detected"
78
echo "Not restarting sysvinit: init not running"
82
63
# Remove old pipe if present. No longer in use after re-exec.
83
if [ "$OLDINITCTL" ] && [ -p "$OLDINITCTL" ]
64
if [ -p "$OLDINITCTL" ]
85
66
rm -f "$OLDINITCTL"
83
if [ ! -f /etc/inittab ]
85
cp -p /usr/share/sysvinit/inittab /etc/inittab
91
ischroot || chroot="$?"
93
if [ "$chroot" != "1" ]; then
100
97
# If systemd is running, don't restart init or doing any initctl
102
if [ ! -e /sys/fs/cgroup/systemd ] ; then
99
if [ -d /run/systemd/system ]; then
102
if [ "$(uname -s)" = "GNU" ]; then
106
if [ "$restart" = "yes" ]; then
109
echo "Not restarting sysvinit"