From 645b10f1a80a7242c3650f8a2f7fb4d7fc55967c Mon Sep 17 00:00:00 2001 From: optim-aizawa <66113133+optim-aizawa@users.noreply.github.com> Date: Tue, 11 Oct 2022 07:00:23 +0900 Subject: [PATCH] Add EnvVars to linux init.d (#339) * change module name * add init.d env * add init.d env --- service_openrc_linux.go | 4 ++++ service_sysv_linux.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/service_openrc_linux.go b/service_openrc_linux.go index 72eaba4b..c678e3ae 100644 --- a/service_openrc_linux.go +++ b/service_openrc_linux.go @@ -230,6 +230,10 @@ command_args="{{range .Arguments}}{{.}} {{end}}" name=$(basename $(readlink -f $command)) supervise_daemon_args="--stdout {{.LogDirectory}}/${name}.log --stderr {{.LogDirectory}}/${name}.err" +{{range $k, $v := .EnvVars -}} +export {{$k}}={{$v}} +{{end -}} + {{- if .Dependencies }} depend() { {{- range $i, $dep := .Dependencies}} diff --git a/service_sysv_linux.go b/service_sysv_linux.go index 48650409..5a98a514 100644 --- a/service_sysv_linux.go +++ b/service_sysv_linux.go @@ -207,6 +207,10 @@ pid_file="/var/run/$name.pid" stdout_log="{{.LogDirectory}}/$name.log" stderr_log="{{.LogDirectory}}/$name.err" +{{range $k, $v := .EnvVars -}} +export {{$k}}={{$v}} +{{end -}} + [ -e /etc/sysconfig/$name ] && . /etc/sysconfig/$name get_pid() {