Turned out not to be very useful

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2018-01-10 11:30:02 +03:00
parent 730374f6d7
commit 339ccd1b47
2 changed files with 10 additions and 66 deletions

64
ssm
View File

@ -280,31 +280,6 @@ result() {
printf '%s\n' "${msgs[$rc]}" printf '%s\n' "${msgs[$rc]}"
}; readonly -f result }; 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 # Overloadable functions
## Start the service, write down the svc pid ## Start the service, write down the svc pid
start() { 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. var service_cgroup_wait = 0 # Wait on all the members of the cgroup to exit when stopping the service.
# Global config # 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 = 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 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' var usrdir = '/usr/share/ssm'
@ -519,7 +492,6 @@ var service_oneshot = 0
var service_running = 0 var service_running = 0
var service_enabled = 0 var service_enabled = 0
var service_stopped = 0 var service_stopped = 0
var service_systemd = 0
var service_nologs = 0 var service_nologs = 0
var service_cgroup_empty = 1 var service_cgroup_empty = 1
var service_cgroup_empty = 1 var service_cgroup_empty = 1
@ -587,45 +559,23 @@ else
break break
} }
done 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 fi
# Die if there is no service config file # Die if there is no service config file
service_config || die 19 "Service not found: $1" service_config || die 19 "Service not found: $1"
# We can handle other people's service configs, poorly # Service name is the basename
if service_systemd; then service_name = "${1##*/}"
# I'm pretty sure we'll need this
:
else
# Service name is the basename
service_name = "${1##*/}"
# Get the service defaults # Get the service defaults
for p in "${cfg_path[@]/%//$service_name}"; do for p in "${cfg_path[@]/%//$service_name}"; do
[[ -f "$p" ]] && { [[ -f "$p" ]] && {
source "$p" || die 5 "Failed to read service defaults: $p" source "$p" || die 5 "Failed to read service defaults: $p"
} }
done done
# Get the service config # Get the service config
source -- "$service_config" "${@:3}" || die 7 "Failed to read the service config: $service_config" source -- "$service_config" "${@:3}" || die 7 "Failed to read the service config: $service_config"
fi
# Legacy # Legacy
service_args && service_command += "${service_args[@]}" service_args && service_command += "${service_args[@]}"

View File

@ -25,12 +25,6 @@
# The signal to send to stop the service # The signal to send to stop the service
#service_stop_signal = 15 #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 # Enable cgroup-related functions
#cgroups = 0 #cgroups = 0