-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatecore.sh
executable file
·57 lines (35 loc) · 1.01 KB
/
createcore.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
#!/bin/bash
PREFIX=$(dirname $0)
if [ ! -e $PREFIX'/sdi.conf' ]; then
echo "ERROR: The $PREFIX/sdi.conf file does not exist or can not be accessed"
exit 1
fi
source $PREFIX'/sdi.conf'
#test if config is loaded
if test $? != 0; then
echo "ERROR: failed to load $PREFIX/sdi.conf file"
exit 1
fi
enviacore(){
for HOST in $*; do
printf "coresdi->$HOST\n"
scp -r -q -o StrictHostKeyChecking=no $PREFIX"/coresdi-client" $HOST:/
sleep 0.5
done
}
CLASSES=$(ls $CLASSESDIR)
CLASSESNUM=$(ls $CLASSESDIR | wc -l)
printf "\nSending core to clients..."
COUNT=0
for CLASS in $CLASSES; do
((COUNT++))
HOSTS=$(awk -F':' '{print $1}' $CLASSESDIR/$CLASS)
enviacore $HOSTS
done
printf "done\n"
printf "Setando permissoes de execucao do core..."
echo "chmod -R 777 /coresdi-client/" >> $PREFIX"/cmds/general"
printf "done\n"
printf "Sending commands to iniciatialize cron jobs..."
echo "bash /coresdi-client/enablecron.sh" >> $PREFIX"/cmds/general"
printf "done\n"