summaryrefslogtreecommitdiff
path: root/community/polipo/polipo.install
blob: 03ed67ead0f4a3af23417c8ae4676e5e763fe94b (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
infodir=/usr/share/info
filelist=(polipo.info)

create_polipo_user() {
  getent group polipo &>/dev/null || groupadd -g 185 polipo >/dev/null
  getent passwd polipo &>/dev/null || useradd -u 185 -g polipo \
                                              -d /var/cache/polipo \
                                              -c 'Caching web proxy' \
                                              -s /bin/nologin polipo >/dev/null
}

post_install() {
  [ -x usr/bin/install-info ] || return 0
  for file in ${filelist[@]}; do
    install-info $infodir/$file $infodir/dir 2> /dev/null
  done
  create_polipo_user
}

post_upgrade() {
  if [[ $(vercmp $2 1.0.4.1-11) -le 0 ]]; then
    echo Stopping polipo service in order to modify the user/group.
    systemctl stop polipo

    # in case the user/group were already created as recommended by the wiki
    userdel polipo &>/dev/null
    groupdel polipo &>/dev/null

    create_polipo_user
    chown -R 185:185 /var/cache/polipo

    echo You may now restart the polipo service.
  fi

  post_install $1
}

pre_remove() {
  [ -x usr/bin/install-info ] || return 0
  for file in ${filelist[@]}; do
    install-info --delete $infodir/$file $infodir/dir 2> /dev/null
  done
}

post_remove() {
  getent passwd polipo &>/dev/null && userdel polipo >/dev/null
  getent group polipo &>/dev/null && groupdel polipo >/dev/null
  true
}

# vim:set ts=2 sw=2 et: