Full path; default workdir

* Determine our full path and use that instead of /bin/zsh
* Default workdir for all services is now '/'

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2017-12-14 07:07:48 +03:00
parent 32b26b5783
commit 905b3e0b37

17
ssm
View File

@ -136,8 +136,8 @@ depend() {
declare s declare s
for s in "$@"; do for s in "$@"; do
if ! "$0" "$s" qstatus; then if ! "$_self" "$s" qstatus; then
nullexec "$0" "$s" start || { nullexec "$_self" "$s" start || {
failed_deps+=( "$s" ) failed_deps+=( "$s" )
return 1 return 1
} }
@ -178,7 +178,7 @@ depend_ready() {
depend "$@" || return 1 depend "$@" || return 1
for s in "$@"; do for s in "$@"; do
"$0" "$s" wait_ready || { "$_self" "$s" wait_ready || {
failed_deps+=( "$s" ) failed_deps+=( "$s" )
return 1 return 1
} }
@ -314,8 +314,8 @@ start() { super_start; }
stop() { super_stop; } stop() { super_stop; }
reload() { super_reload; } reload() { super_reload; }
restart() { restart() {
"$0" "$service_name" stop "$_self" "$service_name" stop
"$0" "$service_name" start "$_self" "$service_name" start
} }
logs() { ${PAGER:-less} "$service_logfile"; } logs() { ${PAGER:-less} "$service_logfile"; }
@ -337,6 +337,12 @@ ready() { :; }
# Code # Code
main() { main() {
# Figure out our full path
case "$0" in
(/*) _self=$0;;
(*) _self="$PWD/$0";;
esac
# Needs to be global # Needs to be global
declare -g service_pid declare -g service_pid
@ -447,6 +453,7 @@ main() {
default service_ready_flag "$rundir/$service_name.ready" default service_ready_flag "$rundir/$service_name.ready"
default service_enabled_flag "$rundir/$service_name.enabled" default service_enabled_flag "$rundir/$service_name.enabled"
default service_stopped_flag "$rundir/$service_name.stopped" default service_stopped_flag "$rundir/$service_name.stopped"
default service_workdir '/'
default service_stop_timeout 30 default service_stop_timeout 30
default service_ready_timeout 15 default service_ready_timeout 15
default service_stop_signal 15 default service_stop_signal 15