new installation process
This commit is contained in:
@@ -38,7 +38,7 @@ Any feedback appreciated: [contact@artcode.re](mailto:contact@artcode.re)
|
|||||||
|
|
||||||
## install
|
## install
|
||||||
<!-- markdownlint-disable MD013 MD025 -->
|
<!-- markdownlint-disable MD013 MD025 -->
|
||||||
`curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install.sh | sudo bash && exec bash -l`
|
`source <(curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install.sh)`
|
||||||
|
|
||||||
## upgrade
|
## upgrade
|
||||||
|
|
||||||
|
|||||||
+50
-25
@@ -1,40 +1,65 @@
|
|||||||
#!/usr/bin/bash -E
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
## CONSTANTS
|
## CONSTANTS
|
||||||
|
|
||||||
|
#TODO: LATEST_TAG
|
||||||
|
# LATEST_TAG=$(curl -s https://git.artcode.re/api/v1/repos/miaou/miaou-bash/tags|grep -oPm1 '{"name":".*?",' | head -n1 | cut -d'"' -f4)
|
||||||
|
# https://git.artcode.re/miaou/miaou-bash/archive/0.3.109.tar.gz
|
||||||
|
|
||||||
MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
||||||
|
|
||||||
## FUNCTIONS
|
## FUNCTIONS
|
||||||
|
|
||||||
function bootstrap {
|
function upgrade {
|
||||||
cd "$(mktemp -d)" || exit 3
|
echo UPGRADE
|
||||||
curl -s -O $MAIN_TAR_GZ_URL
|
execute_miaou_lib self-upgrade
|
||||||
tar -xzf main.tar.gz --directory "$(dirname $MIAOU_BASH_DIR)"
|
}
|
||||||
|
|
||||||
|
function install {
|
||||||
|
echo INSTALL
|
||||||
|
MIAOU_BASH_DIR=/opt/miaou-bash
|
||||||
|
export MIAOU_BASH_DIR
|
||||||
|
|
||||||
|
local tempfile
|
||||||
|
tempfile="/tmp/$(basename "$MAIN_TAR_GZ_URL")"
|
||||||
|
curl -so "$tempfile" $MAIN_TAR_GZ_URL
|
||||||
|
sudo tar -xzf "$tempfile" --directory "$(dirname "$MIAOU_BASH_DIR")"
|
||||||
|
rm "$tempfile"
|
||||||
|
execute_miaou_lib initiate
|
||||||
|
echo "miaou-bash successfully $deployment_type_adjective"
|
||||||
}
|
}
|
||||||
|
|
||||||
function assert_supported_distro {
|
function assert_supported_distro {
|
||||||
grep -E '^ID=debian|^ID_LIKE=debian' /etc/os-release ||
|
if ! grep -E '^ID=debian|^ID_LIKE=debian' /etc/os-release &&
|
||||||
grep -E '^ID=arch|^ID_LIKE=arch' /etc/os-release
|
! grep -E '^ID=arch|^ID_LIKE=arch' /etc/os-release; then
|
||||||
|
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
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function once_installed {
|
||||||
|
[[ -v MIAOU_BASH_DIR && -d "$MIAOU_BASH_DIR" &&
|
||||||
|
-L /etc/inputrc &&
|
||||||
|
"$(readlink /etc/inputrc)" == "$MIAOU_BASH_DIR"/etc/inputrc ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function execute_miaou_lib {
|
||||||
|
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: '
|
||||||
|
true
|
||||||
|
}
|
||||||
## MAIN
|
## MAIN
|
||||||
|
|
||||||
|
# source <(curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install2.sh)
|
||||||
|
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
assert_supported_distro
|
||||||
|
sudo_root
|
||||||
deployment_type_adjective="${1:-installed}"
|
deployment_type_adjective="${1:-installed}"
|
||||||
|
if once_installed; then upgrade; else install; fi
|
||||||
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
exec bash -l
|
||||||
! assert_supported_distro && echo 'unsupported distro: debian-like OR arch-like expected' && exit 2
|
|
||||||
|
|
||||||
if [[ ! -v MIAOU_BASH_DIR ]]; then
|
|
||||||
MIAOU_BASH_DIR=/opt/miaou-bash
|
|
||||||
export MIAOU_BASH_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
|
|||||||
-66
@@ -1,66 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
## CONSTANTS
|
|
||||||
|
|
||||||
#TODO: LATEST_TAG
|
|
||||||
# LATEST_TAG=$(curl -s https://git.artcode.re/api/v1/repos/miaou/miaou-bash/tags|grep -oPm1 '{"name":".*?",' | head -n1 | cut -d'"' -f4)
|
|
||||||
# https://git.artcode.re/miaou/miaou-bash/archive/0.3.109.tar.gz
|
|
||||||
|
|
||||||
MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
|
||||||
|
|
||||||
## FUNCTIONS
|
|
||||||
|
|
||||||
function upgrade {
|
|
||||||
echo UPGRADE
|
|
||||||
execute_miaou_lib self-upgrade
|
|
||||||
}
|
|
||||||
|
|
||||||
function install {
|
|
||||||
echo INSTALL
|
|
||||||
MIAOU_BASH_DIR=/opt/miaou-bash
|
|
||||||
export MIAOU_BASH_DIR
|
|
||||||
|
|
||||||
local tempfile
|
|
||||||
tempfile="/tmp/$(basename "$MAIN_TAR_GZ_URL")"
|
|
||||||
curl -so "$tempfile" $MAIN_TAR_GZ_URL
|
|
||||||
sudo tar -xzf "$tempfile" --directory "$(dirname "$MIAOU_BASH_DIR")"
|
|
||||||
rm "$tempfile"
|
|
||||||
execute_miaou_lib initiate
|
|
||||||
|
|
||||||
# source /etc/profile
|
|
||||||
echo "miaou-bash successfully installed"
|
|
||||||
exec bash -l
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
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 {
|
|
||||||
[[ -v MIAOU_BASH_DIR && -d "$MIAOU_BASH_DIR" &&
|
|
||||||
-L /etc/inputrc &&
|
|
||||||
"$(readlink /etc/inputrc)" == "$MIAOU_BASH_DIR"/etc/inputrc ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
function execute_miaou_lib {
|
|
||||||
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: '
|
|
||||||
true
|
|
||||||
}
|
|
||||||
## MAIN
|
|
||||||
|
|
||||||
# source <(curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install2.sh)
|
|
||||||
|
|
||||||
set -Eeuo pipefail
|
|
||||||
assert_supported_distro
|
|
||||||
sudo_root
|
|
||||||
if once_installed; then upgrade; else install; fi
|
|
||||||
Reference in New Issue
Block a user