From 9435f9254e438435359724925a89d8259cdd0c3f Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Thu, 16 Mar 2023 17:57:02 +0100 Subject: reworked systemd_unit task in action --- actions | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'actions') diff --git a/actions b/actions index 22af37c..487cf22 100755 --- a/actions +++ b/actions @@ -59,7 +59,7 @@ check_manifest () { perl -nE 'chomp; say if $_ && !-e' MANIFEST } -help_text="$help_text list_deps\t[module=JWebmail]\tlists all non core dependencies of a module (default=JWebmail)\n" +help_text="$help_text list_deps\t[module=JWebmail]\tlists all non core dependencies of a module\n" list_deps () { module=${1:-JWebmail} core="$(corelist -v v5.34.1 | awk '{ print $1 }')" @@ -95,12 +95,17 @@ rust_extract () { cd .. } -help_text="$help_text systemd_unit\t[[name user working_dir]]\tcreates a systemd unit file\n" +help_text="$help_text systemd_unit\t[path=/etc/systemd/system/\$JWM_NAME.service] env(JWM_{NAME,USER,HOME,LOG_LEVEL})\tcreates a systemd unit file\n" systemd_unit () { - export JWM_NAME=${1-jwebmail} - export JWM_USER=${2-$USER} - export JWM_HOME=${3-$(pwd)} - perl -pe 's/\$(\w+)/$ENV{$1}/ga' jwebmail.service.tmpl + : "${JWM_NAME=jwebmail}" "${JWM_USER=$USER}" "${JWM_HOME=$(pwd)}" "${JWM_LOG_LEVEL=info}" + export JWM_NAME JWM_USER JWM_HOME JWM_LOG_LEVEL + + cmd='perl -pe s/\$(\w+)/$ENV{$1}/ga jwebmail.service.tmpl' + path=${1-/etc/systemd/system/$JWM_NAME.service} + if [ "$path" = '-' ] + then $cmd + else $cmd >|"$path" + fi } help_text="$help_text compile_python\t[]\tprepare python bytecode files\n" @@ -111,7 +116,7 @@ compile_python () { help () { echo "The following actions are available:" echo - printf "$help_text" | expand -t 22,50 + printf "$help_text" | expand -t 22,43 echo } -- cgit v1.2.3