summaryrefslogtreecommitdiff
path: root/utils/lib.sh
diff options
context:
space:
mode:
authorEliesemoule <github@bougeard.org>2020-08-01 20:12:44 +0000
committerGitHub <noreply@github.com>2020-08-01 22:12:44 +0200
commit1986b5ecacfb3b4b73a160eaa2309e81b609d96b (patch)
tree0d3f535ac628eb5f0eaa1b85e94d2bf788cbd0a5 /utils/lib.sh
parent0e5197123dd4282b324414f46d9fb0f41faa7c60 (diff)
downloadsearxng-1986b5ecacfb3b4b73a160eaa2309e81b609d96b.tar.gz
searxng-1986b5ecacfb3b4b73a160eaa2309e81b609d96b.zip
Utility scripts adapted to run on CentOS 7 (#2112)
Diffstat (limited to 'utils/lib.sh')
-rwxr-xr-xutils/lib.sh54
1 files changed, 35 insertions, 19 deletions
diff --git a/utils/lib.sh b/utils/lib.sh
index 922227a89..800bbf01b 100755
--- a/utils/lib.sh
+++ b/utils/lib.sh
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# shellcheck disable=SC2059,SC1117
-# ubuntu, debian, arch, fedora ...
+# ubuntu, debian, arch, fedora, centos ...
DIST_ID=$(source /etc/os-release; echo "$ID");
# shellcheck disable=SC2034
DIST_VERS=$(source /etc/os-release; echo "$VERSION_ID");
@@ -639,7 +639,7 @@ nginx_distro_setup() {
NGINX_DEFAULT_SERVER=/etc/nginx/nginx.conf
# Including *location* directives from a dedicated config-folder into the
- # server directive is, what what fedora (already) does.
+ # server directive is, what what fedora and centos (already) does.
NGINX_APPS_ENABLED="/etc/nginx/default.d"
# We add a apps-available folder and linking configurations into the
@@ -654,7 +654,7 @@ nginx_distro_setup() {
arch-*)
NGINX_PACKAGES="nginx-mainline"
;;
- fedora-*)
+ fedora-*|centos-7)
NGINX_PACKAGES="nginx"
;;
*)
@@ -668,7 +668,7 @@ install_nginx(){
info_msg "installing nginx ..."
pkg_install "${NGINX_PACKAGES}"
case $DIST_ID-$DIST_VERS in
- arch-*|fedora-*)
+ arch-*|fedora-*|centos-7)
systemctl enable nginx
systemctl start nginx
;;
@@ -718,7 +718,7 @@ nginx_install_app() {
nginx_include_apps_enabled() {
# Add the *NGINX_APPS_ENABLED* infrastruture to a nginx server block. Such
- # infrastruture is already known from fedora, including apps (location
+ # infrastruture is already known from fedora and centos, including apps (location
# directives) from the /etc/nginx/default.d folder into the *default* nginx
# server.
@@ -819,7 +819,7 @@ apache_distro_setup() {
APACHE_MODULES="modules"
APACHE_PACKAGES="apache"
;;
- fedora-*)
+ fedora-*|centos-7)
APACHE_SITES_AVAILABLE="/etc/httpd/sites-available"
APACHE_SITES_ENABLED="/etc/httpd/sites-enabled"
APACHE_MODULES="modules"
@@ -837,7 +837,7 @@ install_apache(){
info_msg "installing apache ..."
pkg_install "$APACHE_PACKAGES"
case $DIST_ID-$DIST_VERS in
- arch-*|fedora-*)
+ arch-*|fedora-*|centos-7)
if ! grep "IncludeOptional sites-enabled" "/etc/httpd/conf/httpd.conf"; then
echo "IncludeOptional sites-enabled/*.conf" >> "/etc/httpd/conf/httpd.conf"
fi
@@ -851,7 +851,7 @@ apache_is_installed() {
case $DIST_ID-$DIST_VERS in
ubuntu-*|debian-*) (command -v apachectl) &>/dev/null;;
arch-*) (command -v httpd) &>/dev/null;;
- fedora-*) (command -v httpd) &>/dev/null;;
+ fedora-*|centos-7) (command -v httpd) &>/dev/null;;
esac
}
@@ -864,7 +864,7 @@ apache_reload() {
sudo -H apachectl configtest
sudo -H systemctl force-reload apache2
;;
- arch-*| fedora-*)
+ arch-*|fedora-*|centos-7)
sudo -H httpd -t
sudo -H systemctl force-reload httpd
;;
@@ -920,7 +920,7 @@ apache_enable_site() {
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
;;
- fedora-*)
+ fedora-*|centos-7)
mkdir -p "${APACHE_SITES_ENABLED}"
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
@@ -944,7 +944,7 @@ apache_dissable_site() {
arch-*)
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
;;
- fedora-*)
+ fedora-*|centos-7)
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
;;
esac
@@ -980,7 +980,7 @@ uWSGI_distro_setup() {
uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
uWSGI_PACKAGES="uwsgi"
;;
- fedora-*)
+ fedora-*|centos-7)
# systemd --> /usr/lib/systemd/system/uwsgi.service
# The unit file starts uWSGI in emperor mode (/etc/uwsgi.ini), see
# - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
@@ -1002,7 +1002,7 @@ install_uwsgi(){
info_msg "installing uwsgi ..."
pkg_install "$uWSGI_PACKAGES"
case $DIST_ID-$DIST_VERS in
- fedora-*)
+ fedora-*|centos-7)
# enable & start should be called once at uWSGI installation time
systemctl enable uwsgi
systemctl restart uwsgi
@@ -1032,7 +1032,7 @@ uWSGI_restart() {
info_msg "[uWSGI:systemd-template] ${CONF} not installed (no need to restart)"
fi
;;
- fedora-*)
+ fedora-*|centos-7)
# in emperor mode, just touch the file to restart
if uWSGI_app_enabled "${CONF}"; then
touch "${uWSGI_APPS_ENABLED}/${CONF}"
@@ -1059,7 +1059,7 @@ uWSGI_prepare_app() {
local APP="${1%.*}"
case $DIST_ID-$DIST_VERS in
- fedora-*)
+ fedora-*|centos-7)
# in emperor mode, the uwsgi user is the owner of the sockets
info_msg "prepare (uwsgi:uwsgi) /run/uwsgi/app/${APP}"
mkdir -p "/run/uwsgi/app/${APP}"
@@ -1135,7 +1135,7 @@ uWSGI_app_enabled() {
systemctl -q is-enabled "uwsgi@${CONF%.*}"
exit_val=$?
;;
- fedora-*)
+ fedora-*|centos-7)
[[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
exit_val=$?
;;
@@ -1170,7 +1170,7 @@ uWSGI_enable_app() {
systemctl enable "uwsgi@${CONF%.*}"
info_msg "enabled uWSGI app: ${CONF} (restart required)"
;;
- fedora-*)
+ fedora-*|centos-7)
mkdir -p "${uWSGI_APPS_ENABLED}"
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
@@ -1202,7 +1202,7 @@ uWSGI_disable_app() {
systemctl disable "uwsgi@${CONF%.*}"
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
;;
- fedora-*)
+ fedora-*|centos-7)
# in emperor mode, just remove the app.ini file
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
;;
@@ -1247,6 +1247,10 @@ pkg_install() {
# shellcheck disable=SC2068
dnf install -y $@
;;
+ centos)
+ # shellcheck disable=SC2068
+ yum install -y $@
+ ;;
esac
}
@@ -1275,6 +1279,10 @@ pkg_remove() {
# shellcheck disable=SC2068
dnf remove -y $@
;;
+ centos)
+ # shellcheck disable=SC2068
+ yum remove -y $@
+ ;;
esac
}
@@ -1295,6 +1303,10 @@ pkg_is_installed() {
dnf list -q --installed "$1" &> /dev/null
return $?
;;
+ centos)
+ yum list -q --installed "$1" &> /dev/null
+ return $?
+ ;;
esac
}
@@ -1395,10 +1407,14 @@ LXC_BASE_PACKAGES_arch="bash git base-devel python python-virtualenv"
# dnf packages
LXC_BASE_PACKAGES_fedora="bash git @development-tools python virtualenv"
+# yum packages
+LXC_BASE_PACKAGES_centos="bash git @development-tools python python-virtualenv"
+
case $DIST_ID in
ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;;
arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;;
- fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
+ fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
+ centos) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_centos}" ;;
*) err_msg "$DIST_ID-$DIST_VERS: pkg_install LXC_BASE_PACKAGES not yet implemented" ;;
esac