You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
#!/usr/bin/env bash
|
|
|
|
## CONSTANTS
|
|
|
|
readonly DESTINATION=/opt
|
|
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" || return 2
|
|
curl -q -O $MAIN_TAR_GZ_URL
|
|
tar -xzf main.tar.gz --directory "$DESTINATION"
|
|
echo "directory: miaou-bash successfully deployed to $DESTINATION"
|
|
popd || return 3
|
|
else
|
|
echo "directory: miaou-bash already deployed!"
|
|
fi
|
|
|
|
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"
|
|
else
|
|
echo "executable: /usr/bin/miaou-bash up-to-date!"
|
|
fi
|
|
|
|
export MIAOU_BASH_DIR="$DESTINATION/miaou-bash"
|
|
}
|
|
|
|
## MAIN
|
|
|
|
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
|
|
|
[[ -v MIAOU_BASH_DIR ]] || bootstrap
|
|
miaou-bash "$MIAOU_BASH_DIR/lib/init.bash"
|