summaryrefslogtreecommitdiff
path: root/www/butterfly/files/butterfly.in
blob: 561358c297b21631d4958928afe66eb62236dcdf (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
#!/bin/sh

# PROVIDE: butterfly
# REQUIRE: LOGIN
#
# Add the following line to /etc/rc.conf to enable butterfly:
#
# butterfly_enable="YES"
#

: ${butterfly_enable="NO"}
: ${butterfly_user="root"}
: ${butterfly_args="--unsecure"}

. /etc/rc.subr

name=butterfly
rcvar=butterfly_enable
pidfile=/var/run/${name}.pid
start_cmd="start_butterfly"

load_rc_config $name

start_butterfly() {
  echo "Starting ${name}."
  if ! [ -r %%ETCDIR%%/ssl/butterfly_localhost.crt -a %%ETCDIR%%/ssl/butterfly_localhost.key -a %%ETCDIR%%/ssl/butterfly_ca.crt ]; then
    %%PREFIX%%/bin/butterfly.server.py --generate-certs --host=localhost &&
    echo "${name}: generated the ssl certificate in %%ETCDIR%%/ssl"
  fi
  daemon -p $pidfile -u ${butterfly_user} %%PREFIX%%/bin/butterfly.server.py ${butterfly_args} >/var/log/${name}.log 2>&1
}

command="%%PYTHON_CMD%%"
run_rc_command "$1"