Compare commits
2 commits
ff4c730968
...
d0fd3cfacf
Author | SHA1 | Date | |
---|---|---|---|
d0fd3cfacf | |||
576a0ac126 |
1 changed files with 0 additions and 48 deletions
48
update.sh
48
update.sh
|
@ -1,48 +0,0 @@
|
||||||
#!/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