simplified install
This commit is contained in:
+17
-14
@@ -2,36 +2,39 @@
|
||||
|
||||
## CONSTANTS
|
||||
|
||||
readonly DESTINATION=/opt
|
||||
readonly MIAOU_BASH_DIR=/opt/miaou-bash
|
||||
readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
||||
|
||||
## FUNCTIONS
|
||||
|
||||
function bootstrap {
|
||||
if [[ ! -d "$DESTINATION/miaou-bash" ]]; then
|
||||
local temp_dir
|
||||
temp_dir=$(mktemp -d)
|
||||
pushd "$temp_dir" >/dev/null || return 2
|
||||
curl -s -O $MAIN_TAR_GZ_URL
|
||||
tar -xzf main.tar.gz --directory "$DESTINATION"
|
||||
echo "directory: miaou-bash successfully deployed to $DESTINATION"
|
||||
popd >/dev/null || return 3
|
||||
fi
|
||||
cd "$(mktemp -d)" || exit 3
|
||||
curl -s -O $MAIN_TAR_GZ_URL
|
||||
tar -xzf main.tar.gz --directory "$MIAOU_BASH_DIR/.."
|
||||
|
||||
local source_bin="$DESTINATION/miaou-bash/bin/miaou-bash"
|
||||
local source_bin="$MIAOU_BASH_DIR/bin/miaou-bash"
|
||||
local dest_bin="/usr/bin/miaou-bash"
|
||||
if ! cmp -s "$source_bin" "$dest_bin"; then
|
||||
cp -f "$source_bin" "$dest_bin"
|
||||
echo "executable: /usr/bin/miaou-bash freshly created"
|
||||
fi
|
||||
echo "miaou-bash deployed to: $MIAOU_BASH_DIR"
|
||||
|
||||
export MIAOU_BASH_DIR="$DESTINATION/miaou-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
|
||||
}
|
||||
|
||||
## MAIN
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
||||
if [[ -v MIAOU_BASH_DIR && -d "$MIAOU_BASH_DIR" ]]; then
|
||||
! assert_supported_distro && echo 'unsupported distro: debian-like OR arch-like expected' && exit 2
|
||||
|
||||
export MIAOU_BASH_DIR
|
||||
if [[ -d "$MIAOU_BASH_DIR" ]]; then
|
||||
miaou-bash "$MIAOU_BASH_DIR/lib/self-upgrade.bash"
|
||||
else
|
||||
bootstrap
|
||||
|
||||
Reference in New Issue
Block a user