Skip to content

Instantly share code, notes, and snippets.

@Otus9051
Created June 7, 2024 05:16
Show Gist options
  • Save Otus9051/57c98346a48d1eadc6b1e1c47c39b433 to your computer and use it in GitHub Desktop.
Save Otus9051/57c98346a48d1eadc6b1e1c47c39b433 to your computer and use it in GitHub Desktop.
Automated Mirroring Script, needs a version text on the origin mirror.
#!/bin/bash
ISO_URL="mirror/iso"
LOCAL_ISO_PATH="/var/www/mirrors/blend/isos/testing/blendOS.iso"
ISO_VERSION_URL="mirror/version"
LOCAL_VERSION_FILE="/var/www/mirrors/blend/isos/testing/version"
download_iso() {
rm -rf $LOCAL_ISO_PATH
wget -O "$LOCAL_ISO_PATH" "$ISO_URL"
wget -O "$LOCAL_VERSION_FILE" "$ISO_VERSION_URL"
}
get_remote_version() {
wget -O - "$ISO_VERSION_URL"
}
REMOTE_VERSION=$(get_remote_version)
LOCAL_VERSION=$(cat "$LOCAL_VERSION_FILE")
if [ "$REMOTE_VERSION" != "$LOCAL_VERSION" ]; then
echo "New ISO version detected. Downloading..."
download_iso
echo "$REMOTE_VERSION" > "$LOCAL_VERSION_FILE"
else
echo "ISO is up-to-date."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment