-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathinstall.sh
executable file
·261 lines (242 loc) · 8.55 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
#!/bin/bash
# ===================================================
# Author: Lucas Rodrigues de Almeida, @propilideno |
# Description: OntoUML installation with bash script |
# ===================================================
# OS Defaults
OS=$(uname -s) # Gather OS Name
USER=$(whoami) # Gather USER Name
#OntoUML-Vp-Plugin Defaults
repoName="ontouml-vp-plugin"
repoUrl="https://github.com/propilideno/ontouml-vp-plugin/archive/refs/heads/master.zip"
ontoumlPluginPath="ontouml-vp-plugin-0.5.3"
# =========== 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
read_app_path(){
local currentPath="$1"
while true; do
echo "Visual Paradigm Path: $currentPath"
read -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y ) [[ -d "$currentPath" ]] && break || printf "<FOLDER NOT FOUND> Type a valid path!\n";;
n|N )
case "$OS" in
MINGW64*) currentPath=$(powershell -Command "(New-Object -ComObject Shell.Application).BrowseForFolder(0, 'Select the Visual Paradigm (APP FOLDER)', 0, 0).Self.Path");;
*) read -p "The path to your Visual Paradigm (APP FOLDER) is: " currentPath;;
esac
;;
* ) printf "Invalid input\n";;
esac
done
appDir="$currentPath"
}
read_plugin_path(){
local currentPath="$1"
while true; do
echo "Visual Paradigm Plugin Path: $currentPath"
read -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y )
if [ -d "$currentPath" ]; then
break
else
read -p "<FOLDER NOT FOUND> Do you want to create this folder (y/n)?: " choice
case "$choice" in
y|Y ) mkdir -p $currentPath && break;;
n|N ) ;;
* ) printf "Invalid input\n";;
esac
fi
;;
n|N )
case "$OS" in
MINGW64*) currentPath=$(powershell -Command "(New-Object -ComObject Shell.Application).BrowseForFolder(0, 'Select the Visual Paradigm (PLUGIN FOLDER)', 0, [System.Environment]::GetFolderPath('ApplicationData')).Self.Path");;
*) read -p "The path to your Visual Paradigm (PLUGIN FOLDER) is: " currentPath;;
esac
;;
* ) printf "Invalid input\n";;
esac
done
pluginDir="$currentPath"
}
get_vp_app_path(){
case "$OS" in
Linux*)
read_app_path "$VISUAL_PARADIGM_APP_DIR_LINUX"
;;
Darwin*)
read_app_path "$VISUAL_PARADIGM_APP_DIR_MAC"
;;
MINGW64*)
read_app_path "$VISUAL_PARADIGM_APP_DIR_WINDOWS"
appDir=$(echo "$appDir" | sed 's/\\/\\\\/g')
;;
*)
echo "Operating System not Supported"
exit 1
esac
}
get_vp_plugin_path(){
case "$OS" in
Linux*)
read_plugin_path "$VISUAL_PARADIGM_PLUGIN_DIR_LINUX"
;;
Darwin*)
read_plugin_path "$VISUAL_PARADIGM_PLUGIN_DIR_MAC"
;;
MINGW64*)
read_plugin_path "$VISUAL_PARADIGM_PLUGIN_DIR_WINDOWS"
pluginDir=$(echo "$pluginDir" | sed 's/\\/\\\\/g')
;;
*)
echo "Operating System not Supported"
exit 1
esac
}
download_plugin(){
echo "Downloading OntoUML VP Plugin Repository ..."
case "$(basename $(pwd))" in
$repoName*) # Case ontouml-vp-plugin or ontouml-vp-plugin-master
echo "OntoUML Repository already downloaded, running the script ..."
;;
*)
echo "Downloading the OntoUML Repository ..."
rm -rf $repoName-master
curl -sL $repoUrl -o master-ontouml-temp.zip
unzip master-ontouml-temp.zip
rm -rf master-ontouml-temp.zip
cd $repoName-master
esac
}
# If the install fails, then print an error and exit.
install_fail() {
echo "<FAIL> Installation failed"
exit 1
}
# This is the help fuction. It helps users withe the options
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"
}
install_jdk(){
if command -v javac &> /dev/null; then
echo "<PRESENT> JDK already installed."
else
echo "<MISSING> You're missing JDK"
case "$OS" in
Linux*)
sudo apt-get install default-jdk
;;
Darwin*)
brew install java
;;
MINGW64*)
local LINK="https://www.oracle.com/java/technologies/downloads/"
echo "JDK automatic installion is not supported by Windows yet."
echo "Install JDK, restart your Git Bash and try it again ..."
start $LINK
exit 1
;;
*)
echo "<FAIL> Operating System not Supported"
exit 1
esac
fi
}
install_ontouml_vp_plugin(){
# Get the paths to write on pom.xml
get_vp_app_path
get_vp_plugin_path
if [ -d "$pluginDir$ontoumlPluginPath" ]; then
echo "<WARNING> ONTOUML 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 -->|$appDir|g" pom.xml # '' Before the regex is to prevent ISSUE on MacOS.
sed -i '' "s|<!-- PLUGIN_PATH -->|$pluginDir|g" pom.xml # '' Before the regex is to prevent ISSUE on MacOS
;;
*)
sed -i "s|<!-- APP_PATH -->|$appDir|g" pom.xml
sed -i "s|<!-- PLUGIN_PATH -->|$pluginDir|g" pom.xml
esac
# Install plugin with Maven Wrapper
./mvnw install
}
install_visual_paradigm(){ #Development
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
}
# to install for debian based distrOS (and ubuntu)
install_shell_deps(){
case "$OS" in
Linux*)
if ! command -v unzip &> /dev/null; then
sudo apt-get install unzip
fi
;;
*)
echo "No shell requirements for your OS"
esac
}
clean_installation(){
while true; do
printf "\nDo you want to clean installation files?\n"
read -p "Confirm (y/n)?: " choice
case "$choice" in
y|Y )
case "$(basename $(pwd))" in
$repoName*) # Case ontouml-vp-plugin or ontouml-vp-plugin-master
echo "Cleaning temporary files, downloads, zips and ontouml-vp-plugin installation ..."
cd ..
rm -rf $repoName-master
break;
;;
esac
;;
n|N ) break;;
* ) printf "Invalid input\n"
esac
done
}
greetings(){
printf "\n\n==> OntoUML was installed with SUCCESS !!!\n"
echo "==> Contribute with us giving this repo a Star ⭐"
exit 1
}
# Main function
install_main(){
echo "=== OntoUML-vp-plugin Installer ==="
echo "Installing shell dependencies ..."
install_shell_deps || install_fail
echo "Installing plugin dependencies ..."
install_jdk || install_fail
#install_visual_paradigm || install_fail
# Download the ontouml-vp-plugin repository
download_plugin || install_fail
echo "Installing ontouml-vp-plugin..."
install_ontouml_vp_plugin || install_fail
# Cleaning installation
clean_installation
# Run the greetings by using OntoUML
greetings
}
# Run the main function
install_main