1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pihole_ynh.git synced 2024-09-03 20:05:58 +02:00

Initial manifestV2

This commit is contained in:
Félix Piédallu 2024-03-20 13:45:25 +01:00
parent 5cc0fe9d75
commit 72da81d0ac
10 changed files with 147 additions and 308 deletions

View file

@ -1,151 +0,0 @@
#!/bin/bash
#=================================================
# PACKAGE UPDATING HELPER
#=================================================
# This script is meant to be run by GitHub Actions
# The YunoHost-Apps organisation offers a template Action to run this script periodically
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
#=================================================
# Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
version_adminlte=$(curl --silent "https://api.github.com/repos/pi-hole/web/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
version_ftl=$(curl --silent "https://api.github.com/repos/pi-hole/FTL/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets[0]="https://github.com/pi-hole/pi-hole/archive/$version.tar.gz"
assets[1]="https://github.com/pi-hole/web/archive/$version_adminlte.tar.gz"
assets[2]="https://github.com/pi-hole/FTL/archive/$version_ftl.tar.gz"
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1}
fi
if [[ ${version_adminlte:0:1} == "v" || ${version_adminlte:0:1} == "V" ]]; then
version_adminlte=${version_adminlte:1}
fi
if [[ ${version_ftl:0:1} == "v" || ${version_ftl:0:1} == "V" ]]; then
version_ftl=${version_ftl:1}
fi
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "VERSION=$version" >> $GITHUB_ENV
echo "REPO=$repo" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
*"FTL"*)
src="pi-hole_FTL"
;;
*"web"*)
src="pi-hole_AdminLTE"
;;
*"pi-hole"*)
src="pi-hole_Core"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true
EOT
echo "... conf/$src.src updated"
else
echo "... asset ignored"
fi
done
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
sed -i "/pihole_adminlte_version/c\pihole_adminlte_version=$version_adminlte" scripts/_common.sh
sed -i "/pihole_flt_version/c\pihole_flt_version=$version_ftl" scripts/_common.sh
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0

View file

@ -1,49 +0,0 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every day at 6:00 UTC
schedule:
- cron: '0 6 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
id: run_updater
run: |
# Setting up Git user
git config --global user.name 'yunohost-bot'
git config --global user.email 'yunohost-bot@users.noreply.github.com'
# Run the updater script
/bin/bash .github/workflows/updater.sh
- name: Commit changes
id: commit
if: ${{ env.PROCEED == 'true' }}
run: |
git commit -am "Upgrade to v$VERSION"
- name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update to version ${{ env.VERSION }}
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
base: testing
branch: ci-auto-update-v${{ env.VERSION }}
delete-branch: true
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
draft: false

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/pi-hole/AdminLTE/archive/v5.18.tar.gz
SOURCE_SUM=563d3568f9b4c8bf09c6a7a21995c1827f3438edd17e5e2b55ead873599580c0
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v5.14.2.tar.gz
SOURCE_SUM=fb2bf933eb7dc54de7b5ab220458e0298fb48fa84d5cba1bcb3c72c47bee1051
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/pi-hole/FTL/archive/v5.20.tar.gz
SOURCE_SUM=c098d65ed7e59865b814d64a0a5fac65914ce93277e69ef97ab87e8479731fc9
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -9,16 +9,18 @@ Use the admin panel of your Pi-hole to configure this app. You may also need to
## Using Pi-hole as your DHCP server
> **Be careful, you should considering that playing with your DHCP may break your network.
In case your server is down, you will lose your dns resolution and ip address.
So, you will lose any internet connection and even the connection to your router.**
> In case your server is down, you will lose your dns resolution and ip address.
> So, you will lose any internet connection and even the connection to your router.**
>
> **If you encounter this kind of problem, please see "How to restore my network" at the end of this document.**
### How to configure Pi-hole
There're two ways to configure Pi-hole to be used as your DHCP server.
- Either you can choose to use it when you install the app.
- Or you can activate the DHCP server afterwards in the "Settings" tab, "Pi-hole DHCP Server" part.
In this second case, it can be better to set the ip of the server to a static address
### How to configure my router
@ -43,19 +45,22 @@ Don't panic, We'll get through it. \o/
Use your favorite terminal on your desktop computer.
And first, get your main interface (usually `eth0`).
``` bash
sudo ifconfig
```
Then, set your ip as a static ip.
``` bash
sudo ifconfig eth0 192.168.1.100
```
Now, you can connect to your router and turn on its DHCP server to use it again.
You can now reset your ip and get a dynamic address.
``` bash
sudo ifconfig eth0 0.0.0.0 && sudo dhclient eth0
```
> Don't forget to turn off the DHCP of your router if your server is working again.
> Don't forget to turn off the DHCP of your router if your server is working again.

View file

@ -9,16 +9,18 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl
## Faire de Pi-hole votre serveur DHCP
> **Attention, vous devez savoir que toucher à votre DHCP pourrait casser votre réseau.
Dans le cas où votre serveur serait inaccessible, vous perdriez votre résolution dns et votre adresse IP.
Ainsi, vous perdriez toute connexion à internet et même la connexion à votre routeur.**
> Dans le cas où votre serveur serait inaccessible, vous perdriez votre résolution dns et votre adresse IP.
> Ainsi, vous perdriez toute connexion à internet et même la connexion à votre routeur.**
>
> **Si vous rencontrez ce genre de problèmes, merci de lire la section "Comment restaurer mon réseau" à la fin de ce document.**
### Comment configurer Pi-hole
Il y a 2 manière de configurer Pi-hole pour qu'il soit utilisé comme votre serveur DHCP.
- Soit vous pouvez choisir de l'utiliser lorsque vous installez l'application.
- Soit vous pouvez activer le serveur DHCP par la suite dans l'onglet "Settings", partie "Pi-hole DHCP Server".
Dans ce second cas, il peut être préférable de forcer l'ip du serveur à une adresse statique.
### Comment configurer mon routeur
@ -43,17 +45,20 @@ Ne paniquez pas, on va surmonter ça \o/
Utilisez votre terminal favori sur votre ordinateur de bureau.
Et tout d'abord, récupérer votre interface réseau (Le plus souvent `eth0`).
``` bash
sudo ifconfig
```
Ensuite, changer votre ip pour une ip statique.
``` bash
sudo ifconfig eth0 192.168.1.100
```
Maintenant, vous pouvez vous connecter à votre routeur et rallumer son serveur DHCP pour l'utiliser à nouveau.
Vous pouvez maintenant retirer votre ip statique et réobtenir une ip dynamique.
``` bash
sudo ifconfig eth0 0.0.0.0 && sudo dhclient eth0
```

View file

@ -1,80 +0,0 @@
{
"name": "Pi-hole",
"id": "pihole",
"packaging_format": 1,
"description": {
"en": "Network-wide ad blocking via your own DNS server",
"fr": "Filtrage publicitaire via votre propre serveur DNS"
},
"version": "5.14.2~ynh4",
"url": "https://pi-hole.net/",
"upstream": {
"license": "EUPL-1.2",
"website": "https://pi-hole.net/",
"admindoc": "https://docs.pi-hole.net",
"code": "https://github.com/pi-hole/pi-hole"
},
"license": "EUPL-1.2",
"maintainer": {
"name": "",
"email": ""
},
"previous_maintainers": [
{
"name": "Maniack Crudelis",
"email": "maniackc_dev@crudelis.fr"
}
],
"requirements": {
"yunohost": ">= 11.2.4"
},
"multi_instance": false,
"services": [
"nginx",
"php7.4-fpm"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/pihole",
"default": "/pihole"
},
{
"name": "admin",
"type": "user"
},
{
"name": "query_logging",
"type": "boolean",
"ask": {
"en": "Do you want to log DNS queries?",
"fr": "Voulez-vous enregistrer les requêtes DNS ?"
},
"help": {
"en": "Keeping this option deactivate will render graphs on the admin page useless. But will respect the privacy of the other users.",
"fr": "Garder cette option désactivée rendra les graphiques sur la page d'administration inutiles. Mais respectera la vie privée des autres utilisateurs."
},
"default": false
},
{
"name": "enable_dhcp",
"type": "boolean",
"ask": {
"en": "Do you want to set Pi-Hole as your DHCP server?",
"fr": "Voulez-vous utiliser Pi-Hole an tant que serveur DHCP ?"
},
"help": {
"en": "If you want to do that, <a href=https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md target=_blank>you really have to read this before</a>!",
"fr": "Si vous voulez faire ça, <a href=https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md target=_blank>vous devez vraiment lire cela avant</a> !"
},
"default": false
}
]
}
}

115
manifest.toml Normal file
View file

@ -0,0 +1,115 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "pihole"
name = "Pi-hole"
description.en = "Network-wide ad blocking via your own DNS server"
description.fr = "Filtrage publicitaire via votre propre serveur DNS"
version = "5.14.2~ynh4"
maintainers = []
[upstream]
license = "EUPL-1.2"
website = "https://pi-hole.net/"
admindoc = "https://docs.pi-hole.net"
code = "https://github.com/pi-hole/pi-hole"
fund = "https://pi-hole.net/donate/#donate"
[integration]
yunohost = ">= 11.2.4"
architectures = "all"
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/pihole"
[install.query_logging]
ask.en = "Do you want to log DNS queries?"
ask.fr = "Voulez-vous enregistrer les requêtes DNS ?"
help.en = "Keeping this option deactivate will render graphs on the admin page useless. But will respect the privacy of the other users."
help.fr = "Garder cette option désactivée rendra les graphiques sur la page d'administration inutiles. Mais respectera la vie privée des autres utilisateurs."
type = "boolean"
default = false
[install.enable_dhcp]
ask.en = "Do you want to set Pi-Hole as your DHCP server?"
ask.fr = "Voulez-vous utiliser Pi-Hole an tant que serveur DHCP ?"
help.en = "If you want to do that, <a href=https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md target=_blank>you really have to read this before</a>!"
help.fr = "Si vous voulez faire ça, <a href=https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md target=_blank>vous devez vraiment lire cela avant</a> !"
type = "boolean"
default = false
[resources]
[resources.sources]
[resources.sources.pi-hole_core]
url = "https://github.com/pi-hole/pi-hole/archive/v5.14.2.tar.gz"
sha256 = "fb2bf933eb7dc54de7b5ab220458e0298fb48fa84d5cba1bcb3c72c47bee1051"
autoupdate.upstream = "https://github.com/pi-hole/pi-hole"
autoupdate.strategy = "latest_github_release"
[resources.sources.pi-hole_web]
url = "https://github.com/pi-hole/web/archive/v5.18.tar.gz"
sha256 = "563d3568f9b4c8bf09c6a7a21995c1827f3438edd17e5e2b55ead873599580c0"
autoupdate.upstream = "https://github.com/pi-hole/web"
autoupdate.strategy = "latest_github_release"
[resources.sources.pi-hole_ftl]
url = "https://github.com/pi-hole/FTL/archive/v5.20.tar.gz"
sha256 = "c098d65ed7e59865b814d64a0a5fac65914ce93277e69ef97ab87e8479731fc9"
autoupdate.upstream = "https://github.com/pi-hole/FTL"
autoupdate.strategy = "latest_github_release"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
mani.allowed = "admins"
[resources.ports]
main.default = 4711
[resources.apt]
packages = [
"php7.4-common",
"php7.4-cgi",
"php7.4-sqlite3",
"php7.4-xml",
"php7.4-intl",
"cmake",
"build-essential",
"libgmp-dev",
"libidn11-dev",
"nettle-dev",
"libreadline-dev",
"sqlite3",
"cron",
"curl",
"iputils-ping",
"psmisc",
"unzip",
"idn2",
"libcap2-bin",
"dns-root-data",
"libcap2",
"netcat-openbsd",
"procps",
"jq",
]

15
tests.toml Normal file
View file

@ -0,0 +1,15 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
args.query_logging = 1
args.enable_dhcp = 0
# ------------
# Tests to run
# ------------
test_upgrade_from.3d2f68c4e19f335e63f8ffa259708b38a58c8f67.name = "5.11.4~ynh1"
test_upgrade_from.4999654987af8b1427a6c72f8af482b235bb46db.name = "5.11.4~ynh1 bis"