aboutsummaryrefslogtreecommitdiff
path: root/mautrix-whatsapp/files/rc.mautrix-whatsapp.new
blob: 1bc38466412131bdb887173d3f0ebb799da0d410 (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
#!/bin/sh
#
# Startup/shutdown script for the matrix Dendrite service.
#

create_run_dir() {
  if [ ! -d /run/mautrix-whatsapp/ ]; then
    mkdir -p /run/mautrix-whatsapp
    chown :mautrix-whatsapp /run/mautrix-whatsapp
    chmod g+wX /run/mautrix-whatsapp
  fi
}

start() {
  echo "Starting matrix Dendrite service"
  create_run_dir

  daemon \
    --chdir=/var/lib/mautrix-whatsapp \
    --name=mautrix-whatsapp \
    --pidfiles=/run/mautrix-whatsapp \
    --user=mautrix-whatsapp \
    -- mautrix-whatsapp --config=/etc/mautrix-whatsapp/config.yaml
}

status() {
  create_run_dir

  /usr/bin/daemon --name=mautrix-whatsapp --pidfiles=/run/mautrix-whatsapp --running --verbose
}

stop() {
  echo "Stopping matrix Dendrite service"
  create_run_dir

  /usr/bin/daemon --name=mautrix-whatsapp --pidfiles=/run/mautrix-whatsapp --stop
}

case "$1" in
start)
  start
  ;;
status)
  status
  ;;
stop)
  stop
  ;;
*)
  echo "Usage: $0 {start|stop|status}"
  exit 1
esac