File: runit.preinst

package info (click to toggle)
runit 2.2.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,568 kB
  • sloc: ansic: 6,071; sh: 3,419; makefile: 399
file content (46 lines) | stat: -rwxr-xr-x 1,722 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
set -eu

# We are at pre-inst, this directory may not exist yet. See #927442.
mkdir -p /etc/runit/runsvdir
if [ ! -e /etc/runit/runsvdir/current ]; then
	#rm any broken/old symlink, just to be sure
	rm -f /etc/runit/runsvdir/current
	echo 'runit: setting up for runsvchdir'
	#now current symlink does not exists, we can safely create it
	ln -s /etc/runit/runsvdir/default /etc/runit/runsvdir/current
	echo 'runit: current symlink succesfully created'
fi

if [ ! -e /etc/service ]; then #new install
	ln -s /etc/runit/runsvdir/current /etc/service
elif [ -h /etc/service ]; then
	servlink=$(readlink /etc/service) # should be /etc/runit/runsvdir/current
	if [ "$servlink" != '/etc/runit/runsvdir/current' ]; then
		# transition to enable runsvchdir, started in 2.1.2-28, to be removed in future:
		# we are running in the default rundir, proceed with the switch
		# note that ln is not safe to use here as it does an unlink before
		# creating the new link; using mv instead
		printf "runit: switching /etc/service to current... "
		ln -s /etc/runit/runsvdir/current /etc/service-new
		mv -T /etc/service-new /etc/service
		printf "done\n"
	fi
fi

# link to atomically upgrade service dirs
mkdir -p /usr/share/runit/sv
mkdir -p /usr/share/runit/sv.now
#2.1.2-55(experimental): sv.current pointed to the wrong dir, must be fixed
if [ "$1" = upgrade ] && dpkg --compare-versions "$2" eq 2.1.2-55; then
	echo "removing wrong symlink" #debug code
	unlink /usr/share/runit/sv.current || true
fi
if [ ! -e /usr/share/runit/sv.current ]; then
		ln -s /usr/share/runit/sv.now   /usr/share/runit/sv.current
fi
if [ ! -e /usr/share/runit/sv.src ]; then
		ln -s /usr/share/runit/sv   /usr/share/runit/sv.src
fi

#DEBHELPER#