blob: 24c5f9dc36a2b7ddfa673c86025287fa8597b48d (
plain)
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
|
#!/bin/bash
set -e
set -x
stages="$@"
if [ "x$stages" = "x" ]; then
stages="install prepare build run result"
fi
if [ "x$HOST" = "x" ]; then
echo "\$HOST is not set"
exit 1
fi
if [ "x$TARGET" = "x" ]; then
echo "\$TARGET is not set"
exit 1
fi
if [ "x$SPEC" = "x" ]; then
echo "\$SPEC is not set"
exit 1
fi
host=$HOST
target=$TARGET
spec=$SPEC
if [ "$host" != "$target" ]; then
local=false
else
local=true
fi
if ssh $target echo \$USER | grep root; then
sudo=
else
sudo=sudo
fi
ssh $target true
if [ "$(ssh $target echo \$SHELL)" != "/bin/bash" ]; then
echo "$target is using non-bash shell"
exit 1
fi
mkdir -p $spec
spec=$(cd $spec; pwd)
ssh $target mkdir -p $spec
$local || sshfs $target:$spec $spec
tmp=$(mktemp $spec/tmp.XXXXX)
$local || fusermount -uz $spec
ssh $target rm $tmp
case "$stages" in
*"prepare"*|*"build"*|*"run"*)
if [ "x$CONFIG" = "x" ]; then
echo "\$CONFIG is not set"
exit 1
fi
;;
esac
case "$stages" in
*"build"*)
ssh $target ssh $host true
;;
esac
case "$stages" in
*"install"*|*"build"*)
d1=$(ssh $target date +%s)
d2=$(date +%s)
if [ "$(echo "($d2 - $d1) > 10 || ($d1 - $d2) > 10" | bc)" != "0" ]; then
echo "Time difference between $host and $target is more than 10 seconds"
ssh $target $sudo date -s "$(date)"
fi
esac
|