FreeBSD.rc.d - geomyidae - A small C-based gopherd.
HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
FreeBSD.rc.d (3444B)
---
1 #!/bin/sh
2
3 # PROVIDE: geomyidae
4 # REQUIRE: NETWORKING SERVERS DAEMON
5 # BEFORE: LOGIN
6 # KEYWORD: shutdown
7 #
8 # Add the following lines to /etc/rc.conf to enable this service
9 #
10 # geomyidae_enable (bool): Set to NO by default.
11 # Set to YES to enable geomyidae
12 # geomyidae_flags (string): Additional command line options to
13 # pass to geomyidae(8).
14 # geomyidae_user (string): Set to the user to run geomyidae as
15 # Default is "geomyidae"
16 # geomyidae_group (string): Set to the group to run geomyidae as
17 # Default is "geomyidae"
18 # geomyidae_htdocs (string): Directory to server files from
19 # Default is "/var/gopher"
20 # geomyidae_logfile (string): File to use as a logfile
21 # Default is "/var/log/gopherlog"
22 # geomyidae_bindhost (string): IP Address to bind to
23 # Default is all addresses
24 # geomyidae_port (int): Port to listen on
25 # Default is 70
26 # geomyidae_sport (int): Port to display within base directory
27 # Default is 70
28 # geomyidae_keyfile (string): Path to private key in case TLS support is desired
29 # Default is empty
30 # geomyidae_certfile (string): Path to public key in case TLS support is desired
31 # Default is empty
32 #
33 # NOTE: You need to install geomyidae setuid root:wheel for this
34 # to work when listening on priviledged ports.
35 #
36 # Create users and group accordingly, e.g.:
37 #
38 # # pw groupadd geomyidae -g 542
39 # # pw useradd geomyidae -g geomyidae -u 542 -s /usr/sbin/nologin -d /nonexistent
40 #
41 # Create logfile, pidfile and htdocs:
42 #
43 # # mkdir /var/gopher
44 # # touch /var/run/geomyidae.pid
45 # # touch /var/log/gopherlog
46 # # chown geomyidae:geomyidae /var/gopher /var/run/geomyidae.pid /var/log/gopherlog
47
48 . /etc/rc.subr
49
50 name=geomyidae
51 rcvar=geomyidae_enable
52
53 load_rc_config $name
54
55 : ${geomyidae_enable:="NO"}
56 : ${geomyidae_user:="geomyidae"}
57 : ${geomyidae_group:="geomyidae"}
58 : ${geomyidae_flags:=""}
59 : ${geomyidae_htdocs:="/var/gopher"}
60 : ${geomyidae_logfile:="/var/log/gopherlog"}
61 : ${geomyidae_bindhost:=""}
62 : ${geomyidae_host:="localhost"}
63 : ${geomyidae_port:="70"}
64 : ${geomyidae_sport:="70"}
65 : ${geomyidae_command:="/usr/local/bin/geomyidae"}
66 : ${geomyidae_certfile:=""}
67 : ${geomyidae_keyfile:=""}
68
69 pidfile=/var/run/geomyidae.pid
70 procname="${geomyidae_command}"
71 command="/usr/sbin/daemon"
72 command_args="-S -T geomyidae -m 3 -f -p ${pidfile} ${geomyidae_command} -d -l ${geomyidae_logfile} \
73 -b ${geomyidae_htdocs} -p ${geomyidae_port} -o ${geomyidae_sport} \
74 -u ${geomyidae_user} -g ${geomyidae_group} -h ${geomyidae_host}"
75
76 # Append bindhost if set
77 [ ! -z "${geomyidae_bindhost}" ] && command_args="${command_args} -i ${geomyidae_bindhost}"
78
79 # TLS setup
80 [ ! -z "${geomyidae_keyfile}" -a ! -z "${geomyidae_certfile}" ] && \
81 command_args="${command_args} -t ${geomyidae_keyfile} ${geomyidae_certfile}"
82
83 # Lastly append flags by user
84 command_args="${command_args} ${geomyidae_flags}"
85
86 required_files="${pidfile} ${geomyidae_logfile}"
87 required_dirs="${geomyidae_htdocs}"
88
89 run_rc_command "$1"