diff --git a/README.md b/README.md index cacf3bd..882770b 100644 --- a/README.md +++ b/README.md @@ -24,16 +24,16 @@ ## To auto install on Linux: ```bash -[[ "$(command -v apt-get)" && ! "$(command -v wget)" ]] && sudo apt-get install -y wget -[[ "$(command -v pacman)" && ! "$(command -v wget)" ]] && sudo pacman -S wget -[[ "$(command -v yum)" && ! "$(command -v wget)" ]] && sudo yum install -y wget +[ "$(command -v apt-get)" -a -z "$(command -v wget)" ] && sudo apt-get install -y wget +[ "$(command -v pacman)" -a -z "$(command -v wget)" ] && sudo pacman -S wget +[ "$(command -v yum)" -a -z "$(command -v wget)" ] && sudo yum install -y wget wget -qO - https://raw.githubusercontent.com/sn4k3/UVtools/master/Scripts/install-uvtools.sh | bash ``` ## To auto install on MacOS (homebrew): ```bash -[[ ! "$(command -v brew)" ]] && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +[ -z "$(command -v brew)" ] && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install --cask uvtools ``` @@ -276,9 +276,9 @@ The following commands are the old way and commands under the UI executable, the **Copy the following script, paste and run on a terminal:** ```bash -[[ "$(command -v apt-get)" && ! "$(command -v wget)" ]] && sudo apt-get install -y wget -[[ "$(command -v pacman)" && ! "$(command -v wget)" ]] && sudo pacman -S wget -[[ "$(command -v yum)" && ! "$(command -v wget)" ]] && sudo yum install -y wget +[ "$(command -v apt-get)" -a -z "$(command -v wget)" ] && sudo apt-get install -y wget +[ "$(command -v pacman)" -a -z "$(command -v wget)" ] && sudo pacman -S wget +[ "$(command -v yum)" -a -z "$(command -v wget)" ] && sudo yum install -y wget wget -qO - https://raw.githubusercontent.com/sn4k3/UVtools/master/Scripts/install-dependencies.sh | sudo bash wget -qO - https://raw.githubusercontent.com/sn4k3/UVtools/master/Scripts/libdl-solver.sh | sudo bash ``` diff --git a/Scripts/install-dependencies.sh b/Scripts/install-dependencies.sh index a034010..d8d4f13 100644 --- a/Scripts/install-dependencies.sh +++ b/Scripts/install-dependencies.sh @@ -8,7 +8,7 @@ echo "Script to install the dependencies in order to run the UVtools" -if [[ $EUID -ne 0 ]]; then +if [ $EUID -ne 0 ]; then echo "This script must be run as root" exit 1 fi @@ -16,13 +16,13 @@ fi arch_name="$(uname -m)" osVariant="" -if [[ "$arch_name" != "x86_64" && "$arch_name" != "arm64" ]]; then - echo "Error: Unsupported host arch: $arch_name" +if [ "$arch_name" != "x86_64" -a "$arch_name" != "arm64" ]; then + echo "Error: Unsupported host arch $arch_name" exit -1 fi #echo "- Detecting OS" -if [[ $OSTYPE == 'darwin'* ]]; then +if [ "${OSTYPE:0:6}" == "darwin" ]; then osVariant="macOS" #/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" #brew analytics off diff --git a/Scripts/install-uvtools.sh b/Scripts/install-uvtools.sh index 94d4cda..cd2a130 100644 --- a/Scripts/install-uvtools.sh +++ b/Scripts/install-uvtools.sh @@ -6,43 +6,50 @@ # usage 1: ./install-uvtools.sh # cd "$(dirname "$0")" -arch_name="$(uname -m)" -osVariant="" +arch_name="$(uname -m)" # x86_64 or arm64 +osVariant="" # osx, linux, arch, rhel api_url="https://api.github.com/repos/sn4k3/UVtools/releases/latest" dependencies_url="https://raw.githubusercontent.com/sn4k3/UVtools/master/Scripts/install-dependencies.sh" +macOS_least_version=10.15 -if [[ "$arch_name" != "x86_64" && "$arch_name" != "arm64" ]]; then - echo "Error: Unsupported host arch: $arch_name" +function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } + +if [ "$arch_name" != "x86_64" -a "$arch_name" != "arm64" ]; then + echo "Error: Unsupported host arch $arch_name" exit -1 fi - echo "Script to download and install UVtools" echo "- Detecting OS" -if [[ $OSTYPE == 'darwin'* ]]; then +if [ "${OSTYPE:0:6}" == "darwin" ]; then osVariant="osx" - if [ installDependencies == true ]; then - [[ ! "$(command -v brew)" ]] && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - brew install --cask uvtools - exit 1 + macOS_version="$(sw_vers -productVersion)" + + if [ $(version $macOS_version) -lt $(version $macOS_least_version) ]; then + echo "Error: Unable to install, UVtools requires at least macOS $macOS_least_version." + exit -1 fi + + [ -z "$(command -v brew)" ] && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + brew install --cask uvtools + exit 1 elif command -v apt-get &> /dev/null then osVariant="linux" - [[ ! "$(command -v wget)" ]] && sudo apt-get install -y wget - [[ ! "$(command -v curl)" ]] && sudo apt-get install -y curl + [ -z "$(command -v wget)" ] && sudo apt-get install -y wget + [ -z "$(command -v curl)" ] && sudo apt-get install -y curl elif command -v pacman &> /dev/null then osVariant="arch" - [[ ! "$(command -v wget)" ]] && sudo pacman -S wget - [[ ! "$(command -v curl)" ]] && sudo pacman -S curl + [ -z "$(command -v wget)" ] && sudo pacman -S wget + [ -z "$(command -v curl)" ] && sudo pacman -S curl elif command -v yum &> /dev/null then osVariant="rhel" - [[ ! "$(command -v wget)" ]] && sudo yum install -y wget - [[ ! "$(command -v curl)" ]] && sudo yum install -y curl + [ -z "$(command -v wget)" ] && sudo yum install -y wget + [ -z "$(command -v curl)" ] && sudo yum install -y curl fi if [ -z "$osVariant" ]; then @@ -52,7 +59,7 @@ fi echo "- Detected: $osVariant $arch_name" -if [[ ! "$(ldconfig -p | grep libpng)" || ! "$(ldconfig -p | grep libgdiplus)" || ! "$(ldconfig -p | grep libavcodec)" ]]; then +if [ ! "$(ldconfig -p | grep libpng)" -o ! "$(ldconfig -p | grep libgdiplus)" -o ! "$(ldconfig -p | grep libavcodec)" ]; then echo "- Missing dependencies found, installing..." wget -qO - $dependencies_url | sudo bash fi diff --git a/Scripts/libdl-solver.sh b/Scripts/libdl-solver.sh index 2f8c99b..9b80180 100644 --- a/Scripts/libdl-solver.sh +++ b/Scripts/libdl-solver.sh @@ -8,7 +8,7 @@ # Version: 1 # -if [[ $EUID -ne 0 ]]; then +if [ $EUID -ne 0 ]; then echo "This script must be run as root" exit 1 fi