File: puppet.postinst

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (76 lines) | stat: -rwxr-xr-x 2,828 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
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
#!/bin/sh

set -e

if [ "$1" = "configure" ]; then

	# Create the "puppet" user
	if ! getent passwd puppet > /dev/null; then
		adduser --quiet --system --group --home /var/lib/puppet  \
			--no-create-home                                 \
			--gecos "Puppet configuration management daemon" \
			puppet
	fi

        # Create the "puppet" group, if it is missing, and set the
        # primary group of the "puppet" user to this group.
        if ! getent group puppet > /dev/null; then
            addgroup --quiet --system puppet
            usermod -g puppet puppet
        fi

	# Set correct permissions and ownership for puppet directories
	if ! dpkg-statoverride --list /var/log/puppet >/dev/null 2>&1; then
		dpkg-statoverride --update --add puppet puppet 0750 /var/log/puppet
	fi

	# Create folders common to "puppet" and "puppetmaster", which need
	# to be owned by the "puppet" user
	if ! dpkg-statoverride --list /var/lib/puppet >/dev/null 2>&1; then
		dpkg-statoverride --update --add puppet puppet 0750 /var/lib/puppet
	fi

	if ! dpkg-statoverride --list /var/cache/puppet/state >/dev/null 2>&1; then
		dpkg-statoverride --update --add puppet puppet 0750 /var/cache/puppet/state
	fi

	if [ -n "$2" ] && dpkg --compare-versions "$2" gt "4.4.2-1~" && \
		dpkg --compare-versions "$2" lt "4.8.1-3~"; then
		# Between 4.4.2-1 and 4.8.1-3, puppet was called 'puppet-agent'
		# Preserve the systemd and SysV service states
		if deb-systemd-helper debian-installed puppet-agent.service; then
			# dh_systemd_enable will not enable the service by
			# default as of 4.8.2-2; enable it if puppet-agent was
			# enabled.
			deb-systemd-helper unmask puppet.service >/dev/null || true
			if deb-systemd-helper --quiet was-enabled puppet-agent.service; then
				deb-systemd-helper enable puppet.service >/dev/null || true
			else
				deb-systemd-helper update-state puppet.service >/dev/null || true
			fi
		fi

		if [ -x /etc/init.d/puppet-agent ] && \
			! ls /etc/rc[S2345].d/S[0-9][0-9]puppet-agent >/dev/null 2>&1; then
			update-rc.d puppet defaults-disabled >/dev/null || true
		fi

		# Remove puppet-agent's symlinks to avoid duplicate starts
		# under SysV
		update-rc.d -f puppet-agent remove >/dev/null || true
	elif [ -n "$2" ] && dpkg --compare-versions "$2" lt "4.4.2-1~"; then
		# The 4.x series has a different lock path. Mirror the old
		# agent lock to the new path to preserve the lock state.
		# Note that we could disable the service here instead, but
		# there is always the case $old_lock was not used because of
		# local configuration (in which case $new_lock will probably
		# not be consulted as well).
		old_lock="/var/lib/puppet/state/agent_disabled.lock"
		new_lock="/var/cache/puppet/state/agent_disabled.lock"
		if [ -f "$old_lock" ]; then
			cp "$old_lock" "$new_lock"
		fi
	fi
fi

#DEBHELPER#