Utility scripts adapted to run on CentOS 7 (#2112)

This commit is contained in:
Eliesemoule 2020-08-01 20:12:44 +00:00 committed by GitHub
parent 0e5197123d
commit 1986b5ecac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 25 deletions

View File

@ -546,7 +546,7 @@ EOF
eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " " eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " "
echo -e "\n.. END install systemd unit" echo -e "\n.. END install systemd unit"
# for DIST_NAME in ubuntu-20.04 arch fedora; do # for DIST_NAME in ubuntu-20.04 arch fedora centos; do
# ( # (
# DIST_ID=${DIST_NAME%-*} # DIST_ID=${DIST_NAME%-*}
# DIST_VERS=${DIST_NAME#*-} # DIST_VERS=${DIST_NAME#*-}

View File

@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# shellcheck disable=SC2059,SC1117 # shellcheck disable=SC2059,SC1117
# ubuntu, debian, arch, fedora ... # ubuntu, debian, arch, fedora, centos ...
DIST_ID=$(source /etc/os-release; echo "$ID"); DIST_ID=$(source /etc/os-release; echo "$ID");
# shellcheck disable=SC2034 # shellcheck disable=SC2034
DIST_VERS=$(source /etc/os-release; echo "$VERSION_ID"); DIST_VERS=$(source /etc/os-release; echo "$VERSION_ID");
@ -639,7 +639,7 @@ nginx_distro_setup() {
NGINX_DEFAULT_SERVER=/etc/nginx/nginx.conf NGINX_DEFAULT_SERVER=/etc/nginx/nginx.conf
# Including *location* directives from a dedicated config-folder into the # 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" NGINX_APPS_ENABLED="/etc/nginx/default.d"
# We add a apps-available folder and linking configurations into the # We add a apps-available folder and linking configurations into the
@ -654,7 +654,7 @@ nginx_distro_setup() {
arch-*) arch-*)
NGINX_PACKAGES="nginx-mainline" NGINX_PACKAGES="nginx-mainline"
;; ;;
fedora-*) fedora-*|centos-7)
NGINX_PACKAGES="nginx" NGINX_PACKAGES="nginx"
;; ;;
*) *)
@ -668,7 +668,7 @@ install_nginx(){
info_msg "installing nginx ..." info_msg "installing nginx ..."
pkg_install "${NGINX_PACKAGES}" pkg_install "${NGINX_PACKAGES}"
case $DIST_ID-$DIST_VERS in case $DIST_ID-$DIST_VERS in
arch-*|fedora-*) arch-*|fedora-*|centos-7)
systemctl enable nginx systemctl enable nginx
systemctl start nginx systemctl start nginx
;; ;;
@ -718,7 +718,7 @@ nginx_install_app() {
nginx_include_apps_enabled() { nginx_include_apps_enabled() {
# Add the *NGINX_APPS_ENABLED* infrastruture to a nginx server block. Such # 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 # directives) from the /etc/nginx/default.d folder into the *default* nginx
# server. # server.
@ -819,7 +819,7 @@ apache_distro_setup() {
APACHE_MODULES="modules" APACHE_MODULES="modules"
APACHE_PACKAGES="apache" APACHE_PACKAGES="apache"
;; ;;
fedora-*) fedora-*|centos-7)
APACHE_SITES_AVAILABLE="/etc/httpd/sites-available" APACHE_SITES_AVAILABLE="/etc/httpd/sites-available"
APACHE_SITES_ENABLED="/etc/httpd/sites-enabled" APACHE_SITES_ENABLED="/etc/httpd/sites-enabled"
APACHE_MODULES="modules" APACHE_MODULES="modules"
@ -837,7 +837,7 @@ install_apache(){
info_msg "installing apache ..." info_msg "installing apache ..."
pkg_install "$APACHE_PACKAGES" pkg_install "$APACHE_PACKAGES"
case $DIST_ID-$DIST_VERS in case $DIST_ID-$DIST_VERS in
arch-*|fedora-*) arch-*|fedora-*|centos-7)
if ! grep "IncludeOptional sites-enabled" "/etc/httpd/conf/httpd.conf"; then if ! grep "IncludeOptional sites-enabled" "/etc/httpd/conf/httpd.conf"; then
echo "IncludeOptional sites-enabled/*.conf" >> "/etc/httpd/conf/httpd.conf" echo "IncludeOptional sites-enabled/*.conf" >> "/etc/httpd/conf/httpd.conf"
fi fi
@ -851,7 +851,7 @@ apache_is_installed() {
case $DIST_ID-$DIST_VERS in case $DIST_ID-$DIST_VERS in
ubuntu-*|debian-*) (command -v apachectl) &>/dev/null;; ubuntu-*|debian-*) (command -v apachectl) &>/dev/null;;
arch-*) (command -v httpd) &>/dev/null;; arch-*) (command -v httpd) &>/dev/null;;
fedora-*) (command -v httpd) &>/dev/null;; fedora-*|centos-7) (command -v httpd) &>/dev/null;;
esac esac
} }
@ -864,7 +864,7 @@ apache_reload() {
sudo -H apachectl configtest sudo -H apachectl configtest
sudo -H systemctl force-reload apache2 sudo -H systemctl force-reload apache2
;; ;;
arch-*| fedora-*) arch-*|fedora-*|centos-7)
sudo -H httpd -t sudo -H httpd -t
sudo -H systemctl force-reload httpd sudo -H systemctl force-reload httpd
;; ;;
@ -920,7 +920,7 @@ apache_enable_site() {
rm -f "${APACHE_SITES_ENABLED}/${CONF}" rm -f "${APACHE_SITES_ENABLED}/${CONF}"
ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}" ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
;; ;;
fedora-*) fedora-*|centos-7)
mkdir -p "${APACHE_SITES_ENABLED}" mkdir -p "${APACHE_SITES_ENABLED}"
rm -f "${APACHE_SITES_ENABLED}/${CONF}" rm -f "${APACHE_SITES_ENABLED}/${CONF}"
ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}" ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
@ -944,7 +944,7 @@ apache_dissable_site() {
arch-*) arch-*)
rm -f "${APACHE_SITES_ENABLED}/${CONF}" rm -f "${APACHE_SITES_ENABLED}/${CONF}"
;; ;;
fedora-*) fedora-*|centos-7)
rm -f "${APACHE_SITES_ENABLED}/${CONF}" rm -f "${APACHE_SITES_ENABLED}/${CONF}"
;; ;;
esac esac
@ -980,7 +980,7 @@ uWSGI_distro_setup() {
uWSGI_APPS_ENABLED="${uWSGI_SETUP}" uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
uWSGI_PACKAGES="uwsgi" uWSGI_PACKAGES="uwsgi"
;; ;;
fedora-*) fedora-*|centos-7)
# systemd --> /usr/lib/systemd/system/uwsgi.service # systemd --> /usr/lib/systemd/system/uwsgi.service
# The unit file starts uWSGI in emperor mode (/etc/uwsgi.ini), see # The unit file starts uWSGI in emperor mode (/etc/uwsgi.ini), see
# - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
@ -1002,7 +1002,7 @@ install_uwsgi(){
info_msg "installing uwsgi ..." info_msg "installing uwsgi ..."
pkg_install "$uWSGI_PACKAGES" pkg_install "$uWSGI_PACKAGES"
case $DIST_ID-$DIST_VERS in case $DIST_ID-$DIST_VERS in
fedora-*) fedora-*|centos-7)
# enable & start should be called once at uWSGI installation time # enable & start should be called once at uWSGI installation time
systemctl enable uwsgi systemctl enable uwsgi
systemctl restart uwsgi systemctl restart uwsgi
@ -1032,7 +1032,7 @@ uWSGI_restart() {
info_msg "[uWSGI:systemd-template] ${CONF} not installed (no need to restart)" info_msg "[uWSGI:systemd-template] ${CONF} not installed (no need to restart)"
fi fi
;; ;;
fedora-*) fedora-*|centos-7)
# in emperor mode, just touch the file to restart # in emperor mode, just touch the file to restart
if uWSGI_app_enabled "${CONF}"; then if uWSGI_app_enabled "${CONF}"; then
touch "${uWSGI_APPS_ENABLED}/${CONF}" touch "${uWSGI_APPS_ENABLED}/${CONF}"
@ -1059,7 +1059,7 @@ uWSGI_prepare_app() {
local APP="${1%.*}" local APP="${1%.*}"
case $DIST_ID-$DIST_VERS in case $DIST_ID-$DIST_VERS in
fedora-*) fedora-*|centos-7)
# in emperor mode, the uwsgi user is the owner of the sockets # in emperor mode, the uwsgi user is the owner of the sockets
info_msg "prepare (uwsgi:uwsgi) /run/uwsgi/app/${APP}" info_msg "prepare (uwsgi:uwsgi) /run/uwsgi/app/${APP}"
mkdir -p "/run/uwsgi/app/${APP}" mkdir -p "/run/uwsgi/app/${APP}"
@ -1135,7 +1135,7 @@ uWSGI_app_enabled() {
systemctl -q is-enabled "uwsgi@${CONF%.*}" systemctl -q is-enabled "uwsgi@${CONF%.*}"
exit_val=$? exit_val=$?
;; ;;
fedora-*) fedora-*|centos-7)
[[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]] [[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
exit_val=$? exit_val=$?
;; ;;
@ -1170,7 +1170,7 @@ uWSGI_enable_app() {
systemctl enable "uwsgi@${CONF%.*}" systemctl enable "uwsgi@${CONF%.*}"
info_msg "enabled uWSGI app: ${CONF} (restart required)" info_msg "enabled uWSGI app: ${CONF} (restart required)"
;; ;;
fedora-*) fedora-*|centos-7)
mkdir -p "${uWSGI_APPS_ENABLED}" mkdir -p "${uWSGI_APPS_ENABLED}"
rm -f "${uWSGI_APPS_ENABLED}/${CONF}" rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${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%.*}" systemctl disable "uwsgi@${CONF%.*}"
rm -f "${uWSGI_APPS_ENABLED}/${CONF}" rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
;; ;;
fedora-*) fedora-*|centos-7)
# in emperor mode, just remove the app.ini file # in emperor mode, just remove the app.ini file
rm -f "${uWSGI_APPS_ENABLED}/${CONF}" rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
;; ;;
@ -1247,6 +1247,10 @@ pkg_install() {
# shellcheck disable=SC2068 # shellcheck disable=SC2068
dnf install -y $@ dnf install -y $@
;; ;;
centos)
# shellcheck disable=SC2068
yum install -y $@
;;
esac esac
} }
@ -1275,6 +1279,10 @@ pkg_remove() {
# shellcheck disable=SC2068 # shellcheck disable=SC2068
dnf remove -y $@ dnf remove -y $@
;; ;;
centos)
# shellcheck disable=SC2068
yum remove -y $@
;;
esac esac
} }
@ -1295,6 +1303,10 @@ pkg_is_installed() {
dnf list -q --installed "$1" &> /dev/null dnf list -q --installed "$1" &> /dev/null
return $? return $?
;; ;;
centos)
yum list -q --installed "$1" &> /dev/null
return $?
;;
esac esac
} }
@ -1395,10 +1407,14 @@ LXC_BASE_PACKAGES_arch="bash git base-devel python python-virtualenv"
# dnf packages # dnf packages
LXC_BASE_PACKAGES_fedora="bash git @development-tools python virtualenv" 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 case $DIST_ID in
ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;; ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;;
arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;; 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" ;; *) err_msg "$DIST_ID-$DIST_VERS: pkg_install LXC_BASE_PACKAGES not yet implemented" ;;
esac esac

View File

@ -54,6 +54,13 @@ dnf install -y git curl wget hostname
echo 'Set disable_coredump false' >> /etc/sudo.conf echo 'Set disable_coredump false' >> /etc/sudo.conf
" "
# shellcheck disable=SC2034
centos7_boilerplate="
yum update -y
yum install -y git curl wget hostname
echo 'Set disable_coredump false' >> /etc/sudo.conf
"
REMOTE_IMAGES=() REMOTE_IMAGES=()
CONTAINERS=() CONTAINERS=()
LOCAL_IMAGES=() LOCAL_IMAGES=()

View File

@ -530,7 +530,7 @@ EOF
eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " " eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " "
echo -e "\n.. END install systemd unit" echo -e "\n.. END install systemd unit"
# for DIST_NAME in ubuntu-20.04 arch fedora; do # for DIST_NAME in ubuntu-20.04 arch fedora centos; do
# ( # (
# DIST_ID=${DIST_NAME%-*} # DIST_ID=${DIST_NAME%-*}
# DIST_VERS=${DIST_NAME#*-} # DIST_VERS=${DIST_NAME#*-}

View File

@ -76,6 +76,19 @@ texlive-xetex-bin texlive-collection-fontsrecommended
texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts
dejavu-sans-mono-fonts" dejavu-sans-mono-fonts"
# yum packages
SEARX_PACKAGES_centos="\
python36-virtualenv python36 python36-pip python36-lxml python-babel
uwsgi uwsgi-plugin-python3
git @development-tools libxml2
ShellCheck"
BUILD_PACKAGES_centos="\
firefox graphviz graphviz-gd ImageMagick librsvg2-tools
texlive-xetex-bin texlive-collection-fontsrecommended
texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts
dejavu-sans-mono-fonts"
case $DIST_ID-$DIST_VERS in case $DIST_ID-$DIST_VERS in
ubuntu-16.04|ubuntu-18.04) ubuntu-16.04|ubuntu-18.04)
SEARX_PACKAGES="${SEARX_PACKAGES_debian}" SEARX_PACKAGES="${SEARX_PACKAGES_debian}"
@ -99,6 +112,10 @@ case $DIST_ID-$DIST_VERS in
SEARX_PACKAGES="${SEARX_PACKAGES_fedora}" SEARX_PACKAGES="${SEARX_PACKAGES_fedora}"
BUILD_PACKAGES="${BUILD_PACKAGES_fedora}" BUILD_PACKAGES="${BUILD_PACKAGES_fedora}"
;; ;;
centos-7)
SEARX_PACKAGES="${SEARX_PACKAGES_centos}"
BUILD_PACKAGES="${BUILD_PACKAGES_centos}"
;;
esac esac
# Apache Settings # Apache Settings
@ -714,7 +731,7 @@ EOF
arch-*) arch-*)
systemctl --no-pager -l status "uwsgi@${SERVICE_NAME%.*}" systemctl --no-pager -l status "uwsgi@${SERVICE_NAME%.*}"
;; ;;
fedora-*) fedora-*|centos-7)
systemctl --no-pager -l status uwsgi systemctl --no-pager -l status uwsgi
;; ;;
esac esac
@ -729,7 +746,7 @@ EOF
case $DIST_ID-$DIST_VERS in case $DIST_ID-$DIST_VERS in
ubuntu-*|debian-*) tail -f /var/log/uwsgi/app/searx.log ;; ubuntu-*|debian-*) tail -f /var/log/uwsgi/app/searx.log ;;
arch-*) journalctl -f -u "uwsgi@${SERVICE_NAME%.*}" ;; arch-*) journalctl -f -u "uwsgi@${SERVICE_NAME%.*}" ;;
fedora-*) journalctl -f -u uwsgi ;; fedora-*|centos-7) journalctl -f -u uwsgi ;;
esac esac
done done
@ -790,22 +807,26 @@ rst-doc() {
local debian="${SEARX_PACKAGES_debian}" local debian="${SEARX_PACKAGES_debian}"
local arch="${SEARX_PACKAGES_arch}" local arch="${SEARX_PACKAGES_arch}"
local fedora="${SEARX_PACKAGES_fedora}" local fedora="${SEARX_PACKAGES_fedora}"
local centos="${SEARX_PACKAGES_centos}"
local debian_build="${BUILD_PACKAGES_debian}" local debian_build="${BUILD_PACKAGES_debian}"
local arch_build="${BUILD_PACKAGES_arch}" local arch_build="${BUILD_PACKAGES_arch}"
local fedora_build="${BUILD_PACKAGES_fedora}" local fedora_build="${BUILD_PACKAGES_fedora}"
local centos_build="${SEARX_PACKAGES_centos}"
debian="$(echo "${debian}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" debian="$(echo "${debian}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
centos="$(echo "${centos}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
debian_build="$(echo "${debian_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" debian_build="$(echo "${debian_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
arch_build="$(echo "${arch_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" arch_build="$(echo "${arch_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
fedora_build="$(echo "${fedora_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" fedora_build="$(echo "${fedora_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
centos_build="$(echo "${centos_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/searx.rst")\"" eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/searx.rst")\""
# I use ubuntu-20.04 here to demonstrate that versions are also suported, # I use ubuntu-20.04 here to demonstrate that versions are also suported,
# normaly debian-* and ubuntu-* are most the same. # normaly debian-* and ubuntu-* are most the same.
for DIST_NAME in ubuntu-20.04 arch fedora; do for DIST_NAME in ubuntu-20.04 arch fedora centos; do
( (
DIST_ID=${DIST_NAME%-*} DIST_ID=${DIST_NAME%-*}
DIST_VERS=${DIST_NAME#*-} DIST_VERS=${DIST_NAME#*-}
@ -850,7 +871,7 @@ EOF
EOF EOF
;; ;;
fedora-*) cat <<EOF fedora-*|centos-7) cat <<EOF
.. code:: bash .. code:: bash