Compare commits
No commits in common. "d0fd3cfacf7b5ca67602bdc8de7c0184b1b7698a" and "ff4c730968e3b6b1c2cdce2185d7649f1450a394" have entirely different histories.
d0fd3cfacf
...
ff4c730968
1 changed files with 48 additions and 0 deletions
48
update.sh
Executable file
48
update.sh
Executable file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
# --- Configurable variables ---
|
||||||
|
SRC_FILE="/var/www/html/banned.txt"
|
||||||
|
REPO_DIR="/home/jordanwages/fail2ban2list/wagenet-ip-ban-list"
|
||||||
|
DEST_FILE="banned.txt"
|
||||||
|
|
||||||
|
# --- Functions ---
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [-s source_file] [-d repo_dir] [-f dest_file]"
|
||||||
|
echo " -s Source file path (default: $SRC_FILE)"
|
||||||
|
echo " -d Git repo directory (default: $REPO_DIR)"
|
||||||
|
echo " -f Destination filename inside repo (default: $DEST_FILE)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Parse arguments ---
|
||||||
|
while getopts ":s:d:f:h" opt; do
|
||||||
|
case $opt in
|
||||||
|
s) SRC_FILE="$OPTARG" ;;
|
||||||
|
d) REPO_DIR="$OPTARG" ;;
|
||||||
|
f) DEST_FILE="$OPTARG" ;;
|
||||||
|
h) usage ;;
|
||||||
|
\?) echo "Invalid option: -$OPTARG" >&2; usage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# --- Main logic ---
|
||||||
|
if [[ ! -f "$SRC_FILE" ]]; then
|
||||||
|
echo "Error: Source file '$SRC_FILE' not found." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$REPO_DIR/.git" ]]; then
|
||||||
|
echo "Error: '$REPO_DIR' is not a git repository." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$REPO_DIR"
|
||||||
|
cp "$SRC_FILE" "$DEST_FILE"
|
||||||
|
|
||||||
|
git add "$DEST_FILE"
|
||||||
|
COMMIT_MSG="Update banned IP list — $(date '+%Y-%m-%d %H:%M:%S %Z')"
|
||||||
|
git commit -m "$COMMIT_MSG" || echo "No changes to commit."
|
||||||
|
git push
|
Loading…
Add table
Add a link
Reference in a new issue