mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
Update install-uvtools.sh
This commit is contained in:
+142
-150
@@ -9,10 +9,10 @@
|
||||
#cd "$(dirname "$0")"
|
||||
arch="$(uname -m)" # x86_64 or arm64
|
||||
archCode="${arch/86_/}"
|
||||
osVariant="" # osx, linux, arch, rhel
|
||||
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
|
||||
macOS_least_version='10.15'
|
||||
|
||||
version() { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
||||
testcmd() { command -v "$1" &> /dev/null; }
|
||||
@@ -61,88 +61,17 @@ if [ "$arch" != "x86_64" -a "$arch" != "arm64" ]; then
|
||||
exit -1
|
||||
fi
|
||||
|
||||
echo "Script to download and install UVtools"
|
||||
echo ' _ ___ ___ _ '
|
||||
echo ' | | | \ \ / / |_ ___ ___ | |___ '
|
||||
echo ' | | | |\ \ / /| __/ _ \ / _ \| / __|'
|
||||
echo ' | |_| | \ V / | || (_) | (_) | \__ \'
|
||||
echo ' \___/ \_/ \__\___/ \___/|_|___/'
|
||||
echo ' Auto download and installer script '
|
||||
|
||||
echo "- Detecting OS"
|
||||
|
||||
if [ "${OSTYPE:0:6}" == "darwin" ]; then
|
||||
#############
|
||||
# macOS #
|
||||
#############
|
||||
osVariant="osx"
|
||||
macOS_version="$(sw_vers -productVersion)"
|
||||
appPath="/Applications/UVtools.app"
|
||||
|
||||
echo "- Detected: $osVariant $arch"
|
||||
|
||||
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
|
||||
|
||||
if ! testcmd codesign && ! testcmd brew; then
|
||||
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
if [ -f "/opt/homebrew/bin/brew" -a -z "$(command -v brew)" ]; then
|
||||
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> "$HOME/.zprofile"
|
||||
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME/.zprofile"
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Required dotnet-sdk to run arm64 and bypass codesign
|
||||
#if [ "$arch" == "arm64" -a -z "$(command -v dotnet)" ]; then
|
||||
# if ! testcmd brew; then
|
||||
# bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
# if [ -f "/opt/homebrew/bin/brew" -a -z "$(command -v brew)" ]; then
|
||||
# echo '# Set PATH, MANPATH, etc., for Homebrew.' >> "$HOME/.zprofile"
|
||||
# echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME/.zprofile"
|
||||
# eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
# fi
|
||||
# fi
|
||||
#
|
||||
# brew install --cask dotnet-sdk
|
||||
#fi
|
||||
|
||||
echo "- Detecting download"
|
||||
|
||||
download_url="$(curl -s "$api_url" \
|
||||
| grep "browser_download_url.*_${osVariant}-${archCode}_.*\.zip" \
|
||||
| head -1 \
|
||||
| cut -d : -f 2,3 \
|
||||
| tr -d \")"
|
||||
|
||||
if [ -z "$download_url" ]; then
|
||||
echo "Error: Unable to detect the download url."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
downloaduvtools "$download_url"
|
||||
|
||||
echo "- Removing old versions"
|
||||
rm -rf "$appPath"
|
||||
|
||||
echo "- Inflating $filename to $appPath"
|
||||
unzip -q -o "$tmpfile" -d "/Applications"
|
||||
rm -f "$tmpfile"
|
||||
|
||||
if [ -d "$appPath" ]; then
|
||||
# Remove quarantine security from files
|
||||
find "$appPath" -print0 | xargs -0 xattr -d com.apple.quarantine &> /dev/null
|
||||
|
||||
# Force codesign to allow the app to run directly
|
||||
codesign --force --deep --sign - "$appPath"
|
||||
|
||||
echo ''
|
||||
echo 'Installation was successful. UVtools will now run.'
|
||||
echo ''
|
||||
|
||||
open -n "$appPath"
|
||||
else
|
||||
echo "Installation unsuccessful, unable to create '$appPath'."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
exit 1
|
||||
elif testcmd apt-get; then
|
||||
osVariant="linux"
|
||||
! testcmd curl && sudo apt-get install -y curl
|
||||
@@ -162,85 +91,148 @@ if [ -z "$osVariant" ]; then
|
||||
exit -1
|
||||
fi
|
||||
|
||||
#############
|
||||
# Linux #
|
||||
#############
|
||||
echo "- Detected: $osVariant $arch"
|
||||
|
||||
requiredlddversion="2.31"
|
||||
lddversion="$(ldd --version | awk '/ldd/{print $NF}')"
|
||||
if [ "$osVariant" == "osx" ]; then
|
||||
#############
|
||||
# macOS #
|
||||
#############
|
||||
macOS_version="$(sw_vers -productVersion)"
|
||||
appPath="/Applications/UVtools.app"
|
||||
|
||||
|
||||
if [ $(version $lddversion) -lt $(version $requiredlddversion) ]; then
|
||||
echo ""
|
||||
echo "##########################################################"
|
||||
echo "Error: Unable to auto install the latest version."
|
||||
echo "ldd version: $lddversion detected, but requires at least version $requiredlddversion."
|
||||
echo "Solutions:"
|
||||
echo "- Upgrade your system to the most recent version"
|
||||
echo "- Try to upgrade glibc to at least $requiredlddversion (Search about this as it can break your system)"
|
||||
echo "##########################################################"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
LDCONFIG=''
|
||||
if testcmd ldconfig; then
|
||||
LDCONFIG='ldconfig'
|
||||
else
|
||||
LDCONFIG="$(whereis ldconfig | awk '{ print $2 }')"
|
||||
fi
|
||||
|
||||
if [ -n "$LDCONFIG" ]; then
|
||||
if [ -z "$($LDCONFIG -p | grep libgeotiff)" -o -z "$($LDCONFIG -p | grep libgdiplus)" ]; then
|
||||
echo "- Missing dependencies found, installing..."
|
||||
sudo bash -c "$(curl -fsSL $dependencies_url)"
|
||||
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
|
||||
else
|
||||
echo "Unable to detect for missing dependencies, ldconfig not found, however installation will continue."
|
||||
fi
|
||||
|
||||
echo "- Detecting download"
|
||||
response="$(curl -s "$api_url")"
|
||||
if ! testcmd codesign && ! testcmd brew; then
|
||||
echo '- Codesign required, installing...'
|
||||
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
if [ -f "/opt/homebrew/bin/brew" -a -z "$(command -v brew)" ]; then
|
||||
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> "$HOME/.zprofile"
|
||||
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME/.zprofile"
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
fi
|
||||
|
||||
download_url="$(echo "$response" \
|
||||
| grep "browser_download_url.*_${osVariant}-x64_.*\.AppImage" \
|
||||
| head -1 \
|
||||
| cut -d : -f 2,3 \
|
||||
| tr -d \")"
|
||||
echo '- Detecting download'
|
||||
|
||||
if [ -z "$download_url" ]; then
|
||||
download_url="$(echo "$response" \
|
||||
| grep "browser_download_url.*_linux-x64_.*\.AppImage" \
|
||||
download_url="$(curl -s "$api_url" \
|
||||
| grep "browser_download_url.*_${osVariant}-${archCode}_.*\.zip" \
|
||||
| head -1 \
|
||||
| cut -d : -f 2,3 \
|
||||
| tr -d \")"
|
||||
|
||||
if [ -z "$download_url" ]; then
|
||||
echo 'Error: Unable to detect the download url.'
|
||||
exit -1
|
||||
fi
|
||||
|
||||
downloaduvtools "$download_url"
|
||||
|
||||
echo '- Removing old versions'
|
||||
rm -rf "$appPath"
|
||||
|
||||
echo "- Inflating $filename to $appPath"
|
||||
unzip -q -o "$tmpfile" -d "/Applications"
|
||||
rm -f "$tmpfile"
|
||||
|
||||
if [ -d "$appPath" ]; then
|
||||
echo '- Removing com.apple.quarantine security flag (gatekeeper)'
|
||||
find "$appPath" -print0 | xargs -0 xattr -d com.apple.quarantine &> /dev/null
|
||||
|
||||
# Force codesign to allow the app to run directly
|
||||
echo '- Codesign app bundle'
|
||||
codesign --force --deep --sign - "$appPath"
|
||||
|
||||
echo ''
|
||||
echo 'Installation was successful. UVtools will now run.'
|
||||
echo ''
|
||||
|
||||
open -n "$appPath"
|
||||
else
|
||||
echo "Installation unsuccessful, unable to create '$appPath'."
|
||||
exit -1
|
||||
fi
|
||||
else
|
||||
#############
|
||||
# Linux #
|
||||
#############
|
||||
requiredlddversion="2.31"
|
||||
lddversion="$(ldd --version | awk '/ldd/{print $NF}')"
|
||||
|
||||
|
||||
if [ $(version $lddversion) -lt $(version $requiredlddversion) ]; then
|
||||
echo ""
|
||||
echo "##########################################################"
|
||||
echo "Error: Unable to auto install the latest version."
|
||||
echo "ldd version: $lddversion detected, but requires at least version $requiredlddversion."
|
||||
echo "Solutions:"
|
||||
echo "- Upgrade your system to the most recent version"
|
||||
echo "- Try to upgrade glibc to at least $requiredlddversion (Search about this as it can break your system)"
|
||||
echo "##########################################################"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
LDCONFIG=''
|
||||
if testcmd ldconfig; then
|
||||
LDCONFIG='ldconfig'
|
||||
else
|
||||
LDCONFIG="$(whereis ldconfig | awk '{ print $2 }')"
|
||||
fi
|
||||
|
||||
if [ -n "$LDCONFIG" ]; then
|
||||
if [ -z "$($LDCONFIG -p | grep libgeotiff)" -o -z "$($LDCONFIG -p | grep libgdiplus)" ]; then
|
||||
echo "- Missing dependencies found, installing..."
|
||||
sudo bash -c "$(curl -fsSL $dependencies_url)"
|
||||
fi
|
||||
else
|
||||
echo "Unable to detect for missing dependencies, ldconfig not found, however installation will continue."
|
||||
fi
|
||||
|
||||
echo '- Detecting download'
|
||||
response="$(curl -s "$api_url")"
|
||||
|
||||
download_url="$(echo "$response" \
|
||||
| grep "browser_download_url.*_${osVariant}-x64_.*\.AppImage" \
|
||||
| head -1 \
|
||||
| cut -d : -f 2,3 \
|
||||
| tr -d \")"
|
||||
|
||||
if [ -z "$download_url" ]; then
|
||||
download_url="$(echo "$response" \
|
||||
| grep "browser_download_url.*_linux-x64_.*\.AppImage" \
|
||||
| head -1 \
|
||||
| cut -d : -f 2,3 \
|
||||
| tr -d \")"
|
||||
fi
|
||||
|
||||
if [ -z "$download_url" ]; then
|
||||
echo 'Error: Unable to detect the download url.'
|
||||
exit -1
|
||||
fi
|
||||
|
||||
downloaduvtools "$download_url"
|
||||
|
||||
targetDir="$PWD"
|
||||
[ -d "$HOME/Applications" ] && targetDir="$HOME/Applications"
|
||||
targetFilePath="$targetDir/UVtools.AppImage"
|
||||
|
||||
echo '- Removing old versions'
|
||||
rm -f "$targetDir/UVtools_"*".AppImage"
|
||||
|
||||
echo "- Moving $filename to $targetDir"
|
||||
mv -f "$tmpfile" "$targetFilePath"
|
||||
rm -f "$tmpfile"
|
||||
|
||||
echo '- Setting permissions'
|
||||
chmod -fv 775 "$targetFilePath"
|
||||
|
||||
"$targetFilePath" &
|
||||
|
||||
echo ''
|
||||
echo 'Installation was successful. UVtools will now run.'
|
||||
echo 'If prompt for "Desktop integration", click "Integrate and run"'
|
||||
echo ''
|
||||
fi
|
||||
|
||||
if [ -z "$download_url" ]; then
|
||||
echo "Error: Unable to detect the download url."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
downloaduvtools "$download_url"
|
||||
|
||||
targetDir="$PWD"
|
||||
[ -d "$HOME/Applications" ] && targetDir="$HOME/Applications"
|
||||
targetFilePath="$targetDir/UVtools.AppImage"
|
||||
|
||||
echo "- Removing old versions"
|
||||
rm -f "$targetDir/UVtools_"*".AppImage"
|
||||
|
||||
echo "- Moving $filename to $targetDir"
|
||||
mv -f "$tmpfile" "$targetFilePath"
|
||||
rm -f "$tmpfile"
|
||||
|
||||
echo "- Setting permissions"
|
||||
chmod -fv 775 "$targetFilePath"
|
||||
|
||||
"$targetFilePath" &
|
||||
|
||||
echo ''
|
||||
echo 'Installation was successful. UVtools will now run.'
|
||||
echo 'If prompt for "Desktop integration", click "Integrate and run"'
|
||||
echo ''
|
||||
|
||||
Reference in New Issue
Block a user