-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
executable file
·236 lines (191 loc) · 7.3 KB
/
installer.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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/bin/bash
#*************************************
# Terminal Notes Utility written in C
#*************************************
# Simple: Create and manage notes from the terminal
#*************************************
# Developed and engineered by
# Felipe Alfonso Gonzalez <f.alfonso@res-ear.ch>
# Computer Science Engineer
# Chile
#*************************************
# Installer v.1.0.2
echo "
▀▀█▀▀ █▀▀ █▀▀█ █▀▄▀█ ░░ ▒█▄░▒█ █▀▀█ ▀▀█▀▀ █▀▀ █▀▀
░▒█░░ █▀▀ █▄▄▀ █░▀░█ ▀▀ ▒█▒█▒█ █░░█ ░░█░░ █▀▀ ▀▀█
░▒█░░ ▀▀▀ ▀░▀▀ ▀░░░▀ ░░ ▒█░░▀█ ▀▀▀▀ ░░▀░░ ▀▀▀ ▀▀▀
╔═══════════════════════════════════════╗
║ ║
║ ~ Term Notes ~ ║
║ Developed with ❤️ by ║
║ Felipe Alfonso González L. ║
║ Computer Science Engineer ║
║ Chile ║
║ ║
║ Contact: f.alfonso@res-ear.ch ║
║ Licensed under MIT ║
║ GitHub: github.com/felipealfonsog ║
║ LinkedIn: ║
║ linkedin.com/in/felipealfonsog ║
║ ║
╚═══════════════════════════════════════╝
"
echo "Welcome to the Term-Notes installer!"
echo "*************************************************
"
if [[ ! -x "$0" ]]; then
echo "The installer script does not have execute permission. Do you want to grant it?"
select yn in "Yes" "No"; do
case $yn in
Yes)
chmod +x "$0"
exec "$0" "$@"
;;
No)
echo "Exiting program."
exit 0
;;
*)
echo "Invalid option. Please choose a valid option."
;;
esac
done
fi
if [[ $(uname) == "Darwin" ]]; then
if ! command -v brew &> /dev/null; then
echo "Homebrew is not installed on macOS. Do you want to install it?"
select yn in "Yes" "No"; do
case $yn in
Yes)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
break
;;
No)
echo "Exiting program."
exit 0
;;
*)
echo "Invalid option. Please choose a valid option."
;;
esac
done
fi
elif [[ $(uname) == "Linux" ]]; then
if ! command -v brew &> /dev/null; then
echo "Homebrew/Linuxbrew is not installed on Linux. Do you want to install it?"
select yn in "Yes" "No"; do
case $yn in
Yes)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
break
;;
No)
echo "Exiting program."
exit 0
;;
*)
echo "Invalid option. Please choose a valid option."
;;
esac
done
fi
if ! command -v gcc &> /dev/null; then
echo "GCC is not installed on Linux. Do you want to install it?"
select yn in "Yes, using Homebrew" "Yes, using package manager" "No"; do
case $yn in
"Yes, using Homebrew")
brew install gcc
break
;;
"Yes, using package manager")
if [[ -f /etc/arch-release ]]; then
sudo pacman -S gcc
elif [[ -f /etc/debian_version ]]; then
sudo apt-get update && sudo apt-get install gcc
else
echo "Unsupported Linux distribution. Please install GCC manually, read documentation according to your distro, and re-run the installer."
exit 1
fi
break
;;
"No")
echo "Exiting program."
exit 0
;;
*)
echo "Invalid option. Please choose a valid option."
;;
esac
done
fi
fi
if [[ $(uname) == "Darwin" ]]; then
source_file_url="https://raw.githubusercontent.com/felipealfonsog/TermNotes/main/src/term_notes_mac.c"
source_file_name="term_notes_mac.c"
elif [[ $(uname) == "Linux" ]]; then
source_file_url="https://raw.githubusercontent.com/felipealfonsog/TermNotes/main/src/term_notes_linux.c"
source_file_name="term_notes_linux.c"
else
echo "Unsupported operating system. Please install manually, read documentation, and re-run the installer."
exit 1
fi
curl -o "$source_file_name" "$source_file_url"
gcc -o term-notes "$source_file_name"
# curl -o term_notes.c https://raw.githubusercontent.com/felipealfonsog/TermNotes/main/src/term_notes.c
# gcc -o term-notes term_notes.c
if [[ $(uname) == "Darwin" ]]; then
sudo mv term-notes /usr/local/bin/
if [[ ! -x /usr/local/bin/term-notes ]]; then
sudo chmod +x /usr/local/bin/term-notes
fi
else
if [[ -f /etc/arch-release ]]; then
sudo mv term-notes /usr/bin/
elif [[ -f /etc/debian_version ]]; then
sudo mv term-notes /usr/local/bin/
else
sudo mv term-notes /usr/local/bin/
fi
if [[ -x /usr/bin/term-notes ]]; then
sudo chmod +x /usr/bin/term-notes
elif [[ -x /usr/local/bin/term-notes ]]; then
sudo chmod +x /usr/local/bin/term-notes
fi
fi
# rm -rf term_notes.c
rm -rf "$source_file_name"
echo "-------------------------------------------------------------------"
if [[ $(uname) == "Darwin" ]]; then
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
echo "Installation has been completed."
else
if [[ -f ~/.bashrc ]]; then
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
elif [[ -f ~/.bash_profile ]]; then
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
else
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.profile
source ~/.profile
fi
echo "Installation has been completed."
fi
reload_shell() {
if [[ $(uname) == "Darwin" ]]; then
source ~/.bash_profile
elif [[ $(uname) == "Linux" ]]; then
if [[ -f /etc/arch-release ]]; then
source ~/.bashrc
elif [[ -f /etc/debian_version ]]; then
source ~/.bashrc
else
source ~/.bashrc
fi
fi
}
reload_shell
echo "-------------------------------------------------------------------"
echo "You can now run the program by typing 'term-notes' in the terminal."
echo "-------------------------------------------------------------------"