From 6441b5ad6657873fcd8f3695515fa6ef3bc4e6f5 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Mon, 13 Mar 2023 21:27:49 +0100 Subject: Added systemd and python compile tasks to actions --- actions | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'actions') diff --git a/actions b/actions index a18c9ff..22af37c 100755 --- a/actions +++ b/actions @@ -20,9 +20,12 @@ dist () { make dist } -help_text="$help_text run_tests\t[arg]\tpasses arg to the 'prove' tool\n" +help_text="$help_text run_tests\t[args='t/' ...]\tpasses arg to the 'prove' tool\n" run_tests () { - eval "prove -l ${1-} t/" + if [ $# -gt 0 ] + then prove -l "$@" + else prove -l t/ + fi } help_text="$help_text start_dev\t[]\tstarts a hot reloading dev server\n" @@ -30,13 +33,13 @@ start_dev () { morbo script/jwebmail } -help_text="$help_text logrotate\t[mode]\tarchives the current log file\n" +help_text="$help_text logrotate\t[mode=development]\tarchives the current log file\n" logrotate () { mode=${1:-development} mv -i "log/$mode.log" "log/${mode}_$(date --iso-8601=minutes).log" } -help_text="$help_text linelength\t[files]\tchecks documentation files for overly long lines\n" +help_text="$help_text linelength\t[[files]]\tchecks documentation files for overly long lines\n" linelength () { files=${1:-'README.md CHANGES.md LICENSE'} for file in $files @@ -45,7 +48,7 @@ linelength () { done } -help_text="$help_text follow\t[mode]\tfollows the current log file\n" +help_text="$help_text follow\t[mode=development]\tfollows the current log file\n" follow () { mode=${1:-development} tail -f "log/$mode.log" @@ -56,7 +59,7 @@ check_manifest () { perl -nE 'chomp; say if $_ && !-e' MANIFEST } -help_text="$help_text list_deps\t[module]\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 (default=JWebmail)\n" list_deps () { module=${1:-JWebmail} core="$(corelist -v v5.34.1 | awk '{ print $1 }')" @@ -70,7 +73,7 @@ list_deps () { done } -help_text="$help_text list_translations\t[raw]\tlists translatable snipptes on a best effort base (incomplete!!)\n" +help_text="$help_text list_translations\t[raw='']\tlists translatable snipptes on a best effort base (incomplete!!)\n" list_translations () { raw=${1-} if [ "$raw" ] @@ -92,18 +95,29 @@ rust_extract () { cd .. } +help_text="$help_text systemd_unit\t[[name user working_dir]]\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 +} + +help_text="$help_text compile_python\t[]\tprepare python bytecode files\n" +compile_python () { + python3 -m compileall script/qmauth.py +} + help () { echo "The following actions are available:" echo - printf "$help_text" | expand -t 22,33 + printf "$help_text" | expand -t 22,50 echo } -if [ $# -gt 0 ] -then cmd=$1; shift -else cmd=help -fi -if [ "$(command -v "$cmd")" = "$cmd" ] -then eval "$cmd" "$@" -else echo "unkown commad '$cmd'"; exit 1 +cmd=${1-help} +[ $# -gt 0 ] && shift +if LANG=C type "$cmd" 2>/dev/null | grep -q 'function$' +then $cmd "$@" +else echo "unkown commad '$cmd'" >&2; exit 1 fi -- cgit v1.2.3