Skip to content

Commit 313cc18

Browse files
author
Bartosz Kuzma
committed
Add rc.d script for sftpgo
1 parent 3d83aed commit 313cc18

3 files changed

Lines changed: 36 additions & 25 deletions

File tree

sftpgo/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ EGDIR= ${PREFIX}/share/examples/sftpgo
1616
USE_LANGUAGES= c
1717
USE_TOOLS= tar
1818

19+
DEPENDS+= daemonize>=1.7.8:../../sysutils/daemonize
20+
1921
GO_BUILD_PATTERN=
2022

2123
CONF_FILES= ${EGDIR}/sftpgo.json ${PKG_SYSCONFDIR}/sftpgo.json
@@ -43,6 +45,9 @@ SUBST_SED.set-path= -e 's|"openapi"|"${PREFIX}/share/sftpgo/openapi"|g'
4345
SUBST_SED.set-path+= -e 's|"static"|"${PREFIX}/share/sftpgo/static"|g'
4446
SUBST_SED.set-path+= -e 's|"templates"|"${PREFIX}/share/sftpgo/templates"|g'
4547

48+
RCD_SCRIPTS+= sftpgo
49+
FILES_SUBST+= SFTPGO_USER=${SFTPGO_USER:Q}
50+
4651
.include "go-modules.mk"
4752

4853
post-build:

sftpgo/TODO

Lines changed: 0 additions & 1 deletion
This file was deleted.

sftpgo/files/sftpgo.sh

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11
#!@RCD_SCRIPTS_SHELL@
2-
2+
#
3+
# $NetBSD$
4+
#
35
# PROVIDE: sftpgo
46
# REQUIRE: DAEMON
5-
6-
if [ -f /etc/rc.subr ]; then
7-
. /etc/rc.subr
8-
fi
7+
# KEYWORD: shutdown
98

109
name="sftpgo"
11-
rcvar=$name
12-
command="@PREFIX@/sbin/bitlbee"
13-
pidfile="@VARBASE@/run/${name}/pid"
14-
command_args="-F" # run as a fork daemon
15-
start_precmd="bitlbee_precmd"
16-
17-
bitlbee_precmd()
18-
{
19-
if [ ! -d "@VARBASE@/run/${name}" ]; then
20-
@MKDIR@ "@VARBASE@/run/${name}"
21-
@CHMOD@ 0700 "@VARBASE@/run/${name}"
22-
@CHOWN@ @BITLBEE_USER@:@BITLBEE_GROUP@ "@VARBASE@/run/${name}"
23-
fi
24-
}
25-
26-
if [ -f /etc/rc.subr ]; then
27-
load_rc_config $name
10+
11+
command="@PREFIX@/sbin/daemonize"
12+
13+
pidfile="@VARBASE@/run/${name}.pid"
14+
15+
task="@PREFIX@/bin/${name}"
16+
task_args="serve --config-dir @VARBASE@/sftpgo --config-file @PKG_SYSCONFDIR@/sftpgo.json"
17+
18+
procname="${task}"
19+
20+
command_args="-p ${pidfile} \
21+
-u @SFTPGO_USER@ \
22+
-c @VARBASE@/${name} \
23+
-e @VARBASE@/${name}/${name}.stderr \
24+
-o @VARBASE@/${name}/${name}.stdout \
25+
${task} ${task_args}"
26+
27+
if [ -f @SYSCONFBASE@/rc.subr ]; then
28+
. @SYSCONFBASE@/rc.subr
29+
30+
rcvar=${name}
31+
pidfile="@VARBASE@/run/${name}.pid"
32+
33+
load_rc_config ${name}
2834
run_rc_command "$1"
2935
else
30-
echo -n "${name}"
31-
${command} ${bitlbee_flags} ${command_args}
36+
@ECHO@ -n " ${name}"
37+
38+
${command} ${command_args}
3239
fi

0 commit comments

Comments
 (0)