summaryrefslogtreecommitdiff
path: root/security/ruby-bitwarden/files/rubywarden-api.in
blob: 5b2e1ce0b938f66c4b863f0c246ded9c37140bc7 (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
#!/bin/sh
#
# Created by: Mark Felder <feld@FreeBSD.org>

# PROVIDE: rubywarden-api
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable `rubywarden-api':
#
# rubywarden_api_enable="YES"

. /etc/rc.subr
name=rubywarden_api

rcvar=rubywarden_api_enable
load_rc_config ${name}

: ${rubywarden_api_enable:=NO}
: ${rubywarden_api_host:=localhost}
: ${rubywarden_api_port:=4567}
: ${rubywarden_api_signups:=NO}
: ${rubywarden_api_user:=www}
: ${rubywarden_api_group:=www}
: ${rubywarden_api_chdir=/usr/local/www/rubywarden}

pidfile="/var/run/rubywarden/${name}.pid"
procname=%%RUBY_WITH_SUFFIX%%
command="%%PREFIX%%/bin/rackup"
command_args="-P ${pidfile} -o ${rubywarden_api_host} -p ${rubywarden_api_port} -E production config.ru 2>&1 | logger -t rubywarden &"
start_precmd="start_precmd"

start_precmd()
{
        if [ ! -e /var/run/rubywarden ] ; then
                install -d -o ${rubywarden_api_user} -g ${rubywarden_api_group} /var/run/rubywarden;
        fi

        checkyesno rubywarden_api_signups
        if [ "$?" -eq 0 ]; then
                export ALLOW_SIGNUPS=1
                echo "Bitwarden Signups Enabled"
        fi
}

run_rc_command "$1"