blob: 22af37cee0157e63a2facdc239d4722b3b66c539 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#!/usr/bin/env sh
set -euC
help_text=
help_text="$help_text install\t[]\t\n"
install () {
perl Makefile.PL
make
make test
make install
}
help_text="$help_text dist\t[]\tcreate a source distribution\n"
dist () {
perl Makefile.PL
make
make test
make dist
}
help_text="$help_text run_tests\t[args='t/' ...]\tpasses arg to the 'prove' tool\n"
run_tests () {
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"
start_dev () {
morbo script/jwebmail
}
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"
linelength () {
files=${1:-'README.md CHANGES.md LICENSE'}
for file in $files
do
fold -s -w 85 "$file" | diff "$file" -
done
}
help_text="$help_text follow\t[mode=development]\tfollows the current log file\n"
follow () {
mode=${1:-development}
tail -f "log/$mode.log"
}
help_text="$help_text check_manifest\t[]\tchecks if files in the MANIFEST actually exist\n"
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"
list_deps () {
module=${1:-JWebmail}
core="$(corelist -v v5.34.1 | awk '{ print $1 }')"
deps="$(perl -wE "use lib 'lib'; use Module::Load::Conditional 'requires'; @res = requires '$module'; \$\" = qq(\n); say \$res[0] ? qq(@res) : ''")"
for dep in $deps
do
if ! echo "$core" | grep -qxF "$dep"
then echo "$dep"
fi
done
}
help_text="$help_text list_translations\t[raw='']\tlists translatable snipptes on a best effort base (incomplete!!)\n"
list_translations () {
raw=${1-}
if [ "$raw" ]
then
find lib -name '*.pm' -exec grep '\->l(' '{}' '+'
find templates -name '*.html.ep' -exec grep "l[ (][\"']" '{}' '+'
else
p1="$(find lib -name '*.pm' -exec grep '\->l(' '{}' '+' | sed 's/^\(\S*\):.*->l(\([^)]*\)).*$/\1: \2/')"
p2="$(find templates -name '*.html.ep' -exec grep "l[ (][\"']" '{}' '+' | sed "s/^\\(\\S*\\):.*l[ (][\"']\\([^\"']*\\)[\"'].*$/\\1: '\\2'/")"
echo "$(echo "$p1"; echo "$p2")" | sort | uniq
fi
}
help_text="$help_text rust_extract\t[]\tupdates and gets the rust extract binary\n"
rust_extract () {
cd extract
cargo build --release --target=x86_64-unknown-linux-musl
cp target/x86_64-unknown-linux-musl/release/jwebmail-extract ../bin
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,50
echo
}
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
|