some cleanup

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2018-01-08 04:47:42 +03:00
parent 758e841e1e
commit 4dee8a29b6
1 changed files with 34 additions and 35 deletions

69
ssm
View File

@ -379,7 +379,7 @@ info() {
printf "%12s: %s\n" "${_info_items[@]}"
}
# Restart just calls the script twice by default
## Restart just calls the script twice by default
restart() {
"$_self" "$service_name" stop
"$_self" "$service_name" start
@ -390,9 +390,9 @@ logs() { $PAGER "$service_logfile"; }
## Status is a bit of a special case. It's talkative.
status() {
(( service_running )) && return 0
(( service_enabled )) && return 0
(( service_stopped )) && return 7
service_running && return 0
service_enabled && return 0
service_stopped && return 7
return 1
}
@ -404,38 +404,35 @@ qstatus() { nullexec status; }
ready() { :; }
# Main code
# Figure out our full path
case "$0" in
(/*) var _self = "$0";;
(*) var _self = "$PWD/$0";;
esac
## Empty declarations
var service_pid \
service_pidfile \
service_type \
service_depends_ready \
service_command \
service_config \
service_path \
service_name \
service_args \
service_logfile \
service_ready_flag \
service_enabled_flag \
service_stopped_flag \
failed_deps \
svc_pidfile \
cfg_path \
cfg_dir \
rundir \
logdir \
_self
# check for some environment stuff
## check for some environment stuff
var EDITOR := 'vim'
var PAGER := 'less'
var XDG_CONFIG_HOME := "$HOME/.config"
var XDG_RUNTIME_DIR := "/run/user/$UID"
# Empty declarations
var service_pid
var service_pidfile
var service_type
var service_depends_ready
var service_command
var service_config
var service_path
var service_name
var service_args
var service_logfile
var service_ready_flag
var service_enabled_flag
var service_stopped_flag
var failed_deps
var svc_pidfile
var cfg_path
var cfg_dir
var rundir
var logdir
# Let's set some defaults
## Let's set some defaults
var service_managed = 0
var service_respawn = 0
var service_oneshot = 0
@ -454,9 +451,11 @@ var systemd_service_path = /etc/systemd/system /run/systemd/system /lib/systemd/
var ssm_config = 0
var usrdir = '/usr/share/ssm'
# XDG stuff
var XDG_CONFIG_HOME := "$HOME/.config"
var XDG_RUNTIME_DIR := "/run/user/$UID"
## Figure out our full path
case "$0" in
(/*) _self = "$0";;
(*) _self = "$PWD/$0";;
esac
if (( $UID )); then
rundir = "$XDG_RUNTIME_DIR/ssm"