forked from odyslam/gm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgm
executable file
·173 lines (153 loc) · 7.35 KB
/
gm
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env bash
# Source functions
source ./install-software-mac.sh
source ./install-software-linux.sh
source ./install-software-eth.sh
source ./install-software-common.sh
source ./sync.sh
source ./terminal-helpers.sh
source ./system-setup.sh
# Intro
welcome() {
cat << 'EOF'
_____________________________________________________________________________________
██████╗ ███╗ ███╗ ██████╗ ██████╗ ██╗ ██╗███████╗███████╗███████╗ █████╗ ███████╗
██╔════╝ ████╗ ████║ ██╔═══██╗██╔══██╗╚██╗ ██╔╝██╔════╝██╔════╝██╔════╝██╔══██╗██╔════╝
██║ ███╗██╔████╔██║ ██║ ██║██║ ██║ ╚████╔╝ ███████╗███████╗█████╗ ███████║███████╗
██║ ██║██║╚██╔╝██║ ██║ ██║██║ ██║ ╚██╔╝ ╚════██║╚════██║██╔══╝ ██╔══██║╚════██║
╚██████╔╝██║ ╚═╝ ██║ ╚██████╔╝██████╔╝ ██║ ███████║███████║███████╗██║ ██║███████║
╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝
_____________________________________________________________________________________
\
\
.,-:;//;:=,
. :H@@@MM@M#H/.,+%;,
,/X+ +M@@M@MM%=,-%HMMM@X/,
-+@MM; $M@@MH+-,;XMMMM@MMMM@+-
;@M@@M- XM@X;. -+XXXXXHHH@M@M#@/.
,%MM@@MH ,@%= .---=-=:=,.
=@#@@@MX ., WE -%HX$$%%%+;
=-./@M@M$ DO .;@MMMM@MM:
X@/ -$MM/ WHAT .+MM@@@M$
,@M@H: :@: WE . =X#@@@@-
,@@@MMX, . MUST /H- ;@M@M=
.H@@@@M@+, BECAUSE %MM+..%#$.
/MMMM@MMH/. WE XM@MH; =;
/%+%$XHH@$= CAN , .H@@@@MX,
.=--------. -%H.,@@@@@MX,
.%MM@@@HHHXX$$$%+- .:$MMX =M@@MM%.
=XMMM@MM@MM#H;,-+HMM@M+ /MMMX=
=%@M@M#@$-.=$@MM@@@M; %M%=
,:+$+-,/H#MMMMMMM@= =,
=++%%%%+/:-.
EOF
}
# https://manytools.org/hacker-tools/ascii-banner/
# ANSI shadow
print_usage(){
echo
cat << "EOF"
. .
██████╗ ███╗ ███╗ ██╗ ██╗███████╗ █████╗ ██████╗ ███████╗
██╔════╝ ████╗ ████║ ██║ ██║██╔════╝██╔══██╗██╔════╝ ██╔════╝
██║ ███╗██╔████╔██║ ██║ ██║███████╗███████║██║ ███╗█████╗
██║ ██║██║╚██╔╝██║ ██║ ██║╚════██║██╔══██║██║ ██║██╔══╝
╚██████╔╝██║ ╚═╝ ██║ ╚██████╔╝███████║██║ ██║╚██████╔╝███████╗
╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ══════╝
╚
EOF
echo
echo
message "${TPUT_BOLD}-g${TPUT_RESET}: Install GUI applications (e.g slack)"
message "${TPUT_BOLD}-d${TPUT_RESET}: Install dotfiles"
message "${TPUT_BOLD}-t${TPUT_RESET}: Install development toolchain"
message "${TPUT_BOLD}-s${TPUT_RESET}: Output instructions to setup the system (configuration, peripherals, etc.)"
message "${TPUT_BOLD}-a${TPUT_RESET}: Install all the above"
message "${TPUT_BOLD}-u${TPUT_RESET}: Update the dotfiles of this repo, with the ones installed in '${HOME}'"
}
# Installation types
GUI="${TPUT_RED}false${TPUT_RESET}"
DOTFILES="${TPUT_RED}false${TPUT_RESET}"
DEV_TOOLCHAIN="${TPUT_RED}false${TPUT_RESET}"
SYSTEM_SETUP="${TPUT_RED}false${TPUT_RESET}"
while getopts 'gdtsauh' OPTION; do
case "${OPTION}" in
a) GUI="true" && DEV_TOOLCHAIN="true" && DOTFILES="true" SYSTEM_SETUP='true';;
d) DOTFILES="true";;
g) GUI="true";;
t) DEV_TOOLCHAIN="true";;
u) UPDATE="true";;
s) SYSTEM_SETUP="true";;
*) echo && warning "flag is not recognised" && print_usage
exit 1;;
esac
done
# Check if no options were passed
if [ $OPTIND -eq 1 ]; then
echo
warning "No options were passed"
message "Use '-h' to print all available options"
exit 1
fi
welcome
if [[ "${UPDATE}" == "true" ]]; then
sync repo
exit 1
fi
message "The following software suites will be installed on the system:"
message "GUI apps: ${TPUT_BOLD}${TPUT_GREEN}$GUI${TPUT_RESET}"
message "Dotfiles: ${TPUT_BOLD}${TPUT_GREEN}$DOTFILES${TPUT_RESET}"
message "Dev Toolchain: ${TPUT_BOLD}${TPUT_GREEN}$DEV_TOOLCHAIN${TPUT_RESET}"
message "System Setup: ${TPUT_BOLD}${TPUT_GREEN}$SYSTEM_SETUP${TPUT_RESET}"
warning "'sudo' may be required during the installation process. A prompt will ask your for your password"
# Read input and advance only if user agrees
read -p "Ready to Install? [y/n] " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# Print 2 empty lines
echo
echo
/*//////////////////////////////////////////////////////////////
OS-DEPENDENT
//////////////////////////////////////////////////////////////*/
if [[ $(uname) == 'Darwin'* ]]; then
message "MacOS detected"
# Make sure the script can find brew
export PATH=$PATH:/opt/homebrew/bin
if ! [ -x "$(which brew)" ]; then
message "Installing brew.."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
message "brew already installed, skipping.."
install_software_mac
if [[ "${SYSTEM_SETUP}" == "true" ]]; then
system_setup_mac
fi
elif [[ $(uname) == 'Linux' ]]; then
message "Linux detected"
install_software_linux
if [[ "${SYSTEM_SETUP}" == "true" ]]; then
system_setup_linux
fi
fi
if [[ $DEV_TOOLCHAIN == "true" ]]; then
install_software_eth
install_software_common
fi
/*//////////////////////////////////////////////////////////////
OS-AGNOSTIC
//////////////////////////////////////////////////////////////*/
if [[ $DOTFILES == "true" ]]; then
message "Installing dotfiles"
message "Visit ~/.zsh_secrets and populate your API keys"
echo -e "export BALENA_TOKEN=\nexport ETHERSCAN_API_KEY=\nexport ETH_RPC_URL=" > ~/.zsh_secrets
sync local
message "Source the dotfiles by running: 'source ~/.zshrc'"
message "Emptying shell's hash.."
hash -r
if [[ $(which git) != "/opt/homebrew/bin/git" ]]; then
warning "The system is not configured to use brew's Git. Current Git path is ${TPUT_BOLD}$(which git)${TPUT_RESET}"
fi
fi