[mod] tools:deploy
This commit is contained in:
parent
7010897ad1
commit
a28c715c15
1 changed files with 55 additions and 23 deletions
74
tools/deploy
74
tools/deploy
|
@ -1,27 +1,59 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env python3
|
||||
|
||||
## functions
|
||||
|
||||
function syntaxerror
|
||||
{
|
||||
echo "SYNTAX: deploy <target-sys> <target-dir>" > /dev/stderr
|
||||
exit 1
|
||||
}
|
||||
import sys as _sys
|
||||
import os as _os
|
||||
import argparse as _argparse
|
||||
|
||||
|
||||
## args
|
||||
def main():
|
||||
## args
|
||||
argument_parser = _argparse.ArgumentParser()
|
||||
argument_parser.add_argument(
|
||||
type = str,
|
||||
dest = "target_system",
|
||||
metavar = "<target-system>",
|
||||
help = "either 'localhost' or SSH handle of the target system",
|
||||
)
|
||||
argument_parser.add_argument(
|
||||
"-t",
|
||||
"--target-directory",
|
||||
type = str,
|
||||
dest = "target_directory",
|
||||
default = "/opt/espe",
|
||||
metavar = "<target-directory>",
|
||||
help = "directory on the target system, where the files shall be put; default: /opt/espe",
|
||||
)
|
||||
argument_parser.add_argument(
|
||||
"-b",
|
||||
"--build-directory",
|
||||
type = str,
|
||||
dest = "build_directory",
|
||||
default = "build",
|
||||
metavar = "<build-directory>",
|
||||
help = "directory to where the build was put",
|
||||
)
|
||||
args = argument_parser.parse_args()
|
||||
|
||||
if [ $# -ge 1 ] ; then target_sys=$1 && shift ; else syntaxerror ; fi
|
||||
if [ $# -ge 1 ] ; then target_dir=$1 && shift ; else syntaxerror ; fi
|
||||
## exec
|
||||
if (not _os.path.exists(args.build_directory)):
|
||||
_sys.stderr.write("-- build directory not found; probably you need to run /tools/build\n")
|
||||
_sys.exit(1)
|
||||
else:
|
||||
_os.system(
|
||||
" ".join([
|
||||
"rsync",
|
||||
"--recursive",
|
||||
"--update",
|
||||
"--verbose",
|
||||
"--exclude='conf.json'",
|
||||
("%s/" % args.build_directory),
|
||||
(
|
||||
("%s" % args.target_directory)
|
||||
if (args.target_system == "localhost") else
|
||||
("%s:%s" % (args.target_system, args.target_directory, ))
|
||||
),
|
||||
])
|
||||
)
|
||||
|
||||
|
||||
## exec
|
||||
|
||||
rsync \
|
||||
--rsh=ssh \
|
||||
--recursive \
|
||||
--update \
|
||||
--delete \
|
||||
--exclude="conf.json" \
|
||||
build/ \
|
||||
${target_sys}:${target_dir}
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue