From 7cb8306c231c95bd1158d09cb6aadeb93690bc25 Mon Sep 17 00:00:00 2001 From: pvincent Date: Tue, 18 Aug 2026 12:11:19 +0400 Subject: [PATCH] install2 --- install2.sh | 14 +++++++++----- lib/functions.bash | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/install2.sh b/install2.sh index 1cb9f13..51a4b99 100755 --- a/install2.sh +++ b/install2.sh @@ -18,7 +18,7 @@ function install { cd /tmp curl -sO $MAIN_TAR_GZ_URL - sudo tar -xzf main.tar.gz --directory $(dirname "$MIAOU_BASH_DIR") + sudo tar -xzf main.tar.gz --directory "$(dirname "$MIAOU_BASH_DIR")" execute_miaou_lib initiate source /etc/profile @@ -28,7 +28,8 @@ function install { function assert_supported_distro { if ! grep -E '^ID=debian|^ID_LIKE=debian' /etc/os-release && ! grep -E '^ID=arch|^ID_LIKE=arch' /etc/os-release; then - local distro=$(grep -oP '^ID=\K(.*)' /etc/os-release) + local distro + distro=$(grep -oP '^ID=\K(.*)' /etc/os-release) >&2 echo "unsupported GNU/Linux distribution: $distro" >&2 echo 'only debian-like OR arch-like currently supported' exit 2 @@ -42,14 +43,17 @@ function once_installed { } function execute_miaou_lib { - sudo -E "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR/lib/"$1".bash" + sudo -E "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR"/lib/"$1".bash } +function sudo_root { + [[ "$UID" -ne 0 ]] && sudo -vp 'SUDO privilege required: ' +} ## MAIN # source <(curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install2.sh) set -Eeuo pipefail assert_supported_distro -[[ "$UID" -ne 0 ]] && sudo -vp 'SUDO privilege required: ' -once_installed && upgrade || install +sudo_root +if once_installed; then upgrade; else install; fi diff --git a/lib/functions.bash b/lib/functions.bash index 6041003..b380054 100644 --- a/lib/functions.bash +++ b/lib/functions.bash @@ -12,7 +12,7 @@ function assert_root { } function assert_container { - cat /proc/self/cgroup | awk -F / '{print $NF}' | grep -qE '^(session-c|\.lxc)' + cat /proc/self/cgroup | grep -E '/session-c[0-9]+.scope' } function assert_system_mode {