-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
91 lines (68 loc) · 2.49 KB
/
start.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
#!/usr/bin/env bash
### READ:
### regarding shell scripting for posix :
### https://unix.stackexchange.com/a/33762/314538
### https://unix.stackexchange.com/questions/392450/bash-renaming-files-extension
# stdout messages
sep='--------------------------------------------------------'
osupdate_msg='Installing recommended OS update, this requires administrator password. \
Run this again if restarting.'
timezone_msg='Setting system timezone to'
xcode_msg='Installing Xcode...'
gitclone_msg='Cloning .dev repo...'
chmod_msg='Changing permissions for .sh files to +x...'
osx_cfg_msg='Setting up macOS default settings...'
dotfiles_msg='Creating dotfiles in home folder...'
brewinstall_msg='Installing brew...'
cli_tools_msg='Installing cli tools...'
printheader() {
echo "
$sep
: $1 $2
"
}
# Start
echo "$sep"
echo "$(date), macOS version: $(sw_vers -productVersion)"
printheader "$osupdate_msg"
## Ask for the administrator password upfront
sudo -v
## Keep-alive: update existing `sudo` time stamp until we're finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
## Install macOS recommended update(s)
sudo softwareupdate --install --recommended --restart --verbose
## and install Xcode tools
printheader "$xcode_msg"
xcode-select --install
# TODO: evaluate the best sequence/strategy since brew install affects dotfiles
# which means it affects dotfiles.sh
# maybe create a function in dotfiles.sh to detect if each file existed already
# if so either merge the diff'd lines or copy as new file with .default extension
## cli tools
## printheader "$cli_tools_msg"
##
## install from brew
## TODO: get list from ./install_cfg/brew_packages.cfg (pure bash/python/ansible) using -f filename flag
./brew_install_packages.sh
## clone .dev repo
printheader "$gitclone_msg"
git clone https://github.com/oleng/.dev.git && cd .dev
printheader "$chmod_msg"
chmod -R +x *.sh
## dotfiles
printheader "$dotfiles_msg"
./dotfiles.sh
## install brew package manager
printheader "$brewinstall_msg"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
## start setting os
printheader "$osx_cfg_msg"
./osx.sh
## Done
printheader "Setup finished. Exiting."
exit 0
# Enable find my mac with defaults (Warning ABSOLUTE PATH ONLY):
# defaults [-currentHost | -host hostname] write domain { 'plist' | key 'value' }
# breaks the defaults read
# defaults write /System/Library/LaunchDaemons/com.apple.findmymac.plist MachServices '{"com.apple.findmymacd" =0;}'