-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-store.sh
executable file
·47 lines (37 loc) · 1.21 KB
/
app-store.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
#!/bin/bash
CYAN='\033[0;36m'
NC='\033[0m'
# log helper
log () {
printf "${CYAN}$1${NC}\n"
}
FILENAME="./data/app-store.txt"
BASE_PATH="/Applications"
BASE_URL="itms-apps://apps.apple.com/us/app"
while read line; do
# id is the numerical id from app store urls
id=`echo $line | cut -d',' -f 1`
# app is the actual folder name in the /Applications folder
app=`echo $line | cut -d',' -f 2`
# build the path and url to check for app installation and open app store
path="$BASE_PATH/$app.app"
url="$BASE_URL/id$id"
# check if the app is still not installed
if ! test -d "$path"
then
log "=> Installing $app..."
open "$url"
# wait for installation to finish
while ! test -d "$path"
do
sleep 1
done
else
log "=> $app is already installed"
fi
done < $FILENAME
# use command line tools from installed xcode version
# OHNO: this asks for user password so it's annoying to always run it
# TODO: figure how to validate whether it's necessary to run this command, probably with the output of `xcodebuild`
# HELP: https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error/17980786#17980786
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer