From 7f88b3bcdafb3daca89fdac4854809e1df391490 Mon Sep 17 00:00:00 2001 From: farhan Date: Mon, 28 Feb 2022 15:43:38 +0000 Subject: [PATCH 1/3] background checks --- scripts/startup.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/startup.sh b/scripts/startup.sh index baf0e75..9fe88a9 100755 --- a/scripts/startup.sh +++ b/scripts/startup.sh @@ -16,6 +16,28 @@ set_option() { fi echo "${1}=${2}" >>$CONFIG_FILE # add option } + +root_check() { + if [[ "$(id -u)" != "0" ]]; then + echo -ne "ERROR! This script must be run under the 'root' user!\n" + exit 0 + fi +} + +docker_check() { + if awk -F/ '$2 == "docker"' /proc/self/cgroup | read -r; then + echo -ne "ERROR! Docker container is not supported (at the moment)\n" + exit 0 + elif [[ -f /.dockerenv ]]; then + echo -ne "ERROR! Docker container is not supported (at the moment)\n" + exit 0 + fi +} + +background_checks() { + root_check + docker_check +} # Renders a text based list of options that can be selected by the # user using up, down and enter keys and returns the chosen option. # From 719273b4c35b1c7557c99354c1d2577b00537af0 Mon Sep 17 00:00:00 2001 From: farhan Date: Mon, 28 Feb 2022 15:44:35 +0000 Subject: [PATCH 2/3] background checks 2 --- scripts/startup.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/startup.sh b/scripts/startup.sh index 9fe88a9..50aa0a1 100755 --- a/scripts/startup.sh +++ b/scripts/startup.sh @@ -34,8 +34,25 @@ docker_check() { fi } +arch_check() { + if [[ ! -e /etc/arch-release ]]; then + echo -ne "ERROR! This script must be run in Arch Linux!\n" + exit 0 + fi +} + +pacman_check() { + if [[ -f /var/lib/pacman/db.lck ]]; then + echo "ERROR! Pacman is blocked." + echo -ne "If not running remove /var/lib/pacman/db.lck.\n" + exit 0 + fi +} + background_checks() { root_check + arch_check + pacman_check docker_check } # Renders a text based list of options that can be selected by the From a6e565ad172354097485c103f0442e9fb98038d5 Mon Sep 17 00:00:00 2001 From: farhan Date: Mon, 28 Feb 2022 15:46:36 +0000 Subject: [PATCH 3/3] background checks 3 --- scripts/startup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/startup.sh b/scripts/startup.sh index 50aa0a1..258c6b9 100755 --- a/scripts/startup.sh +++ b/scripts/startup.sh @@ -340,6 +340,7 @@ installtype () { # language (){} # Starting functions +background_checks clear logo userinfo