summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2023-03-16 17:57:02 +0100
committerJannis M. Hoffmann <jannis@fehcom.de>2023-03-16 17:57:02 +0100
commit9435f9254e438435359724925a89d8259cdd0c3f (patch)
tree731325007b7680c7b97d1342a7f547bccaf73dd2
parentf542a632433cb935e969a2d3c3d2f012fa9e4541 (diff)
reworked systemd_unit task in action
-rwxr-xr-xactions19
1 files changed, 12 insertions, 7 deletions
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
}