139 lines
6.1 KiB
Bash
Executable File
139 lines
6.1 KiB
Bash
Executable File
#!/bin/bash
|
|
cd /var/www/html || exit 1
|
|
|
|
# Fix permissions on config.yml
|
|
chmod 0600 config.yml
|
|
|
|
# Create repo icon directory if it doesn't exist
|
|
mkdir -p repo/icons
|
|
# Create a basic repo icon if missing
|
|
if [ ! -f repo/icons/icon.png ]; then
|
|
echo "Creating placeholder repo icon..."
|
|
# Try to create an icon using ImageMagick if available
|
|
if command -v convert >/dev/null 2>&1; then
|
|
convert -size 512x512 xc:blue -fill white -gravity center -pointsize 70 -annotate 0 "F-Droid\nRepo" repo/icons/icon.png
|
|
else
|
|
# Fallback to downloading a simple icon
|
|
wget -q -O repo/icons/icon.png "https://f-droid.org/assets/favicon-256.png" || echo "Could not create icon, please add one manually"
|
|
fi
|
|
fi
|
|
|
|
# Function to extract version from APK (if aapt is available)
|
|
get_version() {
|
|
apk_file=$1
|
|
if command -v aapt >/dev/null 2>&1; then
|
|
version=$(aapt dump badging "$apk_file" 2>/dev/null | grep versionName | awk -F"'" '{print $4}')
|
|
echo "$version"
|
|
else
|
|
echo "unknown (aapt not installed)"
|
|
fi
|
|
}
|
|
|
|
# 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"
|
|
|
|
# Check if download was successful
|
|
if [ ! -s "./temp/${app_name}.apk.new" ]; then
|
|
echo " ✗ Failed to download $app_name, skipping"
|
|
rm -f "./temp/${app_name}.apk.new"
|
|
return
|
|
fi
|
|
|
|
# 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
|
|
}
|
|
|
|
# Make sure archive directory exists and check for archived APKs
|
|
mkdir -p archive/
|
|
# Check if any apps are in archive and restore them to repo
|
|
echo "Checking for archived APKs to restore..."
|
|
for app in YouTube Reddit SoundCloud Duolingo GoogleNews Instagram Twitter NovaLauncher Busuu Quizlet Telegram; do
|
|
if [ -f "archive/${app}.apk" ]; then
|
|
echo "Restoring ${app}.apk from archive to repo"
|
|
cp "archive/${app}.apk" "repo/${app}.apk"
|
|
touch -d "$(date +%Y-%m-%d)" "repo/${app}.apk"
|
|
fi
|
|
done
|
|
|
|
# Process each app
|
|
update_app "YouTube" "https://github.com/FiorenMas/Revanced-And-Revanced-Extended-Non-Root/releases/download/all/youtube-revanced-extended.apk"
|
|
update_app "Reddit" "https://github.com/FiorenMas/Revanced-And-Revanced-Extended-Non-Root/releases/download/all/reddit-revanced-extended.apk"
|
|
update_app "SoundCloud" "https://github.com/FiorenMas/Revanced-And-Revanced-Extended-Non-Root/releases/download/all/soundcloud-revanced.apk"
|
|
update_app "Duolingo" "https://git.felo.gg/FeloStore/Data/releases/download/latest/duolingo.apk"
|
|
update_app "GoogleNews" "https://github.com/FiorenMas/Revanced-And-Revanced-Extended-Non-Root/releases/download/all/googlenews-arm64-v8a-revanced.apk"
|
|
update_app "Instagram" "https://git.felo.gg/FeloStore/Data/releases/download/latest/instagram.apk"
|
|
update_app "Twitter" "https://github.com/FiorenMas/Revanced-And-Revanced-Extended-Non-Root/releases/download/all/twitter-stable-piko.apk"
|
|
update_app "NovaLauncher" "https://github.com/FiorenMas/Revanced-And-Revanced-Extended-Non-Root/releases/download/all/nova-launcher-indrastorms.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
|
|
|
|
# Create or update fdroidserver config to accept unsigned APKs
|
|
mkdir -p ~/.config/fdroidserver/
|
|
echo "accept_bad_certificate: True" > ~/.config/fdroidserver/config.yml
|
|
echo "allow_disabled_algorithms: True" >> ~/.config/fdroidserver/config.yml
|
|
|
|
# Update config to explicitly allow unsigned APKs
|
|
if [ -f config.yml ]; then
|
|
if ! grep -q "disable_apk_signing:" config.yml; then
|
|
echo "disable_apk_signing: True" >> config.yml
|
|
fi
|
|
if ! grep -q "allow_disabled_algorithms:" config.yml; then
|
|
echo "allow_disabled_algorithms: True" >> config.yml
|
|
fi
|
|
fi
|
|
|
|
# Update F-Droid repository with special flags for unsigned APKs
|
|
echo "Updating F-Droid repository with special settings for unsigned APKs..."
|
|
fdroid update --create-metadata --no-check-certificate --allow-disabled-algorithms --use-date-from-apk --delete-unsigned --disable-apk-signing
|
|
|
|
# After update, copy any moved files back from archive to repo
|
|
echo "Checking if any APKs were moved to archive..."
|
|
for app in YouTube Reddit SoundCloud Duolingo GoogleNews Instagram Twitter NovaLauncher Busuu Quizlet Telegram; do
|
|
if [ -f "archive/${app}.apk" ] && [ ! -f "repo/${app}.apk" ]; then
|
|
echo "Restoring ${app}.apk from archive to repo after update"
|
|
cp "archive/${app}.apk" "repo/${app}.apk"
|
|
touch -d "$(date +%Y-%m-%d)" "repo/${app}.apk"
|
|
fi
|
|
done
|
|
|
|
# Final update to include any restored files
|
|
echo "Running final update..."
|
|
fdroid update --no-check-certificate --allow-disabled-algorithms --use-date-from-apk --disable-apk-signing
|
|
|
|
echo "Update complete!" |