File: partimage-server.postinst

package info (click to toggle)
partimage 0.6.9-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,572 kB
  • sloc: cpp: 15,727; sh: 10,867; makefile: 167; sed: 16
file content (83 lines) | stat: -rw-r--r-- 1,781 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

set -e

[ ! "$1" = "configure" ] && exit 0

opensslpath=/usr/bin/openssl
target=/var/lib/partimaged

clean()
{
	rm -f /etc/partimaged/privkey.pem
	rm -f /etc/partimaged/partimaged.rand
}


create_user()
{
	adduser --system \
		--disabled-password \
		--shell /bin/false \
		--gecos "Partimage Server" \
		--group \
		--no-create-home \
		--home /var/lib/partimaged/ \
		--quiet \
		partimag

}

create_certificates()
{
        $opensslpath req -new -x509 -nodes -config \
      		/etc/partimaged/partimage-certs.cnf \
		-out /etc/partimaged/partimaged.cert -keyout \
		/etc/partimaged/partimaged.key

	rm -f /etc/partimaged/partimaged.csr

	chmod 750 /etc/partimaged
	chown partimag:partimag /etc/partimaged
	chmod 600 /etc/partimaged/partimaged.key
	chmod 600 /etc/partimaged/partimaged.cert
	chown partimag:partimag /etc/partimaged/partimaged.key
	chown partimag:partimag /etc/partimaged/partimaged.cert
}

fix_permissions()
{
	chown partimag:partimag $target
	chmod 750 $target

	chown partimag:partimag /etc/partimaged/partimagedusers
	chmod 0600 /etc/partimaged/partimagedusers

	chown partimag:partimag /var/log/partimage
}

# Create a system user/group partimag
create_user

# Now that we have a user/group partimag set the appropriate access rights
fix_permissions

# SSL Certs
if [ -s "/etc/partimaged/partimaged.key" ]; then
	echo "OpenSSL certificate already exists. Leaving..."
else
	if [ ! -s "/etc/partimaged/partimage-certs.cnf" ]; then
		echo "I cannot find the /etc/partimaged/partimage-certs.cnf file."
		echo "SSL certificate will not be created!"
	else
		echo "Creating certificates for partimage-server"
		create_certificates
	fi
fi

if dpkg --compare-versions "$2" lt-nl "0.6.9-10~"; then
	update-rc.d -f partimaged remove || true
fi

#DEBHELPER#