#!/bin/bash
+JVM=/Library/Java/JavaVirtualMachines
+dir=`dirname "$0"`
+
case `id -u` in
0)
;;
*)
- # Check for java
- if [ ! -d /Library/Java/JavaVirtualMachines/ -o `ls /Library/Java/JavaVirtualMachine` == '' ]; then
- open https://adoptopenjdk.net/
- osascript -e 'display dialog "Install Java from https://adoptopenjdk.net then click OK" buttons {"Continue"}'
- fi
- sudo "$0" "$@"
+ SUDO_ASKPASS="${dir}/ask-pass" sudo -A "$0" "$@"
+ case $? in
+ 0)
+ ;;
+ *)
+ osascript -e 'display dialog "Installation failed. Incorrect password?" buttons {"OK"} default button 1 with title "Installation Status"' > /dev/null
+ ;;
+ esac
+ exit 0
;;
esac
-dir=`dirname "$0"`
+# Check for java
+if ls "$JVM" | grep -q temurin; then
+ echo "Adoptium already present"
+else
+ open https://adoptium.net/
+ osascript -e 'display dialog "Install Java from https://adoptium.net then click Continue" buttons {"Continue"} default button 1 with title "Install Java"' >/dev/null
+fi
+
cd "$dir"
-APP=`echo *.app`
LIBRARY=/Library/AltusMetrum
-APPLICATIONS=/Applications/
+APPLICATIONS=/Applications
+INSTALLED=
for file in *; do
- case "$i" in
+ echo 'Installing' "$file"
+ case "$file" in
*.app)
- mkdir -p "$(APPLICATIONS)"
- if [ -d "$(APPLICATIONS)/$(APP)/." ]; then
- rm -rf "$(APPLICATIONS)/$(APP)"
+ mkdir -p "${APPLICATIONS}"
+ if [ -d "${APPLICATIONS}/${file}" ]; then
+ rm -rf "${APPLICATIONS}/${file}"
fi
- cp -a "$i" "$(APPLICATIONS)/$(APP)"
- chmod +w "$(APPLICATIONS)/$(APP)"/*
- xattr -c "$(APPLICATIONS)/$(APP)"/*
+ cp -a "$file" "${APPLICATIONS}/${file}"
+ chmod -R +w "${APPLICATIONS}/${file}"
+ xattr -rc "${APPLICATIONS}/${file}"
+ APP=`basename "$file" .app`
+ INSTALLED="${INSTALLED} ${APP}"
;;
*)
- mkdir -p "$(LIBRARY)"
- cp -a "$i" "$(LIBRARY)"
+ mkdir -p "${LIBRARY}"
+ cp -a "$file" "${LIBRARY}"
;;
esac
done
+open "${LIBRARY}"
+osascript -e 'display dialog "Installation of'"${INSTALLED}"' complete" with title "Installation Complete" buttons {"OK"} default button 1' >/dev/null