-
Notifications
You must be signed in to change notification settings - Fork 3
/
nginx-remote-check.sh
executable file
·44 lines (40 loc) · 1.03 KB
/
nginx-remote-check.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
#!/bin/sh
#!/bin/bash
basedir=$(dirname $(readlink -f $0))
keyfile=${basedir}/remote-ssh-key
logfile=${basedir}/run.txt
remote="localhost" #"[email protected]"
remote_port=22
verbose=
if [ "$1" = "-v" ] ; then
verbose=1
shift
fi
if [ -z "$1" ] ; then
echo "Usage: $0 COMMAND ARG..."
exit 1
fi
set -e -u
if [ -x "$1" ] ; then
if [ -n "$verbose" ] ; then
echo "Copying $1 to $remote" >&2
else
echo "$(date) Copying $1 to $remote" >> ${logfile}
fi
scp -P ${remote_port} -q -i ${keyfile} "$1" ${remote}:/tmp
remotename="/tmp/$(basename $1)"
shift
if [ -n "$verbose" ] ; then
echo "Running remotely: ${remotename} $@" >&2
else
echo "$(date) Running remotely: ${remotename} $@" >> ${logfile}
fi
ssh -p ${remote_port} -q -i ${keyfile} ${remote} "${remotename} $@"
else
if [ -n "$verbose" ] ; then
echo "Running remotely: $@" >&2
else
echo "$(date) Running remotely: $@" >> ${logfile}
fi
ssh -p ${remote_port} -q -i ${keyfile} ${remote} "$@"
fi