cloud for storage and far more. This first release also includes DMAIL (distributed mail), inherently spam resistant, inherently encrypted, uncensorable, free distributed messaging. WWW: https://morph.is PR: 215804 Submitted by: Yuri Victorovich <yuri@rawbw.com>
88 lines
1.9 KiB
Bash
88 lines
1.9 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# Copyright (C) 2016 by Yuri Victorovich. All rights reserved.
|
|
|
|
# PROVIDE: morphis
|
|
# REQUIRE: NETWORKING SERVERS tor
|
|
# KEYWORD: shutdown
|
|
|
|
# morphis is disabled by default, if you have configuration file
|
|
#
|
|
# Add the following line to /etc/rc.conf to enable morphis:
|
|
#
|
|
#morphis_enable="YES"
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
name="morphis"
|
|
rcvar=morphis_enable
|
|
start_cmd="morphis_start"
|
|
stop_cmd="morphis_stop"
|
|
status_cmd="morphis_status"
|
|
|
|
load_rc_config ${name}
|
|
|
|
: ${morphis_enable="NO"}
|
|
: ${morphis_args=""}
|
|
|
|
is_process_running() {
|
|
local pidfile=$1
|
|
[ -f $pidfile ] && procstat `cat $pidfile` >/dev/null 2>&1
|
|
}
|
|
|
|
stop_daemon() {
|
|
# assume PID is also PGID (daemon(8) PID is always PGID)
|
|
[ -f "$1" ] && kill -- -$(cat $1)
|
|
}
|
|
|
|
morphis_start() {
|
|
local logfile=/var/log/morphis.log
|
|
local pidfile=/var/run/morphis.pid
|
|
# already running?
|
|
if is_process_running $pidfile; then
|
|
echo "morphis is already running (pid=$(cat $pidfile))"
|
|
return 1
|
|
fi
|
|
# log file
|
|
touch $logfile
|
|
chmod 640 $logfile
|
|
# user depends on the port option, so better force it on directories to avoid user confusion
|
|
chown -R %%USER%%:%%GROUP%% /var/db/morphis
|
|
# run
|
|
cd %%LOCALBASE%%/share/morphis
|
|
/usr/sbin/daemon -P $pidfile -u %%USER%% %%LOCALBASE%%/share/morphis/run.sh ${morphis_args} >>$logfile 2>&1
|
|
# make sure it runs
|
|
if is_process_running $pidfile; then
|
|
echo "started morphis (pid=$(cat $pidfile))"
|
|
else
|
|
echo "failed to start morphis"
|
|
fi
|
|
}
|
|
|
|
morphis_stop() {
|
|
local pidfile=/var/run/morphis.pid
|
|
if is_process_running $pidfile; then
|
|
echo "stopping morphis (pid=$(cat $pidfile))"
|
|
stop_daemon $pidfile
|
|
else
|
|
echo "morphis isn't running"
|
|
fi
|
|
}
|
|
|
|
morphis_status() {
|
|
local pidfile=/var/run/morphis.pid
|
|
if is_process_running $pidfile; then
|
|
echo "morphis is running, pid=$(cat $pidfile)"
|
|
else
|
|
echo "morphis isn't running"
|
|
fi
|
|
}
|
|
|
|
command="/usr/bin/true"
|
|
|
|
run_rc_command "$1"
|