From ab1a57739ec7d837f093048133c47110a7ba5179 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 4 Jul 2025 15:24:42 +0900 Subject: [PATCH] Rename git_pull to git_sync, update Readme file --- ReadMe.md | 51 ++++++++++++++++++++++++++-- src/bin/base_setup.sh | 12 +++---- src/bin/{git_pull.sh => git_sync.sh} | 0 3 files changed, 55 insertions(+), 8 deletions(-) rename src/bin/{git_pull.sh => git_sync.sh} (100%) diff --git a/ReadMe.md b/ReadMe.md index dc88a71..ed0bae0 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -6,8 +6,55 @@ the clone base for one campaign and a simple crontab script to pull data from th ## Scripts - base_setup.sh: setup for the folder structure, users, etc -- init_new_clone.sh: Basic clone script -- git_pull.sh: The script to run in crontab +- new_clone.sh: Basic clone script +- git_sync.sh: The script to run in crontab, to sync the changes + +## Run commands + +### Settings + +in `config/webhook.cfg` the following settings have to be entered + +```ini +GIT_WEBHOOK_BASE_FOLDER="" +WWW_GROUP="" +SUDO_USER="" +USE_SUDO=<1: use sudo, 0: no sudo used> +``` + +### base_setup.sh + +as is, if the folder exists it will only copy the scripts, will not alter or change anything. + +Planned to get auto fixes for wrong ACL, etc or missing config settings + +### new_clone.sh + +Create a new clone + +```sh +new_clone.sh [repository] [branch] ([host]) ([remote name]) +``` + +The [host] is the SSH Host name entry, this sill repalce any "[host]:" in the [repository]. If the [host] is not set the host set in the [repository] will be used. If nothing found the script will abort + +A [branch] name must be set all the time. + +An optional [remote name] can be set, if not set "origin" will be used. + +### git_sync.sh + +Syncs changes, this is the script that should be placed into the crontab + +```sh +git_sync.sh [repository] [branch] ([remote name]) +``` + +The [repository] the the folder name inside the clone folder, on new clone it is output in the info line "... into (GIT REPOSITORY FOLDER)". All repository folders are in the "clone-base/" folder. The base folder is defined in the config/webhook.crf file. + +A [branch] name must be set all the time. + +An optional [remote name] can be set, if not set "origin" will be used. ## TODO diff --git a/src/bin/base_setup.sh b/src/bin/base_setup.sh index 58ca5e3..247c456 100755 --- a/src/bin/base_setup.sh +++ b/src/bin/base_setup.sh @@ -66,14 +66,14 @@ if [ -d "${GIT_WEBHOOK_BASE_FOLDER}" ]; then echo "[TODO] -> Not implemented: check folder, check ACL"; # copy scripts & default config echo "~ Copy basic script and config files"; - # git_pull.sh, init.sh, new_clone.sh, webhook.default.cfg - cp "${BASE_FOLDER}new_clone.sh" "${BASE_FOLDER}init.sh" "${BASE_FOLDER}git_pull.sh" "${GIT_WEBHOOK_BASE_FOLDER}${SCRIPT_FOLDER}"; + # git_sync.sh, init.sh, new_clone.sh, webhook.default.cfg + cp "${BASE_FOLDER}new_clone.sh" "${BASE_FOLDER}init.sh" "${BASE_FOLDER}git_sync.sh" "${GIT_WEBHOOK_BASE_FOLDER}${SCRIPT_FOLDER}"; cp "${CONFIG_BASE}/webhook.default.cfg" "${GIT_WEBHOOK_BASE_FOLDER}${CONFIG_FOLDER}"; # and make sure they are all owned by the correct user chown "${SUDO_USER}" \ "${BASE_FOLDER}new_clone.sh" \ "${BASE_FOLDER}init.sh" \ - "${BASE_FOLDER}git_pull.sh" \ + "${BASE_FOLDER}git_sync.sh" \ "${CONFIG_BASE}/webhook.default.cfg"; # check config entries missing exit; @@ -145,14 +145,14 @@ EOF "${GIT_WEBHOOK_BASE_FOLDER}${WWW_BASE}"; # Copy files echo "+ Copy basic script and config files"; - # git_pull.sh, init.sh, new_clone.sh, webhook.default.cfg - cp "${BASE_FOLDER}new_clone.sh" "${BASE_FOLDER}init.sh" "${BASE_FOLDER}git_pull.sh" "${GIT_WEBHOOK_BASE_FOLDER}${SCRIPT_FOLDER}"; + # git_sync.sh, init.sh, new_clone.sh, webhook.default.cfg + cp "${BASE_FOLDER}new_clone.sh" "${BASE_FOLDER}init.sh" "${BASE_FOLDER}git_sync.sh" "${GIT_WEBHOOK_BASE_FOLDER}${SCRIPT_FOLDER}"; cp "${CONFIG_BASE}/webhook.cfg" "${CONFIG_BASE}/webhook.default.cfg" "${GIT_WEBHOOK_BASE_FOLDER}${CONFIG_FOLDER}"; # and make sure they are all owned by the correct user chown "${SUDO_USER}" \ "${BASE_FOLDER}new_clone.sh" \ "${BASE_FOLDER}init.sh" \ - "${BASE_FOLDER}git_pull.sh" \ + "${BASE_FOLDER}git_sync.sh" \ "${CONFIG_BASE}/webhook.cfg" \ "${CONFIG_BASE}/webhook.default.cfg"; fi; diff --git a/src/bin/git_pull.sh b/src/bin/git_sync.sh similarity index 100% rename from src/bin/git_pull.sh rename to src/bin/git_sync.sh