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

Apply last example_ynh

This commit is contained in:
yalh76 2022-09-16 03:30:13 +02:00
parent 1c750f1ceb
commit d815c03a89
18 changed files with 606 additions and 432 deletions

137
.github/workflows/updater.sh vendored Normal file
View file

@ -0,0 +1,137 @@
#!/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_dashboard=$(curl --silent "https://api.github.com/repos/pi-hole/AdminLTE/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/AdminLTE/archive/$version_dashboard.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
# 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
*"AdminLTE"*)
src="admin_dashboard"
;;
*"pi-hole"*)
src="app"
;;
*)
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.
#=================================================
# 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

49
.github/workflows/updater.yml vendored Normal file
View file

@ -0,0 +1,49 @@
# 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@v2
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@v3
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

@ -3,3 +3,5 @@ SOURCE_SUM=67d01bd4245024c9c6f9bf474bb17e8bde269ccc42ba4bb5a99da25632162c21
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -3,3 +3,5 @@ SOURCE_SUM=e24db53c63a6ea240f0852bd082b224dda91ad4fd049ab700c218b9672fc59cf
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -6,10 +6,14 @@ location __PATH__/ {
index index.html index.php;
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
#client_max_body_size 50M;
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Pi-hole® est un puits DNS qui protège vos appareils des contenus indésirables sans installer de logiciel côté client.

View file

@ -12,17 +12,19 @@
"license": "EUPL-1.2",
"website": "https://pi-hole.net/",
"admindoc": "https://docs.pi-hole.net",
"code": "https://github.com/pi-hole/pi-hole/"
"code": "https://github.com/pi-hole/pi-hole"
},
"license": "EUPL-1.2",
"maintainer": {
"name": "",
"email": ""
},
"previous_maintainers": [{
"previous_maintainers": [
{
"name": "Maniack Crudelis",
"email": "maniackc_dev@crudelis.fr"
}],
}
],
"requirements": {
"yunohost": ">= 4.3.0"
},

View file

@ -4,17 +4,17 @@
# COMMON VARIABLES
#=================================================
YNH_PHP_VERSION="7.3"
php_dependencies="php$YNH_DEFAULT_PHP_VERSION-sqlite3"
# Dependencies
pkg_dependencies="sqlite3 idn2 php${YNH_PHP_VERSION}-sqlite3 nettle-dev libcap2-bin build-essential libgmp-dev m4 cmake libidn11-dev libreadline-dev xxd"
# dependencies used by the app (must be on a single line)
pkg_dependencies="sqlite3 idn2 nettle-dev libcap2-bin build-essential libgmp-dev m4 cmake libidn11-dev libreadline-dev xxd $php_dependencies"
pihole_core_version=5.11.4
dashboard_version=5.13
FTL_version=5.16.1
#=================================================
# FUTUR OFFICIAL HELPERS
# PERSONAL HELPERS
#=================================================
#=================================================

View file

@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -25,7 +28,6 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
path_url=$(ynh_app_setting_get --app=$app --key=path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
# Get variable from ynh_add_fpm_config
@ -37,14 +39,10 @@ fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIRECTORIES
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/.pihole"
ynh_backup --src_path="/etc/pihole"
ynh_backup --src_path="/opt/pihole"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
@ -64,6 +62,10 @@ ynh_backup --src_path="$fpm_config_dir/pool.d/$app.conf"
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/.pihole"
ynh_backup --src_path="/etc/pihole"
ynh_backup --src_path="/opt/pihole"
ynh_backup --src_path="/etc/cron.d/pihole"
ynh_backup --src_path="/usr/local/bin/pihole"

View file

@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
source _common.sh
source /usr/share/yunohost/helpers
@ -14,6 +13,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -89,7 +91,7 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -107,14 +109,6 @@ ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
chown $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
@ -123,12 +117,20 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low --dedicated_service
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DIRECTORIES AND POPULATE THEM
#=================================================
ynh_script_progression --message="Creating and populating directories..."
ynh_script_progression --message="Creating and populating directories..." --weight=1
pihole_storage="/etc/pihole"
mkdir -p "$pihole_storage"
@ -147,7 +149,7 @@ cp -a "$pihole_local_repo/advanced/Scripts/COL_TABLE" "$pihole_dir/"
#=================================================
# COPY PI-HOLE MAIN SCRIPT
#=================================================
ynh_script_progression --message="Copying Pi-Hole main script..."
ynh_script_progression --message="Copying Pi-Hole main script..." --weight=1
cp -a "$pihole_local_repo/pihole" /usr/local/bin/
cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion.d/pihole
@ -318,26 +320,26 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
systemctl daemon-reload
ynh_exec_warn_less yunohost tools regen-conf dnsmasq
#=================================================
# START PIHOLE-FTL
#=================================================
ynh_script_progression --message="Restarting PiHole-FTL..." --weight=2
ynh_systemd_action --action=restart --service_name=pihole-FTL
#=================================================
# GENERIC FINALISATION
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add pihole-FTL --description="PiHole backend service" --log="/var/log/pihole-FTL.log"
#=================================================
# RESTRAIN THE ACCESS TO THE ADMIN ONLY
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Restraining the access to the admin only..." --weight=2
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --action=restart --service_name=pihole-FTL
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=2
ynh_permission_update --permission="main" --add="$admin" --remove="all_users"

View file

@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
@ -25,17 +26,17 @@ port=$(ynh_app_setting_get --app=$app --key=port)
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Check if the service is declared in YunoHost
if ynh_exec_fully_quiet yunohost service status pihole-FTL
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status pihole-FTL >/dev/null
then
ynh_script_progression --message="Removing pihole-FTL service..." --weight=2
ynh_script_progression --message="Removing $app service integration..." --weight=2
yunohost service remove pihole-FTL
fi
#=================================================
# STOP PIHOLE-FTL SERVICE
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stop and remove the service"
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
ynh_systemd_action --action=stop --service_name=pihole-FTL
@ -62,32 +63,10 @@ ynh_secure_remove --file="/usr/bin/pihole-FTL"
ynh_secure_remove --file="/var/run/pihole-FTL.pid"
ynh_secure_remove --file="/var/run/pihole-FTL.port"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=7
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE THE DIRECTORIES OF THE APP
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove storage directory
ynh_secure_remove --file="/etc/pihole"
# Remove app directory
ynh_secure_remove --file="/opt/pihole"
# Remove admin panel directory
ynh_secure_remove --file="/var/www/pihole"
# Remove local clone of the repository
ynh_secure_remove --file="/etc/.pihole"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
@ -101,20 +80,27 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
ynh_remove_fpm_config
#=================================================
# CLOSE PORTS
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=7
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# CLOSE A PORT
#=================================================
ynh_script_progression --message="Closing ports $port and 67..." --weight=13
if yunohost firewall list | grep -q "\- $port$"
then
ynh_print_info "Close port $port"
ynh_exec_quiet yunohost firewall disallow TCP $port
ynh_script_progression --message="Closing port $port..." --weight=1
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
if yunohost firewall list | grep -q "\- 67$"
then
ynh_print_info "Close port 67"
ynh_exec_quiet yunohost firewall disallow UDP 67
ynh_script_progression --message="Closing port 67..." --weight=1
ynh_exec_warn_less yunohost firewall disallow UDP 67
fi
#=================================================
@ -137,6 +123,15 @@ ynh_secure_remove --file="/etc/bash_completion.d/pihole"
# Remove sudoer file
ynh_secure_remove --file="/etc/sudoers.d/pihole"
# Remove storage directory
ynh_secure_remove --file="/etc/pihole"
# Remove app directory
ynh_secure_remove --file="/opt/pihole"
# Remove admin panel directory
ynh_secure_remove --file="$final_path"
# Remove local clone of the repository
ynh_secure_remove --file="/etc/.pihole"
#=================================================
# REMOVE DNSMASQ CONFIG
#=================================================
@ -182,6 +177,7 @@ ynh_script_progression --message="Removing the dedicated system user..." --weigh
# Dirty hack to remove correctly the user
killall -u $app
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -14,13 +14,16 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=2
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
@ -39,9 +42,10 @@ fpm_service=$(ynh_app_setting_get --app=$app --key=fpm_service)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# ACTIVATE MAINTENANCE MODE
@ -51,25 +55,19 @@ ynh_script_progression --message="Activating maintenance mode..." --weight=2
ynh_maintenance_mode_ON
#=================================================
# STANDARD RESTORE STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE MAIN DIRECTORIES OF THE APP
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
@ -84,10 +82,20 @@ chown $app: -R "/etc/pihole"
# /etc/pihole/logrotate have to belong to root, otherwise logrotate will failed silently...
chown root: -R "/etc/pihole/logrotate"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=12
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=7
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=7
# Restore the file first, so it can have a backup if different
ynh_restore_file --origin_path="$fpm_config_dir/php-fpm-$app.conf"
@ -97,19 +105,11 @@ ynh_restore_file --origin_path="$fpm_config_dir/pool.d/$app.conf"
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
#=================================================
# SPECIFIC RESTORE
# RESTORE THE NGINX CONFIGURATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=12
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add pihole-FTL --description="PiHole backend service" --log="/var/log/pihole-FTL.log"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE CRON FILE
@ -222,9 +222,16 @@ ynh_replace_string --match_string="^IPV4_ADDRESS=.*" --replace_string="IPV4_ADDR
ynh_store_file_checksum --file="$setupVars"
#=================================================
# START PIHOLE-FTL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Restarting PiHole-FTL..." --weight=2
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add pihole-FTL --description="PiHole backend service" --log="/var/log/pihole-FTL.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_exec_warn_less systemctl enable pihole-FTL --quiet
ynh_systemd_action --action=restart --service_name=pihole-FTL
@ -234,7 +241,7 @@ ynh_systemd_action --action=restart --service_name=pihole-FTL
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=$fpm_service --action=reload
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
source _common.sh
source /usr/share/yunohost/helpers
@ -37,7 +36,7 @@ fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
@ -49,6 +48,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
read -p "999"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
@ -117,43 +117,13 @@ if [ -z "$pihole_version" ]; then
ynh_app_setting_set --app=$app --key=pihole_version --value="$pihole_version"
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=7
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Activating maintenance mode..."
ynh_maintenance_mode_ON
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=6
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -171,18 +141,6 @@ fi
chown $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
# Overwrite the nginx configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ]
then
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
@ -202,6 +160,18 @@ then
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
# Overwrite the nginx configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ]
then
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
#=================================================
# SPECIFIC UPGRADE
#=================================================
@ -356,14 +326,14 @@ ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --ta
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add pihole-FTL --description="PiHole backend service" --log="/var/log/pihole-FTL.log"
#=================================================
# UPDATE CONF_REGEN HOOK
#=================================================
ynh_script_progression --message="Updating conf_regen hook..."
ynh_script_progression --message="Updating conf_regen hook..." --weight=1
cp ../conf/dnsmasq_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
@ -381,7 +351,7 @@ ynh_systemd_action --action=restart --service_name=pihole-FTL
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --action=reload --service_name=nginx