install2
This commit is contained in:
+22
-16
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/bash -E
|
||||
# shellcheck disable=all
|
||||
|
||||
## CONSTANTS
|
||||
|
||||
@@ -9,36 +10,41 @@ MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
||||
function bootstrap {
|
||||
cd "$(mktemp -d)" || exit 3
|
||||
curl -s -O $MAIN_TAR_GZ_URL
|
||||
tar -xzf main.tar.gz --directory "$(dirname $MIAOU_BASH_DIR)"
|
||||
tar -xzf main.tar.gz --directory $(dirname "$MIAOU_BASH_DIR")
|
||||
. "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR/lib/initiate.bash"
|
||||
}
|
||||
|
||||
function assert_supported_distro {
|
||||
grep -E '^ID=debian|^ID_LIKE=debian' /etc/os-release ||
|
||||
grep -E '^ID=arch|^ID_LIKE=arch' /etc/os-release
|
||||
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)
|
||||
>&2 echo "unsupported GNU/Linux distribution: $distro"
|
||||
>&2 echo 'only debian-like OR arch-like currently supported'
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
function once_installed {
|
||||
[[ -d "$MIAOU_BASH_DIR" &&
|
||||
-L /etc/inputrc &&
|
||||
"$(readlink /etc/inputrc)" == "$MIAOU_BASH_DIR"/etc/inputrc ]]
|
||||
}
|
||||
|
||||
## MAIN
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
! assert_supported_distro && echo 'unsupported distro: debian-like OR arch-like expected' && exit 2
|
||||
assert_supported_distro
|
||||
deployment_type_adjective="${1:-installed}"
|
||||
[[ ! -v MIAOU_BASH_DIR ]] && MIAOU_BASH_DIR=/opt/miaou-bash && export MIAOU_BASH_DIR
|
||||
|
||||
if [[ "$UID" -ne 0 ]]; then
|
||||
sudo -vp 'root privilege required: '
|
||||
sudo -vp 'root privilege required (SUDO): '
|
||||
curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install2.sh | sudo bash
|
||||
echo DONE with root, now refresh bash login
|
||||
source /etc/profile
|
||||
source /etc/bash.bashrc
|
||||
exec bash -l
|
||||
elif once_installed; then
|
||||
. "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR/lib/self-upgrade.bash"
|
||||
else
|
||||
if [[ -d "$MIAOU_BASH_DIR" && -L /etc/inputrc && "$(readlink /etc/inputrc)" == "$MIAOU_BASH_DIR"/etc/inputrc ]]; then
|
||||
. "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR/lib/self-upgrade.bash"
|
||||
else
|
||||
bootstrap
|
||||
. "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR/lib/initiate.bash"
|
||||
echo "miaou-bash successfully $deployment_type_adjective"
|
||||
exec bash -l
|
||||
fi
|
||||
bootstrap
|
||||
echo "miaou-bash successfully $deployment_type_adjective"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user