-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-unstable.sh
110 lines (91 loc) · 3.15 KB
/
install-unstable.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
clear
appleChip=$(uname -m)
function getLatestReleaseURLGH(){
local repository=$1
local fileType=$2
local fileNameContains=$3
local url
#local token=$(tokenGenerator)
if [ "$url" == "" ]; then
url="https://api.github.com/repos/${repository}/releases/latest"
fi
curl -fSs "$url" | \
jq -r '[ .assets[] | select(.name | contains("'"$fileNameContains"'") and endswith("'"$fileType"'")).browser_download_url ][0] // empty'
}
function alert() {
osascript <<EOT
tell app "System Events"
display dialog "$1" buttons {"OK"} default button 1 with icon caution with title "EmuDeck - Mac Setup"
return -- Suppress result
end tell
EOT
}
safeDownload() {
local name="$1"
local url="$2"
local outFile="$3"
local showProgress="$4"
local headers="$5"
if [ "$showProgress" == "true" ]; then
echo "safeDownload()"
echo "- $name"
echo "- $url"
echo "- $outFile"
echo "- $showProgress"
echo "- $headers"
fi
request=$(curl -w $'\1'"%{response_code}" --fail -L "$url" -H "$headers" -o "$outFile.temp" 2>&1 && echo $'\2'0 || echo $'\2'$?)
returnCodes="${request#*$'\1'}"
httpCode="${returnCodes%$'\2'*}"
exitCode="${returnCodes#*$'\2'}"
if [ "$httpCode" = "200" ] && [ "$exitCode" == "0" ]; then
#echo "$name downloaded successfully";
mv -v "$outFile.temp" "$outFile" &>/dev/null
volumeName=$(yes | hdiutil attach "$outFile" | grep -o '/Volumes/.*$')
return 0
else
#echo "$name download failed"
rm -f "$outFile.temp"
return 1
fi
}
if ! command -v brew &> /dev/null; then
hasBrew=false
else
hasBrew=true
fi
function prompt() {
osascript <<EOT
tell app "System Events"
text returned of (display dialog "$1" default answer "$2" buttons {"OK"} default button 1 with title "EmuDeck - Mac Dependencies")
end tell
EOT
}
if [ $hasBrew == "false" ]; then
read -r pass <<< "$(prompt 'EmuDeck needs to install Brew, and for that you need to input your password:' '')"
echo $pass | sudo -v -S && {
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSLk https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
}
if [ $appleChip == "arm64" ];then
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc && source ~/.zshrc
else
echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
echo "export PATH=/usr/local/bin:$PATH" >> ~/.zshrc && source ~/.zshrc
fi
fi
#Brew dependencies
brew install zenity gnu-sed rsync xmlstarlet jq fileicon
if ! command -v xcode-select &>/dev/null; then
xcode-select --install
wait
fi
if [ $appleChip == "arm64" ];then
EmuDeckURL="$(getLatestReleaseURLGH "EmuDeck/emudeck-electron-early-unstable" "arm64.dmg")"
else
EmuDeckURL="$(getLatestReleaseURLGH "EmuDeck/emudeck-electron-early-unstable" ".dmg")"
fi
safeDownload "EmuDeck" "$EmuDeckURL" "$HOME/Downloads/EmuDeck.dmg" && open "$HOME/Downloads/EmuDeck.dmg"
open "$HOME/Downloads/EmuDeck.dmg"
exit