#!/bin/bash function install() { echo "install on: $HOSTNAME" echo ---------------------- [ "$(id -u)" -ne 0 ] && echo 'root privilege required' && exit 1 if [[ ! $CURDIR == '/opt/miaou-bash' ]]; then # download and fullfill /opt/miaou-bash, then run it from folder if [[ -L /opt/miaou-bash ]]; then cd /opt/miaou-bash && ./install.sh "$PARAM1" exit 0 else rm -rf /opt/miaou-bash TEMP=$(mktemp -d) cd "$TEMP" || return echo "$TEMP" wget https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz tar -xzf main.tar.gz mv miaou-bash /opt/ cd /opt/miaou-bash || return ./install.sh "$PARAM1" rm -rf "$TEMP" exit 0 fi else apt-get update apt-get install -y "${REQUIRED_PKGS[@]}" ./init.sh fi } ## MAIN CURDIR=$PWD REQUIRED_PKGS=(file git bc) install