]> git.proxmox.com Git - mirror_frr.git/blob - debianpkg/frr.preinst
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / debianpkg / frr.preinst
1 #!/bin/bash
2
3 if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
4 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"}
5 set -e
6 set -u
7
8 # creating frrvty group if it isn't already there
9 if ! getent group frrvty >/dev/null; then
10 addgroup --system frrvty >/dev/null
11 fi
12
13 # creating frr group if it isn't already there
14 if ! getent group frr >/dev/null; then
15 addgroup --system frr >/dev/null
16 fi
17
18 # creating frr user if he isn't already there
19 if ! getent passwd frr >/dev/null; then
20 adduser \
21 --system \
22 --ingroup frr \
23 --home /var/run/frr/ \
24 --gecos "Frr routing suite" \
25 --shell /bin/false \
26 frr >/dev/null
27 fi
28
29 # We may be installing over an older version of
30 # frr and as such we need to intelligently
31 # check to see if the frr user is in the frrvty
32 # group.
33 if ! id frr | grep &>/dev/null 'frrvty'; then
34 usermod -a -G frrvty frr >/dev/null
35 fi
36
37 # Do not change permissions when upgrading as it would violate policy.
38 if [ "$1" = "install" ]; then
39 # Logfiles are group readable in case users were put into the frr group.
40 d=/var/log/frr/
41 mkdir -p $d
42 chown frr:frr $d
43 chown --quiet frr:frr $d/* | true
44 chmod u=rwx,go=rx $d
45 find $d -type f -print0 | xargs -0 --no-run-if-empty chmod u=rw,g=r,o=
46
47 # Strict permissions for the sockets.
48 d=/var/run/frr/
49 mkdir -p $d
50 chown frr:frr $d
51 chown --quiet frr:frr $d/* | true
52 chmod u=rwx,go=rx $d
53 find $d -type f -print0 | xargs -0 --no-run-if-empty chmod u=rw,go=
54
55 # Config files. Vtysh does not have access to the individual daemons config file
56 d=/etc/frr/
57 mkdir -p $d
58 chown frr:frrvty $d
59 chmod ug=rwx,o=rx $d
60 find $d -type f -print0 | xargs -0 --no-run-if-empty chown frr:frr
61 find $d -type f -print0 | xargs -0 --no-run-if-empty chmod u=rw,g=r,o=
62
63 # Exceptions for vtysh.
64 f=$d/vtysh.conf
65 if [ -f $f ]; then
66 chown frr:frrvty $f
67 chmod u=rw,g=r,o= $f
68 fi
69
70 # Exceptions for vtysh.
71 f=$d/frr.conf
72 if [ -f $d/Zebra.conf ]; then
73 mv $d/Zebra.conf $f
74 fi
75 if [ -f $f ]; then
76 chown frr:frrvty $f
77 chmod u=rw,g=r,o= $f
78 fi
79 fi
80
81 #DEBHELPER#