forked from ports/contrib
52 lines
1.2 KiB
Desktop File
52 lines
1.2 KiB
Desktop File
#!/bin/bash
|
|
#
|
|
# /etc/rc.d/synapse: start/stop synapse daemon
|
|
#
|
|
|
|
error() {
|
|
printf "\e[31m%s\e[0m\n" "[ERRO] $*"
|
|
}
|
|
|
|
if [[ -e /usr/bin/doas ]]; then
|
|
SUDO=/usr/bin/doas
|
|
elif [[ -e /usr/bin/sudo ]]; then
|
|
SUDO=/usr/bin/sudo
|
|
else
|
|
error "Needs either core/sudo or contrib/opendoas installed and configured!"
|
|
exit 1
|
|
fi
|
|
|
|
PID=/var/run/homeserver.pid
|
|
|
|
case $1 in
|
|
start)
|
|
if [ ! -e /etc/synapse/homeserver.yaml ]; then
|
|
printf "\e[31m%s\e[0m\n" "[ERRO] Needs either core/sudo or contrib/opendoas installed and configured!"
|
|
error "Please read README.md from this port and create a homeserver.yaml file first"
|
|
exit 1
|
|
fi
|
|
|
|
[[ ! -e /run/synapse ]] && install -g synapse -o synapse -d /run/synapse
|
|
|
|
$SUDO -u synapse /usr/bin/synctl start /etc/synapse/homeserver.yaml ;;
|
|
stop)
|
|
/usr/bin/synctl stop /etc/synapse/homeserver.yaml ;;
|
|
restart)
|
|
$0 stop
|
|
$0 start ;;
|
|
status)
|
|
if [ -e $PID ]; then
|
|
if [ -d "/proc/$(cat $PID)" ]; then
|
|
echo "synapse server is running with pid $(cat $PID)"
|
|
else
|
|
echo "pidfile $PID exists, but synapse server is not running"
|
|
fi
|
|
else
|
|
echo "synapse server is not running"
|
|
fi ;;
|
|
*)
|
|
echo "usage: $0 [start|stop|restart|status]" ;;
|
|
esac
|
|
|
|
# End of file
|