Commit
·
25cb3f2
1
Parent(s):
79455e7
Add jug_exec util
Browse files- scripts/jug_exec.py +17 -0
- scripts/utils.sh +29 -0
scripts/jug_exec.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
from jug import is_jug_running
|
3 |
+
|
4 |
+
if is_jug_running():
|
5 |
+
from sys import argv
|
6 |
+
from jug.utils import jug_execute
|
7 |
+
jug_execute(argv[1:])
|
8 |
+
else:
|
9 |
+
from sys import argv
|
10 |
+
from jug.jug import main
|
11 |
+
try:
|
12 |
+
# Split and reorder jug's argv from script's argv
|
13 |
+
argv[:] = ["jug", "execute"] + argv[1:argv.index("--")] + \
|
14 |
+
[__file__] + argv[argv.index("--"):]
|
15 |
+
except ValueError:
|
16 |
+
argv[:] = ["jug", "execute", __file__] + argv[1:]
|
17 |
+
main(argv)
|
scripts/utils.sh
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
#!/bin/bash
|
2 |
|
|
|
|
|
|
|
|
|
3 |
function exit_on_error_code {
|
4 |
local _ERR=$?
|
5 |
if [[ ${_ERR} -ne 0 ]]
|
@@ -300,6 +304,31 @@ function unshare_mount {
|
|
300 |
unshare -U ${SHELL} -s "$@" <&0
|
301 |
}
|
302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
# function unshare_mount {
|
304 |
# if [[ ${EUID} -ne 0 ]]
|
305 |
# then
|
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
+
pushd `dirname "${BASH_SOURCE[0]}"` >/dev/null
|
4 |
+
_SCRIPT_DIR=`pwd -P`
|
5 |
+
popd >/dev/null
|
6 |
+
|
7 |
function exit_on_error_code {
|
8 |
local _ERR=$?
|
9 |
if [[ ${_ERR} -ne 0 ]]
|
|
|
304 |
unshare -U ${SHELL} -s "$@" <&0
|
305 |
}
|
306 |
|
307 |
+
function jug_exec {
|
308 |
+
if [[ -z ${_jug_exec} ]]
|
309 |
+
then
|
310 |
+
local _jug_exec=${_SCRIPT_DIR}/jug_exec.py
|
311 |
+
fi
|
312 |
+
local _jug_argv=()
|
313 |
+
while [[ $# -gt 0 ]]
|
314 |
+
do
|
315 |
+
local _arg="$1"; shift
|
316 |
+
case "${_arg}" in
|
317 |
+
--script | -s) local _jug_exec="$1"; shift ;;
|
318 |
+
-h | --help)
|
319 |
+
>&2 echo "Options for ${FUNCNAME[0]} are:"
|
320 |
+
>&2 echo "[--script | -s JUG_EXEC] path to the jug wrapper script (default: '${_jug_exec}')"
|
321 |
+
${_jug_exec} --help
|
322 |
+
exit
|
323 |
+
;;
|
324 |
+
--) break ;;
|
325 |
+
*) _jug_argv+=("${_arg}") ;;
|
326 |
+
esac
|
327 |
+
done
|
328 |
+
# Remove trailing '/' in argv before sending to jug
|
329 |
+
jug execute "${_jug_argv[@]%/}" ${_jug_exec} -- "${@%/}"
|
330 |
+
}
|
331 |
+
|
332 |
# function unshare_mount {
|
333 |
# if [[ ${EUID} -ne 0 ]]
|
334 |
# then
|