projects
/
xremote.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8421029
)
Added the -i option, changed the name of the temporary remote dir to include the...
author
Francois Fleuret
<francois@fleuret.org>
Tue, 14 Aug 2018 05:57:34 +0000
(07:57 +0200)
committer
Francois Fleuret
<francois@fleuret.org>
Tue, 14 Aug 2018 05:57:34 +0000
(07:57 +0200)
xremote.sh
patch
|
blob
|
history
diff --git
a/xremote.sh
b/xremote.sh
index
7556470
..
9752a9a
100755
(executable)
--- a/
xremote.sh
+++ b/
xremote.sh
@@
-35,7
+35,7
@@
function check_remote_is_defined () {
function help () {
cat <<EOF
function help () {
cat <<EOF
-xremote.sh [-h
remote_host
] <script> [script arguments]
+xremote.sh [-h
<remote_host>] [-i <remote_dir>
] <script> [script arguments]
This script takes a script as argument and executes it remotely in a
temporary directory on a ssh-accessible server.
This script takes a script as argument and executes it remotely in a
temporary directory on a ssh-accessible server.
@@
-58,6
+58,10
@@
xremote.sh [-h remote_host] <script> [script arguments]
If the -h option is provided @XREMOTE_HOST is ignored.
If the -h option is provided @XREMOTE_HOST is ignored.
+ If the -i option is provided, all the files are installed and
+ scripts run in the specified directory on the remote host, but the
+ main executable and post-run commands are ignored
+
If no argument is provided to @XREMOTE_HOST, and the -h option is
not specified, the environment variable \$XREMOTE_HOST is used
instead
If no argument is provided to @XREMOTE_HOST, and the -h option is
not specified, the environment variable \$XREMOTE_HOST is used
instead
@@
-69,10
+73,9
@@
EOF
}
function cleanup_remote_tmp () {
}
function cleanup_remote_tmp () {
- if [[ "${REMOTE_HOST}" ]] && [[ "${REMOTE_DIR}" ]]
+ if [[ "${REMOTE_HOST}" ]] && [[ "${REMOTE_DIR}" ]]
&& [[ ! "${ARG_DIR}" ]]
then
echo "xremote: Clean up remote workdir."
then
echo "xremote: Clean up remote workdir."
- ssh "${REMOTE_HOST}" "rm -rf \"${REMOTE_DIR}\""
fi
}
fi
}
@@
-87,6
+90,13
@@
do
ARG_HOST="$1"
echo "xremote: remote forced to ${ARG_HOST}"
;;
ARG_HOST="$1"
echo "xremote: remote forced to ${ARG_HOST}"
;;
+
+ -i)
+ shift
+ ARG_DIR="$1"
+ echo "xremote: remote dir set to ${ARG_DIR}"
+ ;;
+
*)
echo "Unknown option $1"
exit 1
*)
echo "Unknown option $1"
exit 1
@@
-144,7
+154,13
@@
do
[[ "${REMOTE_HOST}" ]] || REMOTE_HOST="${value}"
[[ "${REMOTE_HOST}" ]] || REMOTE_HOST="${XREMOTE_HOST}"
[[ "${REMOTE_HOST}" ]] || (echo "xremote: No remote host specified." >&2 && exit 1)
[[ "${REMOTE_HOST}" ]] || REMOTE_HOST="${value}"
[[ "${REMOTE_HOST}" ]] || REMOTE_HOST="${XREMOTE_HOST}"
[[ "${REMOTE_HOST}" ]] || (echo "xremote: No remote host specified." >&2 && exit 1)
- REMOTE_DIR="$(ssh </dev/null "${REMOTE_HOST}" mktemp -d /tmp/xremote.from_"$(hostname)_$(date +%Y%m%d-%H%M%S)".XXXXXX)"
+ if [[ "${ARG_DIR}" ]]
+ then
+ ssh </dev/null "${REMOTE_HOST}" "mkdir -p \"${ARG_DIR}\""
+ REMOTE_DIR="${ARG_DIR}"
+ else
+ REMOTE_DIR="$(ssh </dev/null "${REMOTE_HOST}" mktemp -d /tmp/xremote_\$\(whoami\)_from_"$(hostname)_$(date +%Y%m%d_%H%M%S)".XXXXXX)"
+ fi
echo "xremote: target is ${REMOTE_HOST}"
;;
esac
echo "xremote: target is ${REMOTE_HOST}"
;;
esac
@@
-158,6
+174,12
@@
check_remote_is_defined
tar c "${main}" | ssh "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && tar mx"
tar c "${main}" | ssh "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && tar mx"
+if [[ "${ARG_DIR}" ]]
+then
+ echo "xremote: everything has been set up in ${REMOTE_HOST}:${ARG_DIR}"
+ exit 0
+fi
+
echo "xremote: -- running the executable -----------------------------------"
if [[ "${REMOTE_EXEC}" ]]
echo "xremote: -- running the executable -----------------------------------"
if [[ "${REMOTE_EXEC}" ]]