-
Notifications
You must be signed in to change notification settings - Fork 2
/
ctimer_remote
executable file
·48 lines (39 loc) · 1.24 KB
/
ctimer_remote
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
#!/usr/bin/env bash
# Fetch ctimer json output over ssh, presuming list of site names in text file or as arguments
# (and sites in .ssh/config - see https://github.com/zone-eu/zone-docs/blob/master/articles/eng/SSH-config-and-fs-from-zone-api.md)
# Note: remote base directory is specific to zone.eu
#set -x
# list of hosts to scan
hosts="$HOME/.ssh/zonetech.hosts"
if [ $# == 0 ] && [ ! -f "${hosts}" ]; then
echo "Please provide list of sites in ${hosts} or as command line arguments."
exit 1
fi
function remote_ctimer() {
echo "Doing ${host} ..."
ssh "$host" "\
mkdir -p ~/bin \
&& wget -q https://raw.githubusercontent.com/zone-eu/ctimer/master/ctimer.php -O ~/bin/ctimer.php \
&& chmod +x ~/bin/ctimer.php \
&& cd ~/domeenid/www.${host} \
&& /usr/bin/env php ~/bin/ctimer.php . ${host} echo ${cognizant} \
&& rm -f ~/bin/ctimer.php \
" >"${host}_$(date +%Y-%m-%d_%H-%M)_ctimer.json"
}
if [ $# -gt 0 ]; then
# process sites provided as arguments
if [ "$1" == "cognizant" ]; then
cognizant="cognizant"
shift
fi
for i; do
host="$i"
remote_ctimer
done
else
# process sites from file
while read -u 10 host; do
remote_ctimer
done 10<"${hosts}"
# (using separate handle to avoid commands messing up our input)
fi