summarylogtreecommitdiffstats
path: root/neo4j.install
blob: 6ae39408e26f7693d2f215751be65a5a4e64a010 (plain)
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
post_install() {
  assert_user_and_group_exist
  directory_permissions

  /usr/bin/systemd-tmpfiles --create neo4j.conf
}

post_upgrade() {
  assert_user_and_group_exist
  directory_permissions
}

post_remove() {
  if getent passwd neo4j >/dev/null; then
    userdel neo4j
  fi
  if getent group neo4j >/dev/null; then
    groupdel neo4j
  fi
}

directory_permissions() {
  chown -R neo4j.neo4j /etc/neo4j/certificates
  chown -R neo4j.neo4j /var/lib/neo4j
  chown -R neo4j.neo4j /var/log/neo4j
  chown -R neo4j.neo4j /etc/neo4j
}

assert_user_and_group_exist() {
  if ! getent group neo4j >/dev/null; then
    groupadd --system neo4j
  fi
  if ! getent passwd neo4j >/dev/null; then
    useradd --system -g neo4j -d /var/lib/neo4j -s /bin/false neo4j
  fi
}