From 51742d1eb6fe316a2a619a6ed7955edd3a374edd Mon Sep 17 00:00:00 2001 From: Jimi Ford Date: Mon, 27 Nov 2023 02:37:17 -0500 Subject: [PATCH] add script to point URLs to a different fork --- .gitignore | 1 + misc/point-to-fork.sh | 28 ++++++++++++++++++++++++++++ misc/undo-point-to-fork.sh | 15 +++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 .gitignore create mode 100755 misc/point-to-fork.sh create mode 100755 misc/undo-point-to-fork.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7664704b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.bak \ No newline at end of file diff --git a/misc/point-to-fork.sh b/misc/point-to-fork.sh new file mode 100755 index 00000000..317f6c31 --- /dev/null +++ b/misc/point-to-fork.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright (c) 2021-2023 tteck +# Author: Jimi (JimiHFord) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +# Ensure script will function regardless of user's current working directory +# Get the directory of the script +script_dir="$(dirname "$(readlink -f "$0")")" +# Get project root directory +repo_dir="$(dirname "$(readlink -f "$script_dir")")" + +# Check if the number of arguments is correct +if [ "$#" -ne 3 ]; then + echo "Usage: $0 " + exit 1 +fi +old_string="https://raw.githubusercontent.com/tteck/Proxmox/main" +gh_user=$1 +gh_fork=$2 +gh_branch=$3 +new_string="https://raw.githubusercontent.com/$gh_user/$gh_fork/$gh_branch" + +# Replace string recursively in files +find "$repo_dir" -type f \( -name "*.sh" -o -name "*.func" \) -exec sed -i.bak "s|$old_string|$new_string|g" {} + + +echo "Replacement completed. Backup files with .bak extension created." diff --git a/misc/undo-point-to-fork.sh b/misc/undo-point-to-fork.sh new file mode 100755 index 00000000..fd77e593 --- /dev/null +++ b/misc/undo-point-to-fork.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Copyright (c) 2021-2023 tteck +# Author: Jimi (JimiHFord) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +# Ensure script will function regardless of user's current working directory +# Get the directory of the script +script_dir="$(dirname "$(readlink -f "$0")")" +# Get project root directory +repo_dir="$(dirname "$(readlink -f "$script_dir")")" + +find "$repo_dir" -type f -name "*.bak" -exec sh -c 'mv "$1" "${1%.bak}"' _ {} \; +echo "Undo operation completed. Backup files restored." \ No newline at end of file