Skip to content

Commit 6c9592c

Browse files
Forza-tngsupakeen
authored andcommitted
OpenRC: example init script
1 parent cc8daad commit 6c9592c

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

Diff for: etc/openrc/pinnwand.confd

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
###
2+
# pinnwand init.d configuration
3+
###
4+
5+
# Path to the Pinnwand configuration file.
6+
config_file="/home/pinnwand/pinnwand_config.toml"
7+
8+
# User and group under which the Pinnwand service will run.
9+
pinnwand_user="pinnwand:pinnwand"
10+
11+
# Port on which the Pinnwand service will listen for HTTP requests..
12+
port=9000
13+
14+
# Path to the Pinnwand executable.
15+
command="/home/pinnwand/venv/bin/pinnwand"
16+
17+
# Directory where logs will be stored.
18+
#log_dir="/var/log"
19+
20+
# Path to the standard output log file for the Pinnwand service..
21+
#output_log="${log_dir}/pinnwand.log"
22+
23+
# Path to the error log file for the Pinnwand service.
24+
#error_log="${log_dir}/pinnwand.err"
25+
26+
# Override arguments passed to the Pinnwand command at startup.
27+
# -v: Enable verbose logging.
28+
# --configuration-path: Specify the path to the configuration file.
29+
# http: Start the HTTP server.
30+
# --port: Specify the port on which the service will listen.
31+
32+
#command_args="-v --configuration-path \"${config_file}\" http --port ${port}"

Diff for: etc/openrc/pinnwand.initd

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/sbin/openrc-run
2+
3+
description="Pinnwand pastebin service"
4+
5+
config_file="${config_file:-/home/pinnwand/pinnwand_config.toml}"
6+
port="${port:-9000}"
7+
log_dir="${log_dir:-/var/log}"
8+
output_log="${output_log:-$log_dir/$RC_SVCNAME.log}"
9+
error_log="${error_log:-$log_dir/$RC_SVCNAME.err}"
10+
pidfile="${pidfile:-/run/$RC_SVCNAME.pid}"
11+
command="${command:-/home/pinnwand/venv/bin/pinnwand}"
12+
command_user="${pinnwand_user:-pinnwand:pinnwand}"
13+
command_args="${command_args:- --configuration-path \"$config_file\" http --port $port}"
14+
command_background=true
15+
16+
start_pre() {
17+
if [ ! -f "$config_file" ]; then
18+
eerror "Configuration file not found: $config_file"
19+
return 1
20+
fi
21+
22+
checkpath --file --owner "$command_user" --mode 0664 "$output_log"
23+
checkpath --file --owner "$command_user" --mode 0664 "$error_log"
24+
}

0 commit comments

Comments
 (0)