From 77b40bb64f15b10dfe365b4006f77b7e49260873 Mon Sep 17 00:00:00 2001 From: Matthew Marchese Date: Tue, 2 May 2023 03:30:20 -0700 Subject: update.sh: Automate installation of git submods. This change should pull in new changes from GLEPS and NEWS items automatically in the future. A runtime check of git is performed; the new script should safely exit git is not detected, which _could_ be the case for a dedicated web host. Signed-off-by: Matthew Marchese --- bin/update-git-submodules.sh | 25 +++++++++++++++++++++++++ bin/update.sh | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 bin/update-git-submodules.sh (limited to 'bin') diff --git a/bin/update-git-submodules.sh b/bin/update-git-submodules.sh new file mode 100755 index 0000000..bb796a5 --- /dev/null +++ b/bin/update-git-submodules.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +SUBMODULES=("_data/news" "glep") + +# Ensure the script is in the base of the project directory. +cd "$(dirname "$0")"/.. || exit + +echo -n 'Updating git submodules' + +# Verify git exists at runtime or safely skip this update +if ! command -v git &> /dev/null; then + echo "...skipped (git is not detected on the PATH)." + exit +fi + +for module in "${SUBMODULES[@]}"; do + printf ' %s' "${module}" + if [ -d "${module}/.git" ]; then + git submodule update --quiet --depth=1 "${module}" + else + git submodule update --quiet --depth=1 --init "${module}" + fi + done + +echo '...done.' diff --git a/bin/update.sh b/bin/update.sh index 1ba3e48..20d02c6 100755 --- a/bin/update.sh +++ b/bin/update.sh @@ -10,6 +10,7 @@ bin/update-keys.sh || exit 1 bin/update-mirrors.sh || exit 1 bin/update-packages.sh || exit 1 bin/update-planet.sh || exit 1 -bin/update-use.sh || exit 1 +bin/update-use.sh || exit 1 bin/update-userinfo.sh || exit 1 bin/update-wiki.sh || exit 1 +bin/update-git-submodules.sh || exit 1 \ No newline at end of file -- cgit v1.2.3-65-gdbad