summarylogtreecommitdiffstats
path: root/etherpad-lite.install
blob: ff06746a0fa6f5cc37d52a9d17a52f7f44e67f64 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
post_install(){
  getent group etherpad &>/dev/null || groupadd -r etherpad &>/dev/null
  getent passwd etherpad &>/dev/null || \
    useradd -r -s /usr/bin/bash -g etherpad -G etherpad,http -m \
    -d /var/lib/etherpad-lite etherpad >/dev/null
  
  if [ -h "/usr/share/webapps/etherpad-lite/var/etherpad-lite" ]; then #remove old invalid stuff
    rm /usr/share/webapps/etherpad-lite/var/etherpad-lite
  fi
  if [ -d "/usr/share/webapps/etherpad-lite/var" ]; then
    if [ ! -h "/usr/share/webapps/etherpad-lite/var" ]; then
      mkdir -p /var/lib/etherpad-lite #to be sure this exists.
      mv /usr/share/webapps/etherpad-lite/var/* /var/lib/etherpad-lite/
      rmdir /usr/share/webapps/etherpad-lite/var
      if [ $? -ne 0 ]; then
        exit 1
      fi
    fi
  fi
  
  ln -ds /var/lib/etherpad-lite /usr/share/webapps/etherpad-lite/var
  if [ -f "/etherpad" ]; then #removing old invalid file
    rm /etherpad
  fi
  
  find /usr/share/webapps/etherpad-lite \
        \( -type f -exec chmod 655 {} \; \) , \
        \( -type d -exec chmod 755 {} \; \)
  find /var/lib/etherpad-lite \
        \( -type f -exec chmod 655 {} \; \) , \
        \( -type d -exec chmod 755 {} \; \)
  
  chown -R etherpad:etherpad /usr/share/webapps/etherpad-lite
  chown -R etherpad:etherpad /var/lib/etherpad-lite
  
  chmod u+x /usr/share/webapps/etherpad-lite/bin/run.sh
  chmod u+x /usr/share/webapps/etherpad-lite/bin/installDeps.sh

  #FIXME do we need this really?
  #systemd-tmpfiles --create etherpad-lite.conf
  
  if [ -f "/usr/share/webapps/etherpad-lite/settings.json" ]; then
    if [ ! -h "/usr/share/webapps/etherpad-lite/settings.json" ]; then
      mkdir -p /etc/webapps/etherpad-lite/
      mv /usr/share/webapps/etherpad-lite/settings.json /etc/webapps/etherpad-lite/settings.json
      ln -s /etc/webapps/etherpad-lite/settings.json /usr/share/webapps/etherpad-lite/settings.json
    fi
  fi
  #fix npm bug, using wrong python instance
  npm config set python /usr/bin/python2 -g
}

post_upgrade(){
  post_install
}

pre_remove() {
  systemctl stop etherpad-lite || true
  pkill -u etherpad || true
}
  
post_remove() {
  getent passwd etherpad &>/dev/null && userdel etherpad >/dev/null
  getent group etherpad &>/dev/null && groupdel etherpad >/dev/null
}