blob: 63263da72688102332e48c5aa398a16466481191 (
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
  | 
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: ipfs_go
# REQUIRE: DAEMON NETWORKING
# BEFORE: LOGIN
# KEYWORD: shutdown
# Add the following lines to /etc/rc.conf to enable ipfs_go:
# ipfs_go_enable="YES"
#
# ipfs_go_enable (bool):    Set to YES to enable ipfs_go
#                           Default: NO
# ipfs_go_user (str):       ipfs_go daemon user
#                           Default: %%IPFS_USER%%
# ipfs_go_group (str):      ipfs_go daemon group
#                           Default: %%IPFS_GROUP%%
. /etc/rc.subr
name=ipfs_go
rcvar=ipfs_go_enable
load_rc_config $name
: ${ipfs_go_enable:="NO"}
: ${ipfs_go_user:="%%IPFS_USER%%"}
: ${ipfs_go_group:="%%IPFS_GROUP%%"}
logfile="%%IPFS_LOGDIR%%/${name}.log"
pidfile="/var/run/${name}.pid"
command="%%PREFIX%%/bin/ipfs-go"
start_precmd="ipfs_go_prestart"
start_cmd="ipfs_go_start"
ipfs_go_prestart() {
  install -d -o ${ipfs_go_user} -g ${ipfs_go_group} -m750 %%IPFS_LOGDIR%%
  [ -d ~%%IPFS_USER%%/.ipfs ] || /usr/bin/su - ${ipfs_go_user} -c "${command} init"
}
ipfs_go_start() {
  echo running ${command} daemon
  export USER=${ipfs_go_user}
  export HOME=$(echo ~%%IPFS_USER%%)
  /usr/sbin/daemon -p ${pidfile} -u ${ipfs_go_user} ${command} daemon >> ${logfile} 2>&1
}
run_rc_command "$1"
 
  |