-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
extension
executable file
·47 lines (43 loc) · 1.13 KB
/
extension
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
#!/usr/bin/env sh
set -e
EXTS_CACHE_DIR=/data/extensions/.cache
EXTS_LIST=/data/extensions/list
cd /opt/flarum/ || exit
action=${1}
shift
case "${action}" in
"require")
for package in "$@"; do
COMPOSER_CACHE_DIR=${EXTS_CACHE_DIR} yasu flarum:flarum composer require "${package}"
if [ $? -eq 0 ]; then
echo "${package}" >> "${EXTS_LIST}"
echo "${package} extension added"
sort -u -o "${EXTS_LIST}" "${EXTS_LIST}"
else
echo "ERROR: cannot add ${package} extension"
fi
done
;;
"remove")
for package in "$@"; do
COMPOSER_CACHE_DIR=${EXTS_CACHE_DIR} yasu flarum:flarum composer remove "${package}"
if [ $? -eq 0 ]; then
sed -i "\|${package}|d" "${EXTS_LIST}"
echo "${package} extension removed"
else
echo "ERROR: cannot remove ${package} extension"
fi
done
;;
"list")
cat "${EXTS_LIST}"
;;
*)
echo "Usage:"
echo "extension require <package> [<package>...]"
echo "extension remove <package> [<package>...]"
echo "extension list"
exit 1
;;
esac
yasu flarum:flarum php flarum cache:clear