-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute_cmd
executable file
·109 lines (100 loc) · 2.38 KB
/
execute_cmd
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
#!/bin/bash
EXECCMD_VERSION="0.1"
CONFIGFILE=""
HELPEXIT="no"
VERSIONEXIT="no"
while [ "$1" ]
do
case "$1" in
"--config")
shift
CONFIGFILE="$1"
;;
"--help")
HELPEXIT="yes"
;;
"--version")
VERSIONEXIT="yes"
;;
"--")
shift
break
;;
*)
break
;;
esac
shift
done
if [ "$CONFIGFILE" ]
then
if [ -f "$CONFIGFILE" ]
then
. $CONFIGFILE
else
echo "No config file $CONFIGFILE found, terminating."
exit 16
fi
else
[ -f "/etc/rumia.conf" ] && . /etc/rumia.conf
[ -f "~/.config/rumia.conf" ] && . ~/.config/rumia.conf
[ -f "~/.rumiarc" ] && . ~/.rumiarc
[ -f "./rumia.conf" ] && . ./rumia.conf
fi
if [ -z "$PREFIX" ]
then
echo "No PREFIX variable defined, terminating. Maybe there's no configs at all?"
exit 17
fi
LANGFILE="$PREFIX/language.$RUMIA_LANG"
if [ ! -f $LANGFILE ]
then
echo "No language file $LANGFILE found, terminating."
exit 15
fi
. $LANGFILE
if [ "$HELPEXIT" = "yes" ]
then
echo "$MSG_EXECCMDHELP_0"
echo "$MSG_EXECCMDHELP_1"
echo "$MSG_EXECCMDHELP_2"
echo "$MSG_EXECCMDHELP_3"
echo "$MSG_EXECCMDHELP_4"
echo "$MSG_EXECCMDHELP_5"
echo "$MSG_EXECCMDHELP_6"
echo "$MSG_EXECCMDHELP_7"
echo "$MSG_EXECCMDHELP_8"
exit 0
fi
if [ "$VERSIONEXIT" = "yes" ]
then
echo "${MSG_EXECCMDVERS_0}${EXECCMD_VERSION}${MSG_EXECCMDVERS_1}"
exit 0
fi
echo -e "${MSG_RUNNINGHDR_0}$@${MSG_RUNNINGHDR_1}"
for SCRIPTDIR in `ls $COMPUTERS_D`
do
export SCRIPTPATH=$COMPUTERS_D/$SCRIPTDIR
export MACHINE=`echo $SCRIPTDIR | sed 's/[0-9][0-9]-//'`
if [ "$MACHINE" ]
then
if [ "$MACHINES" ]
then
echo " $MACHINES " | grep -qv [[:space:]]$MACHINE[[:space:]] && continue
fi
if [ -e $SCRIPTPATH/$SMARKER ]
then
echo -ne "\n${MSG_CHECKINGMACH_0}${MACHINE}${MSG_CHECKINGMACH_1}"
if $SCRIPTPATH/ping_cmd
then
echo -e "\r${MSG_RUNNINGMACH_0}${MACHINE}${MSG_RUNNINGMACH_1}"
`$SCRIPTPATH/ssh_cmd -- "$@"`
else
echo -e "\r${MSG_SLEEPINGMACH_0}${MACHINE}${MSG_SLEEPINGMACH_1}"
fi
else
echo -e "\r${MSG_SKIPPINGMACH_0}${MACHINE}${MSG_SKIPPINGMACH_1}"
fi
fi
done
echo