Skip to content

Commit

Permalink
OpenRC: example init script
Browse files Browse the repository at this point in the history
  • Loading branch information
Forza-tng authored and supakeen committed Nov 18, 2024
1 parent cc8daad commit 6c9592c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
32 changes: 32 additions & 0 deletions etc/openrc/pinnwand.confd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
###
# pinnwand init.d configuration
###

# Path to the Pinnwand configuration file.
config_file="/home/pinnwand/pinnwand_config.toml"

# User and group under which the Pinnwand service will run.
pinnwand_user="pinnwand:pinnwand"

# Port on which the Pinnwand service will listen for HTTP requests..
port=9000

# Path to the Pinnwand executable.
command="/home/pinnwand/venv/bin/pinnwand"

# Directory where logs will be stored.
#log_dir="/var/log"

# Path to the standard output log file for the Pinnwand service..
#output_log="${log_dir}/pinnwand.log"

# Path to the error log file for the Pinnwand service.
#error_log="${log_dir}/pinnwand.err"

# Override arguments passed to the Pinnwand command at startup.
# -v: Enable verbose logging.
# --configuration-path: Specify the path to the configuration file.
# http: Start the HTTP server.
# --port: Specify the port on which the service will listen.

#command_args="-v --configuration-path \"${config_file}\" http --port ${port}"
24 changes: 24 additions & 0 deletions etc/openrc/pinnwand.initd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/sbin/openrc-run

description="Pinnwand pastebin service"

config_file="${config_file:-/home/pinnwand/pinnwand_config.toml}"
port="${port:-9000}"
log_dir="${log_dir:-/var/log}"
output_log="${output_log:-$log_dir/$RC_SVCNAME.log}"
error_log="${error_log:-$log_dir/$RC_SVCNAME.err}"
pidfile="${pidfile:-/run/$RC_SVCNAME.pid}"
command="${command:-/home/pinnwand/venv/bin/pinnwand}"
command_user="${pinnwand_user:-pinnwand:pinnwand}"
command_args="${command_args:- --configuration-path \"$config_file\" http --port $port}"
command_background=true

start_pre() {
if [ ! -f "$config_file" ]; then
eerror "Configuration file not found: $config_file"
return 1
fi

checkpath --file --owner "$command_user" --mode 0664 "$output_log"
checkpath --file --owner "$command_user" --mode 0664 "$error_log"
}

0 comments on commit 6c9592c

Please sign in to comment.