A simpler approach

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2020-03-28 19:39:54 +03:00
parent c5bbf92022
commit be3d90ea79

13
ssm
View File

@ -418,10 +418,6 @@ start() {
mktmpfiles || return 13
if [[ $service_netns ]]; then
service_command=( ip netns exec "$service_netns" "${service_command[@]}" )
fi
svc "${service_command[@]}" & job=$!
if service_oneshot; then
@ -619,6 +615,7 @@ var flag_reset_exit = 0
var flag_reread_service = 0
var flag_forget_service = 0
var flag_load_service = 0
var flag_no_netns = 0
## check for some environment stuff
var EDITOR := 'vim'
@ -732,6 +729,9 @@ while (( $# )); do
(-i|--info)
action = 'info';;
(--no-netns)
flag_no_netns = 1;;
(--) shift; break;;
(-*) printf 'Unknown key: %s\n' "$1" >&2; exit 1;;
(*) break;;
@ -828,6 +828,11 @@ flag_reset_exit && { reset-exit; die $?; }
# Get the service config
source -- "$service_config" "${@:3}" || die 7 "Failed to read the service config: $service_config"
# Rexec ourselves in the requested netns
flag_no_netns || {
[[ $service_netns ]] && exec ip netns exec "$service_netns" "$0" --no-netns "$service_name" "$@"
}
# “Load” the service into memory
if ! service_config == "$service_config_current" && service_remember; then
cat "$service_config" > "$rundir/current/$service_name"