-
Notifications
You must be signed in to change notification settings - Fork 1
/
dispatcher
executable file
·157 lines (132 loc) · 4.2 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
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
#!/bin/bash
# Dispatch files in the system
set -o errexit
#set -x DEBUG #uncomment to activate debug mode
readonly PN=$(basename ${0^^}) ;
readonly RootUID=$((0x000))
readonly user_name=`logname`
readonly f_source=CovSurvey
readonly covconf=covset.cfg
readonly conkyrc=.conkyrc
readonly Dconky=conky.desktop
readonly exe=CovSurvey
declare -A sysF=(
["conf"]=/etc/covid/
["exec"]=/usr/bin/
["D_location"]=${HOME}/.config/autostart/
)
if [[ -n $1 ]] ; then
case $1 in
"clean")
sudo rm -r ${sysF["conf"]}
test $? -eq 0 && {
rm ${sysF["exec"]}${f_source}
}|| {
echo "|~> Failed to clean conf dir"
exit 2
}
echo "clean"
exit 0
;;
esac
fi
if [[ -f ${conkyrc} ]] ; then
echo "|-> creating conkyrc file ..."
cp ${conkyrc} ${HOME}
[[ -f ${HOME}/${conkyrc} ]] && {
echo "|=-> [ conky set ]"
echo "[bootstrapping desktop applet ]"
cp ${Dconky} ${sysF["D_location"]}
test $? -eq 0 && {
echo "|-> Applet OK "
} || {
echo "Failed : Autostart Applet launcher broken"
exit 3
}
}||{
echo "|~> Failed : require cOnkYrc file "
exit 3
}
fi
[[ "root permission" ]]
{
[[ ${UID} -ne ${RootUID} ]] && {
echo -e " require root user ..."
read -p "root password: " -s -t $((0x000F))
if [[ -n ${REPLY} ]] ; then
sudo -s <<< ${REPLY} ./${PN,,}
test $? -eq 0 || {
echo -e "ROAuth failed"
exit 3
}
else
exit 3
fi
}
}
sed -n 4,8p ${f_source}
echo -e "|-> [COVID-19] inflating logical conf directory ..."
sleep $((0x0002))
default_source () {
local root_dir=${sysF["conf"]}
if [[ ! -d $root_dir ]] ; then
mkdir $root_dir
[[ $? -ne 0 ]] && {
echo -e "failed ... "
exit 3
}||{
return 0
}
else
echo "|-> [COVID-19] nothing to do evrything is oOK ..."
exit 0
fi
}
default_source
test $? -eq 0 && {
echo "|-> [COVID-19] Injecting DNA proteine -> ${sysF["conf"]}"
sleep $((0x0002))
if [[ -f ${f_source} ]] ; then
cp ${f_source} ${sysF["exec"]}
test $? -eq 0 && {
echo -n "|-> [COVID-19] Mutation "
if [[ -f ${covconf} ]] ; then
conf=${sysF["conf"]}
sed -i "s/${covconf}/\\/etc\\/covid\\/${covconf}/g" ${sysF["exec"]}${f_source}
test $? -eq 0 && {
echo "|-> [ Done ]"
echo "|-> "
cp ${covconf} ${sysF["conf"]}
[[ $? -eq $((0x000)) ]] && {
echo "|-> [COVID-19] Adaptation ..."
`chown ${user_name} ${sysF["exec"]}${f_source}`
`chown ${user_name} ${sysF["conf"]}${covconf}`
[[ -x ${sysF["exec"]}python3 ]] && {
python3 $exe
} || {
echo "require python3 to launch" ; exit 2
}
sleep 3
if [[ -x ${sysF["exec"]}conky ]] ;then
conky
[[ $? -eq 0 ]] && {
echo "|-> Conky is launched"
}
else
echo "|~> it seem conky was not found ..."
fi
}
}
else
echo "|~> fail to found config file ... "
exit 3
fi
echo -e "[ done ]"
}
else
echo -e "|-> something wrong : missing file "
echo -e "|-> please report this error to - > <[email protected]>"
echo -e "|-> or declare an issue to - > <https://github.com/Jukoo/CovidWidget>"
exit 3
fi
}