feat(fdroid): automatic apk download
This commit is contained in:
parent
3c1578e137
commit
b4c9f173bd
@ -2,6 +2,7 @@ BASE_URL=fdroid.
|
||||
EMAIL=
|
||||
|
||||
REPO_NAME=fdroid
|
||||
CRON_APP_UPDATE='0 0 * * 1'
|
||||
|
||||
PUID=1000
|
||||
PGID=1000
|
||||
|
@ -1,7 +1,9 @@
|
||||
FROM docker.io/nginx:latest
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
cron \
|
||||
fdroidserver \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY entrypoint.sh /docker-entrypoint.d/99-init-fdroid.sh
|
||||
COPY entrypoint.sh /docker-entrypoint.d/99-entrypoint.sh
|
||||
COPY scripts/ /usr/local/bin/
|
||||
COPY default.conf /etc/nginx/conf.d/
|
||||
|
6
fdroid/apks.txt
Normal file
6
fdroid/apks.txt
Normal file
@ -0,0 +1,6 @@
|
||||
# 1 URL by line
|
||||
# Supported URLS patterns:
|
||||
# - .*github.com/OWNER/REPO.*
|
||||
# - .*gitlab.com/OWNER/REPO.*
|
||||
# Exemple:
|
||||
# https://gitlab.com/fdroid/fdroidclient
|
@ -18,10 +18,12 @@ services:
|
||||
environment:
|
||||
- BASE_URL
|
||||
- REPO_NAME
|
||||
- CRON_APP_UPDATE
|
||||
- PUID
|
||||
- PGID
|
||||
volumes:
|
||||
- ./repo/:/repo/
|
||||
- ./apks.txt:/:ro
|
||||
networks:
|
||||
- nginx
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
-e "/repo_url/s .* repo_url:\ https://$BASE_URL/repo " \
|
||||
-e "/repo_name/s .* repo_name:\ \"$REPO_NAME\" " \
|
||||
config.yml
|
||||
|
||||
fdroid update -c
|
||||
)
|
||||
|
||||
if [ -n "$PUID" ]; then
|
||||
chown -R "$PUID:$PGID" /repo/
|
||||
fi
|
||||
get_apks.sh
|
||||
|
||||
echo "$CRON_APP_UPDATE root get_apks.sh" > /etc/cron.d/get_new_apks
|
||||
|
||||
/etc/init.d/cron start
|
||||
|
31
fdroid/scripts/get_apks.sh
Executable file
31
fdroid/scripts/get_apks.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
SCRIPT_PATH="$(dirname "$0")"
|
||||
|
||||
function get_links() {
|
||||
FILE="$1"
|
||||
|
||||
awk 'NF && $1!~/^#/' "$FILE" | while read -r URL; do
|
||||
case "$URL" in
|
||||
*github.com*)
|
||||
"$SCRIPT_PATH/get_github_dl_links.sh" "$URL"
|
||||
;;
|
||||
*gitlab.com*)
|
||||
"$SCRIPT_PATH/get_gitlab_dl_links.sh" "$URL"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
LINKS="$(get_links apks.txt)"
|
||||
|
||||
(cd /repo/
|
||||
xargs -n1 -P8 curl -LO <<< "$LINKS"
|
||||
fdroid update -c
|
||||
)
|
||||
|
||||
if [ -n "$PUID" ]; then
|
||||
chown -R "$PUID:$PGID" /repo/
|
||||
fi
|
19
fdroid/scripts/get_github_dl_links.sh
Executable file
19
fdroid/scripts/get_github_dl_links.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
API='https://api.github.com'
|
||||
CONTENT_TYPE='"application/vnd.android.package-archive"'
|
||||
|
||||
function get_urls() {
|
||||
local repo="$1"
|
||||
|
||||
curl -sSL "$API/repos/$repo/releases/latest" | \
|
||||
jq -r ".assets.[] | select(.content_type == $CONTENT_TYPE) | .browser_download_url"
|
||||
}
|
||||
|
||||
function get_repo_name_from_url() {
|
||||
grep -Po '(?<=github.com/)[[:alnum:]]+/[[:alnum:]]+' <<< "$1"
|
||||
}
|
||||
|
||||
for repo in "$@"; do
|
||||
get_urls "$(get_repo_name_from_url "$repo")"
|
||||
done
|
20
fdroid/scripts/get_gitlab_dl_links.sh
Executable file
20
fdroid/scripts/get_gitlab_dl_links.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
API='https://gitlab.com/api/v4'
|
||||
|
||||
function get_urls() {
|
||||
local repo="$1"
|
||||
|
||||
curl -L "$API/projects/$repo/releases" | \
|
||||
jq -r '.[0].assets.links.[] | select(.name | test(".apk$")) | .url'
|
||||
}
|
||||
|
||||
function get_repo_name_from_url() {
|
||||
printf '%s' \
|
||||
"$(grep -Po '(?<=gitlab.com/)[[:alnum:]]+/[[:alnum:]]+' <<< "$1")" | \
|
||||
jq -sRr '@uri'
|
||||
}
|
||||
|
||||
for repo in "$@"; do
|
||||
get_urls "$(get_repo_name_from_url "$repo")"
|
||||
done
|
Loading…
Reference in New Issue
Block a user