summarylogtreecommitdiffstats
path: root/peerbanhelper.install
blob: e34ddda79ec57ae929a3f65fecfaeb88646885da (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
USER=peerbanhelper

link_config() {
  ln -sf '/etc/peerbanhelper/config.yml' "/var/lib/$USER/config.yml"
  ln -sf '/etc/peerbanhelper/profile.yml' "/var/lib/$USER/profile.yml"
  chown $USER: "/var/lib/$USER/"{config,profile}'.yml'
}

create_logs_dir() {
  mkdir "/var/log/$USER"
  chown $USER: "/var/log/$USER"
}

## arg 1:  the new package version
post_install() {
  if ! id -u $USER > /dev/null 2>&1; then
    useradd --system --shell '/usr/bin/nologin' --create-home --home-dir "/var/lib/$USER" $USER
  fi
  chown --recursive $USER: '/etc/peerbanhelper'
  link_config
  create_logs_dir
}

## arg 1:  the new package version
## arg 2:  the old package version
post_upgrade() {
  link_config
  create_logs_dir
}