-
Notifications
You must be signed in to change notification settings - Fork 2
/
dispatcher
executable file
·103 lines (88 loc) · 2.65 KB
/
dispatcher
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
#!/bin/bash
#author : Umar aka jukoo <[email protected]>
#This script for mac and gnu/linux Operating system
#YOU NEED TO EXECUTE THIS AS ROOT CHEF
set -o errexit
declare -a mains_srcipts
declare -r dns_test="one.one.one.one"
declare -r src="scripts/"
declare -r remote_repo_url="https://raw.githubusercontent.com/avalanche-org/Gen_Assoc/master/${src}"
declare -r ubin="/usr/bin/"
declare -r defC="\033[0m"
declare -r rootuid=$((0x00))
[[ ${rootuid} -ne ${UID} ]] && {
echo -e "Sorry !! you need to be root to proceed "
exit ${UID}
}
mains_srcipts=(
"mtdt.R"
"summary.R"
"run_analysis.R"
)
has_command () {
local is_define=`command -v $1`
[[ -n ${is_define} ]] && {
return $((0x00))
} || {
echo -e "\033[1;33m Warrning on line $LINENO : this $1 command is not available in your system\033[0m"
return $((0x001))
}
}
is_internet_available () {
has_command wget
echo -e "... testing connexion"
`wget -q --spider ${dns_test}`
test $? -eq 0 && {
echo -e "Online !"
return $?
}||{
echo -e "Offline mode "
return $?
}
}
automove () {
local path
[[ -n $1 ]] && path=$1 || path=""
for script in ${mains_srcipts[@]} ; do
[[ -f ${path}${script} ]] && {
echo -e "moving ${path}${script} \t -> ${ubin}"
`chmod +x ${path}${script}`
sleep 0.3
if [[ -n ${path} ]] ; then
`cp ${path}${script} ${ubin}`
else
`mv ${path}${script} ${ubin}`
fi
test $? -eq 0 || echo -e "fail to move no root permission !! "
}|| echo -e "not found"
done
}
download_srcipts () {
has_command wget
case $1 in
"--remote")
is_internet_available
test $? -eq 0 || {
echo -e "require internet unless you found script folder in path system "
exit $?
}
for script in ${mains_srcipts[@]} ;do
echo -e "\033[1;34m + Dowloading $script from source$defC"
`wget ${remote_repo_url}${script} --quiet`
test $? -ne 0 && {
echo -e "-\033[1;31m fail to download $script $defC"
}||{
echo -e "-\033[1;32m $script [ downloaded ] $defC"
}
done
automove
;;
*)
automove $src
esac
}
if [[ -n $1 ]] ;then
download_srcipts $1
else
download_srcipts
fi