From 2d8e14d2f89db5f9c98e43ca9719e701107ff9d2 Mon Sep 17 00:00:00 2001 From: LinuxSquare Date: Sat, 20 Apr 2024 20:38:56 +0200 Subject: [PATCH] add config --- .gitignore | 1 + config.json | 6 ++++++ repo-mgmt | 37 +++++++++++-------------------------- 3 files changed, 18 insertions(+), 26 deletions(-) create mode 100644 config.json diff --git a/.gitignore b/.gitignore index 4a8d0a6..4a6a450 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ keys/ repo/ build/ *.list +config_test.json diff --git a/config.json b/config.json new file mode 100644 index 0000000..6ee9198 --- /dev/null +++ b/config.json @@ -0,0 +1,6 @@ +{ + "remote_user": "", + "remote_server": "", + "remote_path": "", + "ssh_priv_key_path": "" +} diff --git a/repo-mgmt b/repo-mgmt index 8094980..1fae077 100755 --- a/repo-mgmt +++ b/repo-mgmt @@ -4,6 +4,7 @@ readonly PODMAN_IMAGE="noveria:alpine-repo" readonly ROOT_DIR="$(dirname $(readlink -f $(which ${0})))" readonly PODMAN_IMAGE_DIR="${ROOT_DIR}/image" +readonly CONFIG="/etc/repo-mgmt/config.json" readonly KEYS_DIR="${ROOT_DIR}/keys" readonly REPO_DIR="${ROOT_DIR}/repo" readonly BUILD_DIR="${ROOT_DIR}/build" @@ -22,30 +23,6 @@ readonly APKBUILD_GIT_REPO_BASE="https://git.noveria.org/APKBUILD" # Miscellaneous functions ## -function usage() { - echo -e "Noveria Alpine Linux repository build management - -Usage: $(basename $0) [...] - -Operations: - Miscellaneous: - -h, --help Usage information - -p, --publish Publish files to webserver (not yet implemented) - --debug Start debug-container bash shell - --init Initialize local directories & abuild keys - - Podman: - -b, --build (Re)build podman image - - DB management: - -d, --delete Delete package - -r, --refresh Refresh APKINDEX with packages in repo - -s, --sign Sign APKINDEX with abuild private key - - Package management: - -k, --apkbuild Build binary package from APKBUILD and move to, refresh and sign local repository -" -} function init_local() { if [[ ! -d "${BUILD_DIR}" || ! -d "${REPO_DIR}" || ! -d "${KEYS_DIR}" || ! -f "${PKG_LIST_FILE}" ]]; then @@ -177,8 +154,16 @@ function delete_pkg_from_repo() { } function publish_repo() { - message_blue_double_colon "Publishing files to remote webserver" - message_error "Not yet implemented" + if [[ -z $(jq -r '.remote_user' $CONFIG) || -z $(jq -r '.remote_server' $CONFIG) || -z $(jq -r '.remote_path' $CONFIG) || -z $(jq -r '.ssh_priv_key_path' $CONFIG) ]]; then + message_error "Config is incomplete. Please fill out first!" + fi + local remote_user="$(jq -r '.remote_user' $CONFIG)" + local remote_server="$(jq -r '.remote_server' $CONFIG)" + local remote_path="$(jq -r '.remote_path' $CONFIG)" + local ssh_priv_key_path="$(jq -r '.ssh_priv_key_path' $CONFIG)" + + message_blue_double_colon "Publishing files to remote webserver: ${remote_user}@${remote_server}:${remote_path}/" + rsync -a --delete --progress --rsync-path="mkdir -p ${remote_path} && rsync" "${REPO_DIR}/" "${remote_user}@${remote_server}:${remote_path}" } ##