72 lines
3.0 KiB
Bash
Executable File
72 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
cd /var/www/html || exit 1
|
|
|
|
# First, let's clear the F-Droid index
|
|
rm -f repo/index*
|
|
rm -f repo/entry.jar
|
|
|
|
# Make sure we have the tools we need
|
|
command -v aapt >/dev/null 2>&1 || { echo "Error: aapt is required but not installed. Please install Android SDK build tools."; exit 1; }
|
|
|
|
# Function to extract version from APK
|
|
get_version() {
|
|
apk_file=$1
|
|
version=$(aapt dump badging "$apk_file" 2>/dev/null | grep versionName | awk -F"'" '{print $4}')
|
|
echo "$version"
|
|
}
|
|
|
|
# Function to download and update only if changed
|
|
update_app() {
|
|
app_name=$1
|
|
app_url=$2
|
|
|
|
echo "Processing $app_name..."
|
|
|
|
# Create temp directory
|
|
mkdir -p ./temp
|
|
|
|
# Download to temp file
|
|
wget -q -O "./temp/${app_name}.apk.new" "$app_url"
|
|
|
|
# Extract version info from the new APK
|
|
new_version=$(get_version "./temp/${app_name}.apk.new")
|
|
echo " Downloaded version: $new_version"
|
|
|
|
# Check if app exists and if it's different
|
|
if [ -f "./repo/${app_name}.apk" ]; then
|
|
# Extract version info from the existing APK
|
|
current_version=$(get_version "./repo/${app_name}.apk")
|
|
echo " Current version: $current_version"
|
|
|
|
# Compare files (binary comparison to be absolutely sure)
|
|
if ! cmp -s "./temp/${app_name}.apk.new" "./repo/${app_name}.apk"; then
|
|
echo " ✓ $app_name: New version detected ($current_version → $new_version), updating..."
|
|
mv "./temp/${app_name}.apk.new" "./repo/${app_name}.apk"
|
|
touch -d "$(date +%Y-%m-%d)" "./repo/${app_name}.apk"
|
|
else
|
|
echo " ✓ $app_name: No changes detected (version $current_version), keeping existing version"
|
|
rm "./temp/${app_name}.apk.new"
|
|
fi
|
|
else
|
|
echo " ✓ $app_name: File does not exist yet, adding version $new_version..."
|
|
mv "./temp/${app_name}.apk.new" "./repo/${app_name}.apk"
|
|
touch -d "$(date +%Y-%m-%d)" "./repo/${app_name}.apk"
|
|
fi
|
|
}
|
|
|
|
# Process each app
|
|
update_app "YouTube" "https://git.felo.gg/FeloStore/Data/releases/download/latest/youtube.apk"
|
|
update_app "Reddit" "https://git.felo.gg/FeloStore/Data/releases/download/latest/reddit.apk"
|
|
update_app "Duolingo" "https://git.felo.gg/FeloStore/Data/releases/download/latest/duolingo.apk"
|
|
update_app "Instagram" "https://git.felo.gg/FeloStore/Data/releases/download/latest/instagram.apk"
|
|
update_app "Twitter" "https://git.felo.gg/FeloStore/Data/releases/download/latest/twitter.apk"
|
|
update_app "NovaLauncher" "https://git.felo.gg/FeloStore/Data/releases/download/latest/novalauncher.apk"
|
|
update_app "Busuu" "https://git.felo.gg/FeloStore/Data/releases/download/latest/busuu.apk"
|
|
update_app "Quizlet" "https://git.felo.gg/FeloStore/Data/releases/download/latest/quizlet.apk"
|
|
update_app "Telegram" "https://git.felo.gg/FeloStore/Data/releases/download/latest/telegram.apk"
|
|
|
|
# Clean up temp directory
|
|
rm -rf ./temp
|
|
|
|
# Update the F-Droid repository
|
|
/root/.local/bin/fdroid update --clean --allow-disabled-algorithms |