summaryrefslogtreecommitdiff
path: root/modules/nixos/server/github-mirror/update-mirror.sh
diff options
context:
space:
mode:
authorseth <[email protected]>2024-10-27 20:12:19 -0400
committerGitHub <[email protected]>2024-10-28 00:12:19 +0000
commit5ec7ee21e036f7bc1cbdec714271c619cb3fdb3d (patch)
tree3277d8ba68ca466e68c58a8373063010db392d2e /modules/nixos/server/github-mirror/update-mirror.sh
parent75ec48c5f7dd7877f2294b86764b1fdadc6b7e88 (diff)
modules: restructure (#487)
* seth: remove unused pkgs * modules: restructure from archetypes back to profiles make less actual modules for everything use lib.mkDefault like it's supposed to move mixins out of server * nixos/resolved: use modern options
Diffstat (limited to 'modules/nixos/server/github-mirror/update-mirror.sh')
-rwxr-xr-xmodules/nixos/server/github-mirror/update-mirror.sh78
1 files changed, 0 insertions, 78 deletions
diff --git a/modules/nixos/server/github-mirror/update-mirror.sh b/modules/nixos/server/github-mirror/update-mirror.sh
deleted file mode 100755
index c1e392d..0000000
--- a/modules/nixos/server/github-mirror/update-mirror.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-help() {
- echo "Mirror a GitHub user's repositories
-
-Usage: $(basename "$0") [options] <user>...
-
-Options:
- -h --help Show this screen
- -d --directory DIRECTORY Where to clone repositories (defaults to ./git)"
-}
-
-create_if_not_exists() {
- if [ ! -d "$1" ]; then
- mkdir -p "$1"
- fi
-}
-
-repo_endpoint() {
- echo "https://api.github.com/users/$1/repos"
-}
-
-users=()
-output_directory="git"
-
-while [ "$#" -gt 0 ]; do
- case $1 in
- -h | --help)
- help
- exit 0
- ;;
- -d | --directory)
- output_directory="$2"
- shift
- shift
- ;;
- -*)
- echo "error: unknown option $1"
- help
- exit 1
- ;;
- *)
- users+=("$1")
- shift
- ;;
- esac
-done
-
-if [ "${#users[@]}" -lt 1 ]; then
- echo "error: at least one user must be specified"
- help
- exit 1
-fi
-
-create_if_not_exists "$output_directory"
-cd "$output_directory"
-
-for user in "${users[@]}"; do
- create_if_not_exists "$user"
-
- url="$(repo_endpoint "$user")"
- curl --fail --location --show-error --silent "$url" | jq --raw-output '.[].name' | while read -r repo; do
- repo_path="$user"/"$repo"
-
- if [ -d "$repo_path"/.git ]; then
- pushd "$repo_path" &>/dev/null
- echo "Pulling $repo_path..."
- if ! git remote update --prune &>/dev/null; then
- echo "Unable to pull $repo_path! Continuing..."
- fi
- popd &>/dev/null
- else
- echo "Cloning $repo_path..."
- git clone --bare --mirror https://github.com/"$repo_path".git "$repo_path" &>/dev/null
- fi
- done
-done