summaryrefslogtreecommitdiff
path: root/utils/lib.sh
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2020-02-23 12:10:45 +0100
committerMarkus Heiser <markus.heiser@darmarit.de>2020-02-23 12:10:45 +0100
commit5fb6d4f508d9744a8d82160ca184729514bc18c8 (patch)
tree8b96368ef9b097bfe2b908dd2b56026f1b637c25 /utils/lib.sh
parente36e0f80aeec5d513b0bf8d4e4dc94c9fa4d98b4 (diff)
downloadsearxng-5fb6d4f508d9744a8d82160ca184729514bc18c8.tar.gz
searxng-5fb6d4f508d9744a8d82160ca184729514bc18c8.zip
LXC: normalize package installation & user creation.
utils/lib.sh: - get DIST_ID & DIST_VERSION from /etc/os-release - pkg_[install|remove|...] supports ubuntu, debian, archlinux & fedora utils/lxc.sh - Workaround for the "setrlimit(RLIMIT_CORE): Operation not permitted" error:: 'Set disable_coredump false' >> /etc/sudo.conf utils/[searx.sh|filtron.sh|morty.sh] - switched user creation from 'adduser' perl script to 'useradd' built-in command utils/searx.sh - install packages for ubuntu, debian, archlinux & fedora Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'utils/lib.sh')
-rwxr-xr-xutils/lib.sh57
1 files changed, 48 insertions, 9 deletions
diff --git a/utils/lib.sh b/utils/lib.sh
index a045c91a8..c3707d580 100755
--- a/utils/lib.sh
+++ b/utils/lib.sh
@@ -3,6 +3,11 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# shellcheck disable=SC2059,SC1117
+# ubuntu, debian, arch, fedora ...
+DIST_ID=$(source /etc/os-release; echo $ID);
+# shellcheck disable=SC2034
+DIST_VERS=$(source /etc/os-release; echo $VERSION_ID);
+
ADMIN_NAME="${ADMIN_NAME:-$(git config user.name)}"
ADMIN_NAME="${ADMIN_NAME:-$USER}"
@@ -54,7 +59,7 @@ sudo_or_exit() {
required_commands() {
- # usage: requires_commands [cmd1 ...]
+ # usage: required_commands [cmd1 ...]
local exit_val=0
while [ -n "$1" ]; do
@@ -787,9 +792,6 @@ uWSGI_disable_app() {
# distro's package manager
# ------------------------
-#
-# FIXME: Arch Linux & RHEL should be added
-#
pkg_install() {
@@ -801,8 +803,20 @@ pkg_install() {
if ! ask_yn "Should packages be installed?" Yn 30; then
return 42
fi
- # shellcheck disable=SC2068
- apt-get install -m -y $@
+ case $DIST_ID in
+ ubuntu|debian)
+ # shellcheck disable=SC2068
+ apt-get install -m -y $@
+ ;;
+ arch)
+ # shellcheck disable=SC2068
+ pacman -S --noconfirm $@
+ ;;
+ fedora)
+ # shellcheck disable=SC2068
+ dnf install -y $@
+ ;;
+ esac
}
pkg_remove() {
@@ -815,15 +829,40 @@ pkg_remove() {
if ! ask_yn "Should packages be removed (purge)?" Yn 30; then
return 42
fi
- apt-get purge --autoremove --ignore-missing -y "$@"
+ case $DIST_ID in
+ ubuntu|debian)
+ # shellcheck disable=SC2068
+ apt-get purge --autoremove --ignore-missing -y $@
+ ;;
+ arch)
+ # shellcheck disable=SC2068
+ pacman -R --noconfirm $@
+ ;;
+ fedora)
+ # shellcheck disable=SC2068
+ dnf remove -y $@
+ ;;
+ esac
}
pkg_is_installed() {
# usage: pkg_is_install foopkg || pkg_install foopkg
- dpkg -l "$1" &> /dev/null
- return $?
+ case $DIST_ID in
+ ubuntu|debian)
+ dpkg -l "$1" &> /dev/null
+ return $?
+ ;;
+ arch)
+ pacman -Qsq "$1" &> /dev/null
+ return $?
+ ;;
+ fedora)
+ dnf list -q --installed "$1" &> /dev/null
+ return $?
+ ;;
+ esac
}
# git tooling