-
Notifications
You must be signed in to change notification settings - Fork 8
/
global_function.sh
57 lines (53 loc) · 1.35 KB
/
global_function.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
# ----------------- FUNCTIONS -------------------
# Wait for user
function pause(){
read -p "$*"
}
# Returns get path from user
function getuserdir(){
local __resultvar=$1
local myresult=
while true ; do
read -r -p "Path: " myresult
if [ -d "$myresult" ] ; then
break
fi
echo "$myresult is not a directory... try without slash at the end (unless it's the root drive like C:/)"
done
eval $__resultvar="'$myresult'"
}
#Check the system :
function system_check(){
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Your OS: Linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Your OS: Mac OSX"
elif [[ "$OSTYPE" == "msys" ]]; then
echo "Your OS: Windows"
else
echo "Unknown OS, the script will exit: $OSTYPE"
pause "Press [Enter] to end the script"
exit 1 # We cannot proceed
fi
}
#function checkdir
function path_validation(){
if [ $# -eq 0 ]
then
echo ------- Installation path validation
system_check
echo "Please enter the installation path (windows: C:/, mac: /Applications/, Linux : /home/user/abba)"
echo "The directory must exist first"
getuserdir path_install
else
if [ -d "$1" ] ; then
path_install=$1
else
echo $1 is not a valid path
echo "Please enter the installation path for QuPath"
getuserdir path_install
fi
fi
echo "All components will be installed in:"
echo "$path_install"
}