]> git.proxmox.com Git - ceph.git/blob - ceph/debian/ceph-common.postinst
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / debian / ceph-common.postinst
1 #!/bin/sh
2 # vim: set noet ts=8:
3 # postinst script for ceph-mds
4 #
5 # see: dh_installdeb(1)
6
7 set -e
8
9 # summary of how this script can be called:
10 #
11 # postinst configure <most-recently-configured-version>
12 # old-postinst abort-upgrade <new-version>
13 # conflictor's-postinst abort-remove in-favour <package> <new-version>
14 # postinst abort-remove
15 # deconfigured's-postinst abort-deconfigure in-favour <failed-install-package> <version> [<removing conflicting-package> <version>]
16 #
17
18 # for details, see http://www.debian.org/doc/debian-policy/ or
19 # the debian-policy package
20
21
22 # Let the admin override these distro-specified defaults. This is NOT
23 # recommended!
24 [ -f "/etc/default/ceph" ] && . /etc/default/ceph
25
26 [ -z "$SERVER_HOME" ] && SERVER_HOME=/var/lib/ceph
27 [ -z "$SERVER_USER" ] && SERVER_USER=ceph
28 [ -z "$SERVER_NAME" ] && SERVER_NAME="Ceph storage service"
29 [ -z "$SERVER_GROUP" ] && SERVER_GROUP=ceph
30 [ -z "$SERVER_UID" ] && SERVER_UID=64045 # alloc by Debian base-passwd maintainer
31 [ -z "$SERVER_GID" ] && SERVER_GID=$SERVER_UID
32
33
34 # Groups that the user will be added to, if undefined, then none.
35 [ -z "$SERVER_ADDGROUP" ] && SERVER_ADDGROUP=
36
37 case "$1" in
38 configure)
39 # create user to avoid running server as root
40 # 1. create group if not existing
41 if ! getent group | grep -q "^$SERVER_GROUP:" ; then
42 echo -n "Adding group $SERVER_GROUP.."
43 addgroup --quiet --system --gid $SERVER_GID \
44 $SERVER_GROUP 2>/dev/null ||true
45 echo "..done"
46 fi
47 # 2. create user if not existing
48 if ! getent passwd | grep -q "^$SERVER_USER:"; then
49 echo -n "Adding system user $SERVER_USER.."
50 adduser --quiet \
51 --system \
52 --no-create-home \
53 --disabled-password \
54 --uid $SERVER_UID \
55 --gid $SERVER_GID \
56 $SERVER_USER 2>/dev/null || true
57 echo "..done"
58 fi
59 # 3. adjust passwd entry
60 echo -n "Setting system user $SERVER_USER properties.."
61 usermod -c "$SERVER_NAME" \
62 -d $SERVER_HOME \
63 -g $SERVER_GROUP \
64 $SERVER_USER
65 echo "..done"
66
67 # 5. adjust file and directory permissions
68 if ! dpkg-statoverride --list $SERVER_HOME >/dev/null
69 then
70 chown $SERVER_USER:$SERVER_GROUP $SERVER_HOME
71 chmod u=rwx,g=rx,o= $SERVER_HOME
72 fi
73 if ! dpkg-statoverride --list /var/log/ceph >/dev/null
74 then
75 chown -R $SERVER_USER:$SERVER_GROUP /var/log/ceph
76 # members of group ceph can log here, but cannot remove
77 # others' files. non-members cannot read any logs.
78 chmod u=rwx,g=rwxs,o=t /var/log/ceph
79 fi
80
81 # 6. fix /var/run/ceph
82 if [ -d /var/run/ceph ]; then
83 echo -n "Fixing /var/run/ceph ownership.."
84 chown $SERVER_USER:$SERVER_GROUP /var/run/ceph
85 echo "..done"
86 fi
87
88 # create /run/ceph. fail softly if systemd isn't present or
89 # something.
90 [ -x /bin/systemd-tmpfiles ] && systemd-tmpfiles --create || true
91 ;;
92 abort-upgrade|abort-remove|abort-deconfigure)
93 :
94 ;;
95
96 *)
97 echo "postinst called with unknown argument \`$1'" >&2
98 exit 1
99 ;;
100 esac
101
102 # dh_installdeb will replace this with shell code automatically
103 # generated by other debhelper scripts.
104
105 #DEBHELPER#
106
107 exit 0