From 339ccd1b476466c40b6b1b8dc2332aae5611de67 Mon Sep 17 00:00:00 2001 From: fbt Date: Wed, 10 Jan 2018 11:30:02 +0300 Subject: [PATCH] Turned out not to be very useful Signed-off-by: fbt --- ssm | 70 ++++++++------------------------------------------------ ssm.conf | 6 ----- 2 files changed, 10 insertions(+), 66 deletions(-) diff --git a/ssm b/ssm index 03a385f..dece4c0 100755 --- a/ssm +++ b/ssm @@ -280,31 +280,6 @@ result() { printf '%s\n' "${msgs[$rc]}" }; readonly -f result -read_systemd_service() { - declare section key value line - var key value line - - while read -r line; do - line =~ '^\[(.+)\]' && var section = "${BASH_REMATCH[1],,}" - line =~ '^([^=]+)=(.+)' && { - key = "${BASH_REMATCH[1],,}" - value = "${BASH_REMATCH[2]}" - } - - case $section in - (service) - case $key in - (pidfile) service_pidfile = "$value";; - (execstart) eval "service_command=( $value )";; - (execstop) eval "stop() { $value; }";; - (execreload) eval "reload() { $value; }";; - (restart) [[ $value == 'always' ]] && service_respawn = 1;; - esac - ;; - esac - done < "$1" -} - # Overloadable functions ## Start the service, write down the svc pid start() { @@ -507,8 +482,6 @@ var service_cgroup_exclusive = 0 # Refuse to start the service if its cgroup is var service_cgroup_wait = 0 # Wait on all the members of the cgroup to exit when stopping the service. # Global config -var systemd = 0 # Enable systemd-related functions. -var systemd_service_path = /etc/systemd/system /run/systemd/system /lib/systemd/system var cgroups = 0 # Enable cgroup-related functions var cgroups_check_pid = 1 # Enable checking if the main service PID is in the correct cgroup before doing anythin with the service var usrdir = '/usr/share/ssm' @@ -519,7 +492,6 @@ var service_oneshot = 0 var service_running = 0 var service_enabled = 0 var service_stopped = 0 -var service_systemd = 0 var service_nologs = 0 var service_cgroup_empty = 1 var service_cgroup_empty = 1 @@ -587,45 +559,23 @@ else break } done - - service_config || { - # Search for a systemd service too - systemd && { - for i in "${systemd_service_path[@]/%//$1.service}"; do - [[ -f "$i" ]] && { - service_name = "$1" - service_systemd = 1 - service_config = "$i" - - read_systemd_service "$i" - break - } - done - } - } fi # Die if there is no service config file service_config || die 19 "Service not found: $1" -# We can handle other people's service configs, poorly -if service_systemd; then - # I'm pretty sure we'll need this - : -else - # Service name is the basename - service_name = "${1##*/}" +# Service name is the basename +service_name = "${1##*/}" - # Get the service defaults - for p in "${cfg_path[@]/%//$service_name}"; do - [[ -f "$p" ]] && { - source "$p" || die 5 "Failed to read service defaults: $p" - } - done +# Get the service defaults +for p in "${cfg_path[@]/%//$service_name}"; do + [[ -f "$p" ]] && { + source "$p" || die 5 "Failed to read service defaults: $p" + } +done - # Get the service config - source -- "$service_config" "${@:3}" || die 7 "Failed to read the service config: $service_config" -fi +# Get the service config +source -- "$service_config" "${@:3}" || die 7 "Failed to read the service config: $service_config" # Legacy service_args && service_command += "${service_args[@]}" diff --git a/ssm.conf b/ssm.conf index 718ad93..b1fd560 100644 --- a/ssm.conf +++ b/ssm.conf @@ -25,12 +25,6 @@ # The signal to send to stop the service #service_stop_signal = 15 -# Enable systemd-related functions. -#systemd = 0 - -# Where to look fro system service files -#systemd_service_path = /etc/systemd/system /run/systemd/system /lib/systemd/system - # Enable cgroup-related functions #cgroups = 0