More flexibility
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
34a43d4db6
commit
8fdd73af45
29
ssm
29
ssm
|
@ -349,21 +349,28 @@ main() {
|
|||
default XDG_CONFIG_HOME "$HOME/.config"
|
||||
default XDG_RUNTIME_DIR "/run/user/$UID"
|
||||
|
||||
cfgdir="$XDG_CONFIG_HOME/ssm"
|
||||
service_path=( "$XDG_CONFIG_HOME/ssm/services" )
|
||||
cfg_path=( "$XDG_CONFIG_HOME/ssm" )
|
||||
|
||||
rundir="$XDG_RUNTIME_DIR/ssm"
|
||||
logdir="$HOME/log/ssm"
|
||||
else
|
||||
cfgdir='/etc/ssm'
|
||||
rundir='/run/ssm'
|
||||
logdir='/var/log/ssm'
|
||||
fi
|
||||
|
||||
service_path+=( "$cfgdir/init.d" "$rundir/services" "$usrdir/services" )
|
||||
# Common service path
|
||||
service_path+=( '/etc/ssm/init.d' "$rundir/services" "$usrdir/services" )
|
||||
|
||||
# Common config path
|
||||
cfg_path+=( '/etc/ssm/conf.d' )
|
||||
|
||||
# Load custom functions
|
||||
for f in "$cfgdir/functions"/*; do
|
||||
for p in "${cfg_path[@]}"; do
|
||||
for f in "$p/functions"/*; do
|
||||
source "$f" || die 9 "Failed to source functions from $f"
|
||||
done
|
||||
done
|
||||
|
||||
# Now create the needed runtime stuff
|
||||
for d in "$rundir" "$logdir"; do
|
||||
|
@ -376,7 +383,10 @@ main() {
|
|||
service_config=$1
|
||||
else
|
||||
for i in "${service_path[@]}"; do
|
||||
[[ -f "$i/$1" ]] && service_config="$i/$1"
|
||||
[[ -f "$i/$1" ]] && {
|
||||
service_config="$i/$1"
|
||||
break
|
||||
}
|
||||
done
|
||||
fi
|
||||
|
||||
|
@ -390,12 +400,15 @@ main() {
|
|||
svc_pidfile="$rundir/$service_name.pid"
|
||||
|
||||
# Get the service defaults
|
||||
[[ -f "$cfgdir/conf.d/$service_name" ]] && {
|
||||
source "$cfgdir/conf.d/$service_name" || die 5 "Failed to read service defaults: $cfgdir/conf.d/$service_name"
|
||||
for p in "${cfg_path[@]}"; do
|
||||
[[ -f "$p/conf.d/$service_name" ]] && {
|
||||
source "$p/conf.d/$service_name" || die 5 "Failed to read service defaults: $p/conf.d/$service_name"
|
||||
break
|
||||
}
|
||||
done
|
||||
|
||||
# Get the service config
|
||||
source -- "$service_config" "${@:3}" || die 7 "Failed to read the service config: $cfgdir/init.d/$service_name"
|
||||
source -- "$service_config" "${@:3}" || die 7 "Failed to read the service config: $service_config"
|
||||
|
||||
# Legacy
|
||||
[[ "$service_args" ]] && service_command=( "${service_command[@]}" "${service_args[@]}" )
|
||||
|
|
Loading…
Reference in New Issue
Block a user