on master help sign in
Utility scripts adapted to run on CentOS 7 (#2112)
commit1986b5ecacfb3b4b73a160eaa2309e81b609d96b authorEliesemoule <github@bougeard.org> dateSat 1 Aug 2020, 20:12 (6 years ago) parent0e51971
5 files changed+69−25
utils/filtron.sh+1−1 utils/lib.sh+35−19 utils/lxc.sh+7 utils/morty.sh+1−1 utils/searx.sh+25−4
utils/filtron.sh+1−1
@@ -546,7 +546,7 @@ EOF
546546 eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " "
547547 echo -e "\n.. END install systemd unit"
548548
549− # for DIST_NAME in ubuntu-20.04 arch fedora; do
549+ # for DIST_NAME in ubuntu-20.04 arch fedora centos; do
550550 # (
551551 # DIST_ID=${DIST_NAME%-*}
552552 # DIST_VERS=${DIST_NAME#*-}
utils/lib.sh+35−19
@@ -3,7 +3,7 @@
33# SPDX-License-Identifier: AGPL-3.0-or-later
44# shellcheck disable=SC2059,SC1117
55
6−# ubuntu, debian, arch, fedora ...
6+# ubuntu, debian, arch, fedora, centos ...
77DIST_ID=$(source /etc/os-release; echo "$ID");
88# shellcheck disable=SC2034
99DIST_VERS=$(source /etc/os-release; echo "$VERSION_ID");
@@ -639,7 +639,7 @@ nginx_distro_setup() {
639639 NGINX_DEFAULT_SERVER=/etc/nginx/nginx.conf
640640
641641 # Including *location* directives from a dedicated config-folder into the
642− # server directive is, what what fedora (already) does.
642+ # server directive is, what what fedora and centos (already) does.
643643 NGINX_APPS_ENABLED="/etc/nginx/default.d"
644644
645645 # We add a apps-available folder and linking configurations into the
@@ -654,7 +654,7 @@ nginx_distro_setup() {
654654 arch-*)
655655 NGINX_PACKAGES="nginx-mainline"
656656 ;;
657− fedora-*)
657+ fedora-*|centos-7)
658658 NGINX_PACKAGES="nginx"
659659 ;;
660660 *)
@@ -668,7 +668,7 @@ install_nginx(){
668668 info_msg "installing nginx ..."
669669 pkg_install "${NGINX_PACKAGES}"
670670 case $DIST_ID-$DIST_VERS in
671− arch-*|fedora-*)
671+ arch-*|fedora-*|centos-7)
672672 systemctl enable nginx
673673 systemctl start nginx
674674 ;;
@@ -718,7 +718,7 @@ nginx_install_app() {
718718nginx_include_apps_enabled() {
719719
720720 # Add the *NGINX_APPS_ENABLED* infrastruture to a nginx server block. Such
721− # infrastruture is already known from fedora, including apps (location
721+ # infrastruture is already known from fedora and centos, including apps (location
722722 # directives) from the /etc/nginx/default.d folder into the *default* nginx
723723 # server.
724724
@@ -819,7 +819,7 @@ apache_distro_setup() {
819819 APACHE_MODULES="modules"
820820 APACHE_PACKAGES="apache"
821821 ;;
822− fedora-*)
822+ fedora-*|centos-7)
823823 APACHE_SITES_AVAILABLE="/etc/httpd/sites-available"
824824 APACHE_SITES_ENABLED="/etc/httpd/sites-enabled"
825825 APACHE_MODULES="modules"
@@ -837,7 +837,7 @@ install_apache(){
837837 info_msg "installing apache ..."
838838 pkg_install "$APACHE_PACKAGES"
839839 case $DIST_ID-$DIST_VERS in
840− arch-*|fedora-*)
840+ arch-*|fedora-*|centos-7)
841841 if ! grep "IncludeOptional sites-enabled" "/etc/httpd/conf/httpd.conf"; then
842842 echo "IncludeOptional sites-enabled/*.conf" >> "/etc/httpd/conf/httpd.conf"
843843 fi
@@ -851,7 +851,7 @@ apache_is_installed() {
851851 case $DIST_ID-$DIST_VERS in
852852 ubuntu-*|debian-*) (command -v apachectl) &>/dev/null;;
853853 arch-*) (command -v httpd) &>/dev/null;;
854− fedora-*) (command -v httpd) &>/dev/null;;
854+ fedora-*|centos-7) (command -v httpd) &>/dev/null;;
855855 esac
856856}
857857
@@ -864,7 +864,7 @@ apache_reload() {
864864 sudo -H apachectl configtest
865865 sudo -H systemctl force-reload apache2
866866 ;;
867− arch-*| fedora-*)
867+ arch-*|fedora-*|centos-7)
868868 sudo -H httpd -t
869869 sudo -H systemctl force-reload httpd
870870 ;;
@@ -920,7 +920,7 @@ apache_enable_site() {
920920 rm -f "${APACHE_SITES_ENABLED}/${CONF}"
921921 ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
922922 ;;
923− fedora-*)
923+ fedora-*|centos-7)
924924 mkdir -p "${APACHE_SITES_ENABLED}"
925925 rm -f "${APACHE_SITES_ENABLED}/${CONF}"
926926 ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
@@ -944,7 +944,7 @@ apache_dissable_site() {
944944 arch-*)
945945 rm -f "${APACHE_SITES_ENABLED}/${CONF}"
946946 ;;
947− fedora-*)
947+ fedora-*|centos-7)
948948 rm -f "${APACHE_SITES_ENABLED}/${CONF}"
949949 ;;
950950 esac
@@ -980,7 +980,7 @@ uWSGI_distro_setup() {
980980 uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
981981 uWSGI_PACKAGES="uwsgi"
982982 ;;
983− fedora-*)
983+ fedora-*|centos-7)
984984 # systemd --> /usr/lib/systemd/system/uwsgi.service
985985 # The unit file starts uWSGI in emperor mode (/etc/uwsgi.ini), see
986986 # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
@@ -1002,7 +1002,7 @@ install_uwsgi(){
10021002 info_msg "installing uwsgi ..."
10031003 pkg_install "$uWSGI_PACKAGES"
10041004 case $DIST_ID-$DIST_VERS in
1005− fedora-*)
1005+ fedora-*|centos-7)
10061006 # enable & start should be called once at uWSGI installation time
10071007 systemctl enable uwsgi
10081008 systemctl restart uwsgi
@@ -1032,7 +1032,7 @@ uWSGI_restart() {
10321032 info_msg "[uWSGI:systemd-template] ${CONF} not installed (no need to restart)"
10331033 fi
10341034 ;;
1035− fedora-*)
1035+ fedora-*|centos-7)
10361036 # in emperor mode, just touch the file to restart
10371037 if uWSGI_app_enabled "${CONF}"; then
10381038 touch "${uWSGI_APPS_ENABLED}/${CONF}"
@@ -1059,7 +1059,7 @@ uWSGI_prepare_app() {
10591059 local APP="${1%.*}"
10601060
10611061 case $DIST_ID-$DIST_VERS in
1062− fedora-*)
1062+ fedora-*|centos-7)
10631063 # in emperor mode, the uwsgi user is the owner of the sockets
10641064 info_msg "prepare (uwsgi:uwsgi) /run/uwsgi/app/${APP}"
10651065 mkdir -p "/run/uwsgi/app/${APP}"
@@ -1135,7 +1135,7 @@ uWSGI_app_enabled() {
11351135 systemctl -q is-enabled "uwsgi@${CONF%.*}"
11361136 exit_val=$?
11371137 ;;
1138− fedora-*)
1138+ fedora-*|centos-7)
11391139 [[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
11401140 exit_val=$?
11411141 ;;
@@ -1170,7 +1170,7 @@ uWSGI_enable_app() {
11701170 systemctl enable "uwsgi@${CONF%.*}"
11711171 info_msg "enabled uWSGI app: ${CONF} (restart required)"
11721172 ;;
1173− fedora-*)
1173+ fedora-*|centos-7)
11741174 mkdir -p "${uWSGI_APPS_ENABLED}"
11751175 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
11761176 ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
@@ -1202,7 +1202,7 @@ uWSGI_disable_app() {
12021202 systemctl disable "uwsgi@${CONF%.*}"
12031203 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
12041204 ;;
1205− fedora-*)
1205+ fedora-*|centos-7)
12061206 # in emperor mode, just remove the app.ini file
12071207 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
12081208 ;;
@@ -1247,6 +1247,10 @@ pkg_install() {
12471247 # shellcheck disable=SC2068
12481248 dnf install -y $@
12491249 ;;
1250+ centos)
1251+ # shellcheck disable=SC2068
1252+ yum install -y $@
1253+ ;;
12501254 esac
12511255}
12521256
@@ -1275,6 +1279,10 @@ pkg_remove() {
12751279 # shellcheck disable=SC2068
12761280 dnf remove -y $@
12771281 ;;
1282+ centos)
1283+ # shellcheck disable=SC2068
1284+ yum remove -y $@
1285+ ;;
12781286 esac
12791287}
12801288
@@ -1295,6 +1303,10 @@ pkg_is_installed() {
12951303 dnf list -q --installed "$1" &> /dev/null
12961304 return $?
12971305 ;;
1306+ centos)
1307+ yum list -q --installed "$1" &> /dev/null
1308+ return $?
1309+ ;;
12981310 esac
12991311}
13001312
@@ -1395,10 +1407,14 @@ LXC_BASE_PACKAGES_arch="bash git base-devel python python-virtualenv"
13951407# dnf packages
13961408LXC_BASE_PACKAGES_fedora="bash git @development-tools python virtualenv"
13971409
1410+# yum packages
1411+LXC_BASE_PACKAGES_centos="bash git @development-tools python python-virtualenv"
1412+
13981413case $DIST_ID in
13991414 ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;;
14001415 arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;;
1401− fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
1416+ fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
1417+ centos) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_centos}" ;;
14021418 *) err_msg "$DIST_ID-$DIST_VERS: pkg_install LXC_BASE_PACKAGES not yet implemented" ;;
14031419esac
14041420
utils/lxc.sh+7
@@ -54,6 +54,13 @@ dnf install -y git curl wget hostname
5454echo 'Set disable_coredump false' >> /etc/sudo.conf
5555"
5656
57+# shellcheck disable=SC2034
58+centos7_boilerplate="
59+yum update -y
60+yum install -y git curl wget hostname
61+echo 'Set disable_coredump false' >> /etc/sudo.conf
62+"
63+
5764REMOTE_IMAGES=()
5865CONTAINERS=()
5966LOCAL_IMAGES=()
utils/morty.sh+1−1
@@ -530,7 +530,7 @@ EOF
530530 eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " "
531531 echo -e "\n.. END install systemd unit"
532532
533− # for DIST_NAME in ubuntu-20.04 arch fedora; do
533+ # for DIST_NAME in ubuntu-20.04 arch fedora centos; do
534534 # (
535535 # DIST_ID=${DIST_NAME%-*}
536536 # DIST_VERS=${DIST_NAME#*-}
utils/searx.sh+25−4
@@ -76,6 +76,19 @@ texlive-xetex-bin texlive-collection-fontsrecommended
7676texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts
7777dejavu-sans-mono-fonts"
7878
79+# yum packages
80+SEARX_PACKAGES_centos="\
81+python36-virtualenv python36 python36-pip python36-lxml python-babel
82+uwsgi uwsgi-plugin-python3
83+git @development-tools libxml2
84+ShellCheck"
85+
86+BUILD_PACKAGES_centos="\
87+firefox graphviz graphviz-gd ImageMagick librsvg2-tools
88+texlive-xetex-bin texlive-collection-fontsrecommended
89+texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts
90+dejavu-sans-mono-fonts"
91+
7992case $DIST_ID-$DIST_VERS in
8093 ubuntu-16.04|ubuntu-18.04)
8194 SEARX_PACKAGES="${SEARX_PACKAGES_debian}"
@@ -99,6 +112,10 @@ case $DIST_ID-$DIST_VERS in
99112 SEARX_PACKAGES="${SEARX_PACKAGES_fedora}"
100113 BUILD_PACKAGES="${BUILD_PACKAGES_fedora}"
101114 ;;
115+ centos-7)
116+ SEARX_PACKAGES="${SEARX_PACKAGES_centos}"
117+ BUILD_PACKAGES="${BUILD_PACKAGES_centos}"
118+ ;;
102119esac
103120
104121# Apache Settings
@@ -714,7 +731,7 @@ EOF
714731 arch-*)
715732 systemctl --no-pager -l status "uwsgi@${SERVICE_NAME%.*}"
716733 ;;
717− fedora-*)
734+ fedora-*|centos-7)
718735 systemctl --no-pager -l status uwsgi
719736 ;;
720737 esac
@@ -729,7 +746,7 @@ EOF
729746 case $DIST_ID-$DIST_VERS in
730747 ubuntu-*|debian-*) tail -f /var/log/uwsgi/app/searx.log ;;
731748 arch-*) journalctl -f -u "uwsgi@${SERVICE_NAME%.*}" ;;
732− fedora-*) journalctl -f -u uwsgi ;;
749+ fedora-*|centos-7) journalctl -f -u uwsgi ;;
733750 esac
734751 done
735752
@@ -790,22 +807,26 @@ rst-doc() {
790807 local debian="${SEARX_PACKAGES_debian}"
791808 local arch="${SEARX_PACKAGES_arch}"
792809 local fedora="${SEARX_PACKAGES_fedora}"
810+ local centos="${SEARX_PACKAGES_centos}"
793811 local debian_build="${BUILD_PACKAGES_debian}"
794812 local arch_build="${BUILD_PACKAGES_arch}"
795813 local fedora_build="${BUILD_PACKAGES_fedora}"
814+ local centos_build="${SEARX_PACKAGES_centos}"
796815 debian="$(echo "${debian}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
797816 arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
798817 fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
818+ centos="$(echo "${centos}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
799819 debian_build="$(echo "${debian_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
800820 arch_build="$(echo "${arch_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
801821 fedora_build="$(echo "${fedora_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
822+ centos_build="$(echo "${centos_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
802823
803824 eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/searx.rst")\""
804825
805826 # I use ubuntu-20.04 here to demonstrate that versions are also suported,
806827 # normaly debian-* and ubuntu-* are most the same.
807828
808− for DIST_NAME in ubuntu-20.04 arch fedora; do
829+ for DIST_NAME in ubuntu-20.04 arch fedora centos; do
809830 (
810831 DIST_ID=${DIST_NAME%-*}
811832 DIST_VERS=${DIST_NAME#*-}
@@ -850,7 +871,7 @@ EOF
850871
851872EOF
852873 ;;
853− fedora-*) cat <<EOF
874+ fedora-*|centos-7) cat <<EOF
854875
855876.. code:: bash
856877