forked from oVirt/vdsm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvdsm.postinst
122 lines (105 loc) · 4.11 KB
/
vdsm.postinst
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
# postinst script for vdsm
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
VDSM_USER=vdsm
VDSM_GROUP=kvm
QEMU_USER=qemu
QEMU_GROUP=kvm
SNLK_GROUP=sanlock
SNLK_USER=sanlock
LIBVIRT_SOCK_GROUP=libvirtd
CDROM_GROUP=cdrom
INSTALLDIR="install -dDm 0755 -o $VDSM_USER -g $VDSM_GROUP"
case "$1" in
configure)
getent passwd "$VDSM_USER" >/dev/null || \
useradd -r -u 36 -g "$VDSM_GROUP" -d /var/lib/vdsm \
-s /usr/sbin/nologin -c "Node Virtualization Manager" "$VDSM_USER"
#getent passwd "$SNLK_USER" >/dev/null || useradd -r -g "$SNLK_GROUP" \
# -s /bin/false -c "sanlock service" "$SNLK_USER"
usermod -a -G "$QEMU_GROUP","$SNLK_GROUP","$LIBVIRT_SOCK_GROUP" "$VDSM_USER"
usermod -a -G "$QEMU_GROUP","$VDSM_GROUP" "$SNLK_USER"
usermod -a -G "$CDROM_GROUP" "$QEMU_USER"
start_conf_section="## beginning of configuration section by vdsm"
end_conf_section="## end of configuration section by vdsm"
if ! grep "$start_conf_section" /etc/default/sanlock ; then
echo "$start_conf_section" >> /etc/default/sanlock
echo "sanlock_opts=\"\$sanlock_opts -U sanlock -G sanlock\"" >> /etc/default/sanlock
echo "$end_conf_section" >> /etc/default/sanlock
fi
$INSTALLDIR /rhev
$INSTALLDIR /rhev/data-center
$INSTALLDIR /rhev/data-center/hsm-tasks
$INSTALLDIR /rhev/data-center/mnt
$INSTALLDIR /var/lib/libvirt/qemu/channels
chmod 775 /var/lib/libvirt/qemu/channels
$INSTALLDIR /etc/pki/vdsm
$INSTALLDIR /etc/pki/vdsm/keys
$INSTALLDIR /etc/pki/vdsm/certs
$INSTALLDIR /var/lib/vdsm
$INSTALLDIR /var/lib/vdsm/connections
$INSTALLDIR /var/lib/vdsm/netconfback
$INSTALLDIR /var/run/vdsm
$INSTALLDIR /var/run/vdsm/payload
$INSTALLDIR /var/run/vdsm/v2v
$INSTALLDIR /var/run/vdsm/sourceRoutes
$INSTALLDIR /var/run/vdsm/trackedInterfaces
$INSTALLDIR /var/log/vdsm
$INSTALLDIR /var/log/vdsm/backup
chmod g+x /var/lib/libvirt/qemu
chmod 644 /etc/iscsi/initiatorname.iscsi
sysctl -q -p /etc/sysctl.d/vdsm.conf
vdsm-tool load-needed-modules
echo /usr/lib/sanlock/ > /etc/ld.so.conf.d/sanlock.conf
ldconfig
udevadm control --reload-rules
initctl reload-configuration
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
# vdsm hooks are invoked as .pyc files, but the .pyc files are generated by
# dh helpers. Restarting vdsmd should be run after dh helpers so that the
# hooks are invoked correctly.
if [ "$1" = "configure" ]; then
supervdsmd_start_required='no'
vdsmd_start_required='no'
# Both vdsm and supervdsm should be managed here and must be restarted if
# ran before (code might changed)
if initctl status supervdsmd | grep -q start/running ; then
supervdsmd_start_required='yes'
fi
if initctl status vdsmd | grep -q start/running ; then
vdsmd_start_required='yes'
fi
if ! vdsm-tool is-configured --module libvirt >/dev/null 2>&1; then
vdsm-tool configure --module libvirt --force >/dev/null 2>&1
fi
if [ "${supervdsmd_start_required}" = 'yes' ]; then
initctl stop supervdsmd || :
initctl start supervdsmd || :
fi
if [ "${vdsmd_start_required}" = 'yes' ]; then
initctl stop vdsmd || :
initctl start vdsmd || :
fi
fi
exit 0