From 64436d5d6ae8153c99c2e79a2522402fe34140ed Mon Sep 17 00:00:00 2001 From: Fenris Wolf Date: Tue, 31 Mar 2026 21:41:00 +0200 Subject: [PATCH] [mod] tools:deploy --- tools/deploy | 68 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/tools/deploy b/tools/deploy index 2f641af..e0b5daa 100755 --- a/tools/deploy +++ b/tools/deploy @@ -1,19 +1,59 @@ -#!/usr/bin/env sh +#!/usr/bin/env python3 -## args - -if [ $# -ge 1 ] ; then target_ssh_handle=$1 && shift ; else target_ssh_handle="gs-monitoring" ; fi +import sys as _sys +import os as _os +import argparse as _argparse -## exec +def main(): + ## args + argument_parser = _argparse.ArgumentParser() + argument_parser.add_argument( + type = str, + dest = "target_system", + metavar = "", + help = "either 'localhost' or SSH handle of the target system", + ) + argument_parser.add_argument( + "-t", + "--target-directory", + type = str, + dest = "target_directory", + default = "/opt/heimdall", + metavar = "", + help = "directory on the target system, where the files shall be put; default: /opt/heimdall", + ) + argument_parser.add_argument( + "-b", + "--build-directory", + type = str, + dest = "build_directory", + default = "/tmp/heimdall", + metavar = "", + help = "directory to where the build was put", + ) + args = argument_parser.parse_args() + + ## 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", + ("%s/" % args.build_directory), + ( + ("%s" % args.target_directory) + if (args.target_system == "localhost") else + ("%s:%s" % (args.target_system, args.target_directory, )) + ), + ]) + ) + -rsync \ - --rsh=ssh \ - --recursive \ - --update \ - --delete \ - --exclude 'node_modules' \ - --verbose \ - build/ \ - ${target_ssh_handle}:/opt/heimdall +main()