aboutsummaryrefslogtreecommitdiff
path: root/net-im/py-matrix-synapse/files/synapse.in
blob: 7d618f2b398c48c240ad33e5d2d0541b0d4c6f1e (plain) (blame)
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
#!/bin/sh
#
# Created by: Mark Felder <feld@FreeBSD.org>
# $FreeBSD$
#

# PROVIDE: synapse
# REQUIRE: LOGIN postgresql
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable `synapse':
#
# synapse_enable="YES"

. /etc/rc.subr
name=synapse

rcvar=synapse_enable
load_rc_config ${name}

: ${synapse_enable:=NO}
: ${synapse_user:=%%USERS%%}
: ${synapse_conf:=%%ETCDIR%%/homeserver.yaml}
: ${synapse_dbdir:=%%DBDIR%%}
: ${synapse_logdir:=%%LOGDIR%%}
: ${synapse_pidfile:=%%PIDDIR%%/homeserver.pid}

pidfile="${synapse_pidfile}"
procname=%%PYTHON_CMD%%
command=%%PYTHON_CMD%%
command_args="-m synapse.app.homeserver --daemonize -c ${synapse_conf}"
start_precmd=start_precmd

start_precmd()
{
	if [ ! -d ${synapse_pidfile%/*} ] ; then
		install -d -o %%USERS%% -g wheel ${synapse_pidfile%/*};
	fi

	if [ ! -d ${synapse_dbdir} ] ; then
		install -d -o %%USERS%% -g wheel ${synapse_dbdir};
	fi

	if [ ! -d ${synapse_logdir} ] ; then
		install -d -o %%USERS%% -g wheel ${synapse_logdir};
	fi

	if $(grep -q CHANGEME ${synapse_conf}) ; then
		echo "Error: Default secret values in config."
		echo "Please replace the CHANGEME values in ${synapse_conf}"
		exit 1
	fi
}

run_rc_command "$1"