blob: e19894f147caa4580fb8f74c1ef31626d8997248 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/sh
# PROVIDE: calibre
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable calibre_server:
#
# calibre_enable (bool): Set it to "YES" to enable calibre
# Default is "NO".
# calibre_port (int): port that calibre_server listens on
# Default is 8080
# calibre_user (string): user that calibre_server runs as
# Default is calibre
# calibre_home (string): home directory for calibre_server
# Default is the home directory of calibre_user
# calibre_url_prefix (string): prefix to append to all URLs
# default is unset
# calibre_logfile (string): log file location
# Default /var/log/calibre-server/calibre-server.log
# calibre_logsize (int): size of log file before being rotated in MBs
# Default 10 MB
# calibre_flags (string): Any further flags to customize configuration
# Default empty
# calibre_library (string): path to library folder to serve content from
#
#
##########################################################
. /etc/rc.subr
export PATH=$PATH:%%LOCALBASE%%/sbin:%%LOCALBASE%%/bin
name=calibre
rcvar=calibre_enable
load_rc_config $name
: ${calibre_enable:=NO}
: ${calibre_user:=calibre}
: ${calibre_library:=/nonexistent}
: ${calibre_logfile:=/var/log/calibre-server/calibre-server.log}
: ${calibre_logsize:=10}
pidfile=/var/run/${name}/${name}.pid
command=%%PREFIX%%/bin/calibre-server
command_interpreter=%%LOCALBASE%%/bin/%%PYTHON_VERSION%%
required_dirs=${calibre_library}
start_precmd=calibre_prestart
calibre_home=${calibre_home:-$(getent passwd ${calibre_user} | awk -F: '{print $6}')}
calibre_env="${calibre_env} HOME=${calibre_home:-/nonexistent}"
if [ ! -z "${calibre_port}" ]; then
command_args="${command_args} --port=${calibre_port}"
fi
if [ ! -z "${calibre_url_prefix}" ]; then
command_args="${command_args} --url-prefix=${calibre_url_prefix}"
fi
command_args="${command_args} --log ${calibre_logfile} --pidfile ${pidfile} --max-log-size ${calibre_logsize} --daemonize ${calibre_library}"
calibre_prestart()
{
install -d -o ${calibre_user} -m 755 /var/run/${name}
install -d -o ${calibre_user} -m 755 `dirname ${calibre_logfile}`
}
run_rc_command "$1"
|