File: openrc.postinst

package info (click to toggle)
openrc 0.63-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,424 kB
  • sloc: ansic: 16,257; sh: 2,225; perl: 28; makefile: 26
file content (89 lines) | stat: -rw-r--r-- 2,747 bytes parent folder | download
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
#!/bin/sh

set -e

# Remove diverts made by 0.20.4-1
if [ "$(dpkg-divert --list /usr/sbin/invoke-rc.d)" = \
     "diversion of /usr/sbin/invoke-rc.d to /usr/sbin/invoke-rc.d.init-system-helpers by openrc" ]
	then dpkg-divert --package openrc --remove --rename \
		--divert /usr/sbin/invoke-rc.d.init-system-helpers /usr/sbin/invoke-rc.d
fi
if [ "$(dpkg-divert --list /usr/sbin/update-rc.d)" = \
     "diversion of /usr/sbin/update-rc.d to /usr/sbin/update-rc.d.init-system-helpers by openrc" ]
	then dpkg-divert --package openrc --remove --rename \
		--divert /usr/sbin/update-rc.d.init-system-helpers /usr/sbin/update-rc.d
fi


if [ "${1}" = "configure" ] ; then
	echo "Add existing services ..."

	for rl in 1 2 S; do
		[ -d /etc/rc${rl}.d ] || continue

		for f in $(ls -1 /etc/rc${rl}.d | egrep 'S[[:digit:]]{2}*'); do
			rclink=/etc/rc${rl}.d/${f}
			initsh=$(readlink -f ${rclink})
			svc=$(basename ${initsh})
			if [ -x ${initsh} ]; then
				case ${rl} in
				1) orl="recovery" ;;
				2) orl="default" ;;
				S) orl="sysinit" ;;
				esac
				rc-update add ${svc} ${orl}
			else
			    if [ -f ${initsh} ]; then
				echo "*** WARNING: skipping non-executable $initsh"
			    else
				echo "*** WARNING: dangling link $rclink"
				echo $dsvcs|grep -qw ${svc} || dsvcs="$dsvcs ${svc}"
			    fi
			fi
		done
	done

	[ -d /etc/rc6.d ] && for f in $(ls -1 /etc/rc6.d | egrep 'K[[:digit:]]{2}*'); do
		rclink=/etc/rc6.d/${f}
		initsh=$(readlink -f ${rclink})
		svc=$(basename ${initsh})
		if [ -f ${initsh} ]; then
			# reboot is managed by /etc/init.d/rc
			[ ${svc} = reboot ] && continue

			# no need to duplicate services in the off runlevel
			egrep -q '# Default-Start:\s+[S12345]' ${initsh} && continue
			rc-update add ${svc} off
		else
			echo "*** WARNING: dangling link $rclink"
			echo $dsvcs|grep -qw ${svc} || dsvcs="$dsvcs ${svc}"
		fi
	done

	rc-update add savecache off
	rc-update add cgroups sysinit
	rc-update -u

	if [ "$dsvcs" != "" ]; then
		echo "**********************************************************************"
		echo "*** WARNING: Found the following dangling links:"
		for link in $dsvcs; do
			ls -l /etc/rc*.d/*$link
		done
		echo "**********************************************************************"
	fi

	if [ -z "${2}" ] ; then
		echo "**********************************************************************"
		echo "*** WARNING: if you are replacing sysv-rc by OpenRC, then you must ***"
		echo "*** reboot immediately using the following command:                ***"
		echo 'for file in /etc/rc0.d/K*; do s=`basename $(readlink "$file")` ; /etc/init.d/$s stop; done'
		echo "**********************************************************************"
	fi
fi

pam-auth-update --package

#DEBHELPER#

exit 0