summarylogtreecommitdiffstats
path: root/journey.install
blob: f749fd2b61e4b360fcb60b37ba1cde12d813a2aa (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
pre_install() {
  # Create a system user for journey to run under
  if [[ ! $(id journey 2>/dev/null) ]]; then
    /usr/bin/useradd -r -d /usr/lib/journey -s /usr/bin/bash -U -G http journey
  fi
}

post_install() {
  # Fix ownership of files and directories
  if [[ $(id journey 2>/dev/null) ]]; then
    chown -R journey:journey /opt/journey
  fi
  # Reload to daemon to make sure it finds the service file
  systemctl daemon-reload
}

pre_upgrade() {
  pre_install
}

post_upgrade() {
  # Reload systemd for the new/updated service file and restart the service if
  # it is already running on the system
  systemctl daemon-reload
  systemctl condrestart journey.service
}

pre_remove() {
  # Stop the service regardless if it is running
  systemctl stop journey.service
}

post_remove() {
  # Remove the user and group
  if [[ ! $(id journey 2>/dev/null) ]]; then
    userdel journey
    groupdel journey
  fi
  # Reload systemd for the removed service file
  systemctl daemon-reload
}