-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·142 lines (109 loc) · 3.31 KB
/
install.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
#
# Downloads, installs, and launches App Fair.app
#
set -u
FAIR_GROUND="App Fair"
echo "Welcome to the ${FAIR_GROUND}!"
BASE_PATH="/Applications"
APP_PATH="${BASE_PATH}/${FAIR_GROUND}.app"
INSTALL_PATH="${BASE_PATH}/${FAIR_GROUND}/"
TOKEN="${FAIR_GROUND// /-}"
ZIPURL="https://github.com/${TOKEN}/App/releases/latest/download/${TOKEN}-macOS.zip"
echo "This script will download and install the ${FAIR_GROUND} catalog browser app."
abort() {
printf "%s\n" "$@"
exit 1
}
if [ -z "${BASH_VERSION:-}" ]; then
abort "Bash is required to interpret this script."
fi
# Check if script is run non-interactively (e.g. CI)
# If it is run non-interactively we should not prompt for passwords.
if [[ ! -t 0 || -n "${CI-}" ]]; then
NONINTERACTIVE=1
fi
# First check OS.
OS="$(uname)"
if [[ "$OS" != "Darwin" ]]; then
abort "The ${FAIR_GROUND} is only supported on macOS."
fi
# version check
if [ "`/usr/bin/sw_vers -productVersion | cut -f 1 -d '.'`" -lt 12 ]; then
echo "Sorry, the ${FAIR_GROUND} requires macOS 12."
echo "Come back soon!"
exit 12
fi
getc() {
local save_state
save_state=$(/bin/stty -g)
/bin/stty raw -echo
IFS= read -r -n 1 -d '' "$@"
/bin/stty "$save_state"
}
ring_bell() {
if [[ -t 1 ]]; then
printf "\a"
fi
}
wait_for_user() {
local c
getc c
if ! [[ "$c" == $'\r' || "$c" == $'\n' ]]; then
exit 1
fi
}
await_return() {
if [[ -z "${NONINTERACTIVE-}" ]]; then
ring_bell
wait_for_user
fi
}
# string formatters
if [[ -t 1 ]]; then
tty_escape() { printf "\033[%sm" "$1"; }
else
tty_escape() { :; }
fi
tty_mkbold() { tty_escape "1;$1"; }
tty_underline="$(tty_escape "4;39")"
tty_red="$(tty_mkbold 31)"
tty_green="$(tty_mkbold 32)"
tty_yellow="$(tty_mkbold 33)"
tty_blue="$(tty_mkbold 34)"
tty_purple="$(tty_mkbold 35)"
tty_cyan="$(tty_mkbold 36)"
tty_bold="$(tty_mkbold 39)"
tty_reset="$(tty_escape 0)"
echo ""
echo " Destination: ${APP_PATH}"
echo " Package: ${ZIPURL}"
echo ""
printf "Hit return to proceed (or CMD-C to quit): "
await_return
# quit the app if it is running
killall -qI "${FAIR_GROUND}"
# ensure we have write access to App Fair (otherwise we may need sudo)
mkdir -p "${INSTALL_PATH}" || abort "Could not create install folder: ${INSTALL_PATH}"
chmod 777 "${INSTALL_PATH}/" || true # abort "Could not fix permissions on ${INSTALL_PATH}/"
# remove previous version if it is installed
mv -f "${INSTALL_PATH}" "~/.Trash/App-Fair-$(uuidgen)" || true # failure is permitted
echo ""
echo ""
printf " Installing the ${FAIR_GROUND}…"
curl -fsSL "${ZIPURL}" | ditto --noqtn -x -k - "${BASE_PATH}" || abort "Unable to install"
printf " Verifying…"
codesign --verify --deep --strict "${APP_PATH}" || abort "Validation Failed"
#spctl --add --label "${FAIR_GROUND}" "${APP_PATH}"
#spctl -a -vv -t execute "${APP_PATH}" || abort "Validation Failed"
echo " Success!"
echo ""
echo "The ${FAIR_GROUND} is now installed in ${APP_PATH}"
printf "Hit return to launch the app (or CMD-C to exit): "
await_return
echo ""
# launch the app pointing to the ${FAIR_GROUND} folder
open -F -n -b 'app.App-Fair' -a "${APP_PATH}"
# "${INSTALL_PATH}"
APP_FAIR_COLORS="${tty_red}A${tty_reset}${tty_blue}p${tty_reset}${tty_yellow}p${tty_reset} ${tty_green}F${tty_reset}${tty_cyan}a${tty_reset}${tty_blue}i${tty_reset}${tty_red}r${tty_reset}"
echo "Welcome to the ${APP_FAIR_COLORS}!"