This repository was archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlit.sh
109 lines (80 loc) · 2.2 KB
/
lit.sh
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
#!/bin/sh
# lit.sh v1.0.0
# https://google.github.io/styleguide/shellguide.html#s7-naming-conventions
CONTAINER_INIT_DIRECTORY="/opt/litea/init.d"
LITEA_INSTALLED_PACKAGES="/opt/litea/installed_packages.txt"
preset_laravel () {
echo "Installing required system libraries and php extensions" \
&& install-php-extensions bcmath calendar opcache pdo_mysql zip redis gd
}
# ================= #
# === HELPERS === #
# ================= #
error () {
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${RED}ERROR${NC}: ${1}"
}
warning () {
ORANGE='\033[0;33m'
NC='\033[0m' # No Color
echo -e "${ORANGE}WARNING${NC}: ${1}"
}
success () {
GREEN='\033[1;32m'
NC='\033[0m' # No Color
echo -e "${GREEN}SUCCESS${NC}: ${1}"
}
install_package () {
pkg="${1}"
touch "${LITEA_INSTALLED_PACKAGES}"
if grep -Fxq "${pkg}" "${LITEA_INSTALLED_PACKAGES}"; then
warning "the package ${pkg} has already been installed"
exit 0
fi
echo "Installing ${pkg}"
pkg_conf_path="/opt/litea/conf/${pkg}"
if [ ! -d "${pkg_conf_path}" ]; then
error "Configuration folder for the package ${pkg} was not found"
exit 1
fi
pkg_install_script="${pkg_conf_path}/install.sh"
if [ ! -f "${pkg_install_script}" ]; then
error "Installation script for the package ${pkg} was not found"
exit 1
fi
sh "${pkg_install_script}" "${CONTAINER_INIT_DIRECTORY}"
if [ "${?}" != 0 ]; then
error "${pkg} installation failed"
exit 1
fi
success "${pkg} installed successfully"
echo "${pkg}" >> "${LITEA_INSTALLED_PACKAGES}"
}
# ================== #
# === COMMANDS === #
# ================== #
case "${1}" in
"install")
shift 1
for pkg in "${@}"
do
install_package "${pkg}"
if [ "${?}" != 0 ]; then
exit 1
fi
done
;;
"preset")
shift 1
case "${1}" in
"laravel")
echo "Installing Laravel production preset"
preset_laravel
if [ "${?}" != 0 ]; then
exit 1
fi
;;
esac
;;
esac