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:
parent
1c750f1ceb
commit
d815c03a89
18 changed files with 606 additions and 432 deletions
137
.github/workflows/updater.sh
vendored
Normal file
137
.github/workflows/updater.sh
vendored
Normal 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
49
.github/workflows/updater.yml
vendored
Normal 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
|
|
@ -3,3 +3,5 @@ SOURCE_SUM=67d01bd4245024c9c6f9bf474bb17e8bde269ccc42ba4bb5a99da25632162c21
|
|||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
||||
|
|
|
@ -3,3 +3,5 @@ SOURCE_SUM=e24db53c63a6ea240f0852bd082b224dda91ad4fd049ab700c218b9672fc59cf
|
|||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
||||
|
|
|
@ -27,9 +27,9 @@ ynh_replace_string --match_string="@INT@" --replace_string="$main_iface" --targe
|
|||
ynh_replace_string --match_string="@CACHE_SIZE@" --replace_string="1000" --target_file="$dnsmasq_dir/01-pihole.conf"
|
||||
query_logging=$(ynh_app_setting_get --app=$app --key=query_logging)
|
||||
if [ "$query_logging" = "true" ]; then
|
||||
ynh_replace_string --match_string="^#log-queries" --replace_string="log-queries" --target_file="$dnsmasq_dir/01-pihole.conf"
|
||||
ynh_replace_string --match_string="^#log-queries" --replace_string="log-queries" --target_file="$dnsmasq_dir/01-pihole.conf"
|
||||
else
|
||||
ynh_replace_string --match_string="^log-queries" --replace_string="#log-queries" --target_file="$dnsmasq_dir/01-pihole.conf"
|
||||
ynh_replace_string --match_string="^log-queries" --replace_string="#log-queries" --target_file="$dnsmasq_dir/01-pihole.conf"
|
||||
fi
|
||||
|
||||
#
|
||||
|
@ -50,36 +50,36 @@ enable_dhcp=$(ynh_app_setting_get --app=$app --key=enable_dhcp)
|
|||
if [ $enable_dhcp -eq 1 ]
|
||||
then
|
||||
|
||||
# Get the default network interface
|
||||
# Find the IP associated to the network interface
|
||||
localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
|
||||
# Get the default network interface
|
||||
# Find the IP associated to the network interface
|
||||
localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
|
||||
|
||||
max_dhcp_range=250
|
||||
dhcp_range=100
|
||||
max_dhcp_range=250
|
||||
dhcp_range=100
|
||||
|
||||
# Define the dhcp range from the current ip
|
||||
ip_beginning_part=$(echo "$localipv4" | cut -d. -f1-3)
|
||||
ip_fourth_part=$(echo "$localipv4" | cut -d. -f4)
|
||||
b_range=$(( $ip_fourth_part + $dhcp_range ))
|
||||
if [ $b_range -gt $max_dhcp_range ]; then
|
||||
b_range=$max_dhcp_range
|
||||
fi
|
||||
a_range=$(( $b_range - $dhcp_range ))
|
||||
# Define the dhcp range from the current ip
|
||||
ip_beginning_part=$(echo "$localipv4" | cut -d. -f1-3)
|
||||
ip_fourth_part=$(echo "$localipv4" | cut -d. -f4)
|
||||
b_range=$(( $ip_fourth_part + $dhcp_range ))
|
||||
if [ $b_range -gt $max_dhcp_range ]; then
|
||||
b_range=$max_dhcp_range
|
||||
fi
|
||||
a_range=$(( $b_range - $dhcp_range ))
|
||||
|
||||
# Get the gateway
|
||||
gateway=$(ip route | grep default | awk '{print $3;}')
|
||||
# And the mac adress
|
||||
hw_adress=$(ip link | grep -A1 "$main_iface" | tail -n1 | awk '{print $2;}')
|
||||
# Get the gateway
|
||||
gateway=$(ip route | grep default | awk '{print $3;}')
|
||||
# And the mac adress
|
||||
hw_adress=$(ip link | grep -A1 "$main_iface" | tail -n1 | awk '{print $2;}')
|
||||
|
||||
# Copy the config file
|
||||
cp -a "/etc/yunohost/apps/$app/conf/02-pihole-dhcp.conf" "$dnsmasq_dir/"
|
||||
# Copy the config file
|
||||
cp -a "/etc/yunohost/apps/$app/conf/02-pihole-dhcp.conf" "$dnsmasq_dir/"
|
||||
|
||||
# And set the config
|
||||
ynh_replace_string --match_string="__A_RANGE__" --replace_string="$ip_beginning_part.$a_range" --target_file="${pending_conf}/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||
ynh_replace_string --match_string="__B_RANGE__" --replace_string="$ip_beginning_part.$b_range" --target_file="${pending_conf}/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||
ynh_replace_string --match_string="__GATEWAY__" --replace_string="$gateway" --target_file="${pending_conf}/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||
# And set the config
|
||||
ynh_replace_string --match_string="__A_RANGE__" --replace_string="$ip_beginning_part.$a_range" --target_file="${pending_conf}/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||
ynh_replace_string --match_string="__B_RANGE__" --replace_string="$ip_beginning_part.$b_range" --target_file="${pending_conf}/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||
ynh_replace_string --match_string="__GATEWAY__" --replace_string="$gateway" --target_file="${pending_conf}/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||
|
||||
# Set a static ip for the server.
|
||||
echo "dhcp-host=$hw_adress,$localipv4" > "${dnsmasq_dir}/04-pihole-static-dhcp.conf"
|
||||
# Set a static ip for the server.
|
||||
echo "dhcp-host=$hw_adress,$localipv4" > "${dnsmasq_dir}/04-pihole-static-dhcp.conf"
|
||||
fi
|
||||
exit 0
|
||||
|
|
|
@ -6,16 +6,20 @@ location __PATH__/ {
|
|||
|
||||
index index.html index.php;
|
||||
|
||||
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;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
# 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;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
|
1
doc/DESCRIPTION_fr.md
Normal file
1
doc/DESCRIPTION_fr.md
Normal 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.
|
|
@ -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": [{
|
||||
"name": "Maniack Crudelis",
|
||||
"email": "maniackc_dev@crudelis.fr"
|
||||
}],
|
||||
"previous_maintainers": [
|
||||
{
|
||||
"name": "Maniack Crudelis",
|
||||
"email": "maniackc_dev@crudelis.fr"
|
||||
}
|
||||
],
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
|
@ -247,136 +247,136 @@ ynh_maintenance_mode_OFF () {
|
|||
#
|
||||
# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source]
|
||||
# | arg: -f --format= - Format in which the changelog will be printed
|
||||
# markdown: Default format.
|
||||
# html: Turn urls into html format.
|
||||
# plain: Plain text changelog
|
||||
# markdown: Default format.
|
||||
# html: Turn urls into html format.
|
||||
# plain: Plain text changelog
|
||||
# | arg: -o --output= - Output file for the changelog file (Default ./changelog)
|
||||
# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md)
|
||||
#
|
||||
# The changelog is printed into the file ./changelog and ./changelog_lite
|
||||
ynh_app_changelog () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=foc
|
||||
declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
|
||||
local format
|
||||
local output
|
||||
local changelog
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
format=${format:-markdown}
|
||||
output=${output:-changelog}
|
||||
changelog=${changelog:-../CHANGELOG.md}
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=foc
|
||||
declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
|
||||
local format
|
||||
local output
|
||||
local changelog
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
format=${format:-markdown}
|
||||
output=${output:-changelog}
|
||||
changelog=${changelog:-../CHANGELOG.md}
|
||||
|
||||
local original_changelog="$changelog"
|
||||
local temp_changelog="changelog_temp"
|
||||
local final_changelog="$output"
|
||||
local original_changelog="$changelog"
|
||||
local temp_changelog="changelog_temp"
|
||||
local final_changelog="$output"
|
||||
|
||||
if [ ! -n "$original_changelog" ]
|
||||
then
|
||||
echo "No changelog available..." > "$final_changelog"
|
||||
echo "No changelog available..." > "${final_changelog}_lite"
|
||||
return 0
|
||||
fi
|
||||
if [ ! -n "$original_changelog" ]
|
||||
then
|
||||
echo "No changelog available..." > "$final_changelog"
|
||||
echo "No changelog available..." > "${final_changelog}_lite"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
|
||||
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
|
||||
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
|
||||
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
|
||||
|
||||
# Get the line of the version to update to into the changelog
|
||||
local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
|
||||
# If there's no entry for this version yet into the changelog
|
||||
# Get the first available version
|
||||
if [ -z "$update_version_line" ]
|
||||
then
|
||||
update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
|
||||
fi
|
||||
# Get the line of the version to update to into the changelog
|
||||
local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
|
||||
# If there's no entry for this version yet into the changelog
|
||||
# Get the first available version
|
||||
if [ -z "$update_version_line" ]
|
||||
then
|
||||
update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
|
||||
fi
|
||||
|
||||
# Get the length of the complete changelog.
|
||||
local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
|
||||
# Cut the file before the version to update to.
|
||||
tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
|
||||
# Get the length of the complete changelog.
|
||||
local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
|
||||
# Cut the file before the version to update to.
|
||||
tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
|
||||
|
||||
# Get the length of the troncated changelog.
|
||||
changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
|
||||
# Get the line of the current version into the changelog
|
||||
# Keep only the last line found
|
||||
local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
|
||||
# If there's no entry for this version into the changelog
|
||||
# Get the last available version
|
||||
if [ -z "$current_version_line" ]
|
||||
then
|
||||
current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
|
||||
fi
|
||||
# Cut the file before the current version.
|
||||
# Then grep the previous version into the changelog to get the line number of the previous version
|
||||
local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
|
||||
"$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
|
||||
# If there's no previous version into the changelog
|
||||
# Go until the end of the changelog
|
||||
if [ -z "$previous_version_line" ]
|
||||
then
|
||||
previous_version_line=$changelog_length
|
||||
fi
|
||||
# Get the length of the troncated changelog.
|
||||
changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
|
||||
# Get the line of the current version into the changelog
|
||||
# Keep only the last line found
|
||||
local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
|
||||
# If there's no entry for this version into the changelog
|
||||
# Get the last available version
|
||||
if [ -z "$current_version_line" ]
|
||||
then
|
||||
current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
|
||||
fi
|
||||
# Cut the file before the current version.
|
||||
# Then grep the previous version into the changelog to get the line number of the previous version
|
||||
local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
|
||||
"$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
|
||||
# If there's no previous version into the changelog
|
||||
# Go until the end of the changelog
|
||||
if [ -z "$previous_version_line" ]
|
||||
then
|
||||
previous_version_line=$changelog_length
|
||||
fi
|
||||
|
||||
# Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
|
||||
head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
|
||||
# Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
|
||||
head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
|
||||
|
||||
if [ "$format" = "html" ]
|
||||
then
|
||||
# Replace markdown links by html links
|
||||
ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
|
||||
ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --target_file="$final_changelog"
|
||||
elif [ "$format" = "plain" ]
|
||||
then
|
||||
# Change title format.
|
||||
ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
|
||||
# Change modifications lines format.
|
||||
ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
|
||||
fi
|
||||
# else markdown. As the file is already in markdown, nothing to do.
|
||||
if [ "$format" = "html" ]
|
||||
then
|
||||
# Replace markdown links by html links
|
||||
ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
|
||||
ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --target_file="$final_changelog"
|
||||
elif [ "$format" = "plain" ]
|
||||
then
|
||||
# Change title format.
|
||||
ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
|
||||
# Change modifications lines format.
|
||||
ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
|
||||
fi
|
||||
# else markdown. As the file is already in markdown, nothing to do.
|
||||
|
||||
# Keep only important changes into the changelog
|
||||
# Remove all minor changes
|
||||
sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
|
||||
# Remove all blank lines (to keep a clear workspace)
|
||||
sed --in-place '/^$/d' "${final_changelog}_lite"
|
||||
# Add a blank line at the end
|
||||
echo "" >> "${final_changelog}_lite"
|
||||
# Keep only important changes into the changelog
|
||||
# Remove all minor changes
|
||||
sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
|
||||
# Remove all blank lines (to keep a clear workspace)
|
||||
sed --in-place '/^$/d' "${final_changelog}_lite"
|
||||
# Add a blank line at the end
|
||||
echo "" >> "${final_changelog}_lite"
|
||||
|
||||
# Clean titles if there's no significative changes
|
||||
local line
|
||||
local previous_line=""
|
||||
while read line <&3
|
||||
do
|
||||
if [ -n "$previous_line" ]
|
||||
then
|
||||
# Remove the line if it's a title or a blank line, and the previous one was a title as well.
|
||||
if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
|
||||
then
|
||||
ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
|
||||
fi
|
||||
fi
|
||||
previous_line="$line"
|
||||
done 3< "${final_changelog}_lite"
|
||||
# Clean titles if there's no significative changes
|
||||
local line
|
||||
local previous_line=""
|
||||
while read line <&3
|
||||
do
|
||||
if [ -n "$previous_line" ]
|
||||
then
|
||||
# Remove the line if it's a title or a blank line, and the previous one was a title as well.
|
||||
if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
|
||||
then
|
||||
ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
|
||||
fi
|
||||
fi
|
||||
previous_line="$line"
|
||||
done 3< "${final_changelog}_lite"
|
||||
|
||||
# Remove all blank lines again
|
||||
sed --in-place '/^$/d' "${final_changelog}_lite"
|
||||
# Remove all blank lines again
|
||||
sed --in-place '/^$/d' "${final_changelog}_lite"
|
||||
|
||||
# Restore changelog format with blank lines
|
||||
ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
|
||||
# Remove the 2 first blank lines
|
||||
sed --in-place '1,2d' "${final_changelog}_lite"
|
||||
# Add a blank line at the end
|
||||
echo "" >> "${final_changelog}_lite"
|
||||
# Restore changelog format with blank lines
|
||||
ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
|
||||
# Remove the 2 first blank lines
|
||||
sed --in-place '1,2d' "${final_changelog}_lite"
|
||||
# Add a blank line at the end
|
||||
echo "" >> "${final_changelog}_lite"
|
||||
|
||||
# If changelog are empty, add an info
|
||||
if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
|
||||
then
|
||||
echo "No changes from the changelog..." > "$final_changelog"
|
||||
fi
|
||||
if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
|
||||
then
|
||||
echo "No significative changes from the changelog..." > "${final_changelog}_lite"
|
||||
fi
|
||||
# If changelog are empty, add an info
|
||||
if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
|
||||
then
|
||||
echo "No changes from the changelog..." > "$final_changelog"
|
||||
fi
|
||||
if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
|
||||
then
|
||||
echo "No significative changes from the changelog..." > "${final_changelog}_lite"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remaining that are not handle by the remove script.
|
||||
ynh_clean_check_starting
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -56,13 +56,13 @@ ynh_script_progression --message="Resetting source files..." --weight=1
|
|||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
pihole_local_repo="/etc/.pihole"
|
||||
(
|
||||
cd scripts
|
||||
# Overwrite the last version available
|
||||
YNH_CWD=$PWD ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app
|
||||
# Overwrite admin dashboard
|
||||
YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
|
||||
cd scripts
|
||||
# Overwrite the last version available
|
||||
YNH_CWD=$PWD ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app
|
||||
# Overwrite admin dashboard
|
||||
YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
|
||||
|
||||
chown $app:www-data "$final_path"
|
||||
chown $app:www-data "$final_path"
|
||||
|
||||
)
|
||||
|
||||
|
@ -147,9 +147,9 @@ ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
|
|||
|
||||
# Instead of downloading a binary file, we're going to compile it
|
||||
(
|
||||
cd "$FTL_temp_path"
|
||||
ynh_exec_warn_less make
|
||||
ynh_exec_warn_less make install
|
||||
cd "$FTL_temp_path"
|
||||
ynh_exec_warn_less make
|
||||
ynh_exec_warn_less make install
|
||||
)
|
||||
ynh_secure_remove --file="$FTL_temp_path"
|
||||
|
||||
|
@ -193,9 +193,9 @@ ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --ta
|
|||
#=================================================
|
||||
|
||||
(
|
||||
cd scripts
|
||||
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"
|
||||
cd scripts
|
||||
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"
|
||||
)
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -31,9 +31,9 @@ query_logging=$(ynh_app_setting_get --app=$app --key=query_logging)
|
|||
file="$1"
|
||||
|
||||
if [ "$file" = "setupVars.conf" ]; then
|
||||
config_file="/etc/pihole/setupVars.conf"
|
||||
config_file="/etc/pihole/setupVars.conf"
|
||||
elif [ "$file" = "pihole-FTL.conf" ]; then
|
||||
config_file="/etc/pihole/pihole-FTL.conf"
|
||||
config_file="/etc/pihole/pihole-FTL.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -50,31 +50,31 @@ main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
|
|||
|
||||
if [ "$file" = "setupVars.conf" ]
|
||||
then
|
||||
# Recreate the default config
|
||||
# Trouve l'interface réseau par défaut
|
||||
echo "PIHOLE_INTERFACE=$main_iface" > "$config_file"
|
||||
echo "IPV4_ADDRESS=127.0.0.1" >> "$config_file"
|
||||
echo "IPV6_ADDRESS=::1" >> "$config_file"
|
||||
echo "PIHOLE_DNS_1=" >> "$config_file"
|
||||
echo "PIHOLE_DNS_2=" >> "$config_file"
|
||||
if [ $query_logging -eq 1 ]; then
|
||||
query_logging=true
|
||||
else
|
||||
query_logging=false
|
||||
fi
|
||||
echo "QUERY_LOGGING=$query_logging" >> "$config_file"
|
||||
echo "INSTALL_WEB=true" >> "$config_file"
|
||||
# Recreate the default config
|
||||
# Trouve l'interface réseau par défaut
|
||||
echo "PIHOLE_INTERFACE=$main_iface" > "$config_file"
|
||||
echo "IPV4_ADDRESS=127.0.0.1" >> "$config_file"
|
||||
echo "IPV6_ADDRESS=::1" >> "$config_file"
|
||||
echo "PIHOLE_DNS_1=" >> "$config_file"
|
||||
echo "PIHOLE_DNS_2=" >> "$config_file"
|
||||
if [ $query_logging -eq 1 ]; then
|
||||
query_logging=true
|
||||
else
|
||||
query_logging=false
|
||||
fi
|
||||
echo "QUERY_LOGGING=$query_logging" >> "$config_file"
|
||||
echo "INSTALL_WEB=true" >> "$config_file"
|
||||
|
||||
elif [ "$file" = "pihole-FTL.conf" ]
|
||||
then
|
||||
# Get the default file and overwrite the current config
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
ynh_add_config --template="/etc/yunohost/apps/$app/conf/pihole-FTL.conf" --destination="$config_file"
|
||||
# Get the default file and overwrite the current config
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
ynh_add_config --template="/etc/yunohost/apps/$app/conf/pihole-FTL.conf" --destination="$config_file"
|
||||
|
||||
ynh_script_progression --message="Restarting Pi-Hole..." --weight=2
|
||||
ynh_script_progression --message="Restarting Pi-Hole..." --weight=2
|
||||
|
||||
# Restart pihole-FTL
|
||||
ynh_systemd_action --action=restart --service_name=pihole-FTL
|
||||
# Restart pihole-FTL
|
||||
ynh_systemd_action --action=restart --service_name=pihole-FTL
|
||||
fi
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
|
|
|
@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remaining that are not handle by the remove script.
|
||||
ynh_clean_check_starting
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -39,22 +39,22 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
#=================================================
|
||||
|
||||
if [ $type == nginx ]; then
|
||||
name=Nginx
|
||||
name=Nginx
|
||||
elif [ $type == phpfpm ]; then
|
||||
name=PHP-FPM
|
||||
name=PHP-FPM
|
||||
else
|
||||
ynh_die --message="The type $type is not recognized"
|
||||
ynh_die --message="The type $type is not recognized"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Resetting the specific configuration of $name for the app $app..." --weight=3
|
||||
|
||||
if [ $type == nginx ]
|
||||
then
|
||||
(cd scripts; ynh_add_nginx_config)
|
||||
(cd scripts; ynh_add_nginx_config)
|
||||
|
||||
elif [ $type == phpfpm ]
|
||||
then
|
||||
(cd scripts; ynh_add_fpm_config --usage=low --footprint=low --dedicated_service)
|
||||
(cd scripts; ynh_add_fpm_config --usage=low --footprint=low --dedicated_service)
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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"
|
||||
|
|
130
scripts/config
130
scripts/config
|
@ -59,11 +59,11 @@ fpm_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT:-$old_fpm_footprint}"
|
|||
# Check if fpm_footprint is an integer
|
||||
if [ "$fpm_footprint" -eq "$fpm_footprint" ] 2> /dev/null
|
||||
then
|
||||
# If fpm_footprint is an integer, that's a numeric value for the footprint
|
||||
old_free_footprint=$fpm_footprint
|
||||
fpm_footprint=specific
|
||||
# If fpm_footprint is an integer, that's a numeric value for the footprint
|
||||
old_free_footprint=$fpm_footprint
|
||||
fpm_footprint=specific
|
||||
else
|
||||
old_free_footprint=0
|
||||
old_free_footprint=0
|
||||
fi
|
||||
free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footprint}"
|
||||
|
||||
|
@ -75,7 +75,7 @@ fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}"
|
|||
old_php_forced_max_children="$(ynh_app_setting_get --app=$app --key=php_forced_max_children)"
|
||||
# If php_forced_max_children isn't into settings.yml, get the current value from the fpm config
|
||||
if [ -z "$old_php_forced_max_children" ]; then
|
||||
old_php_forced_max_children="$(grep "^pm.max_children" "$fpm_config_dir/pool.d/$app.conf" | awk '{print $3}')"
|
||||
old_php_forced_max_children="$(grep "^pm.max_children" "$fpm_config_dir/pool.d/$app.conf" | awk '{print $3}')"
|
||||
fi
|
||||
php_forced_max_children="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN:-$old_php_forced_max_children}"
|
||||
|
||||
|
@ -84,20 +84,20 @@ php_forced_max_children="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN:-$o
|
|||
#=================================================
|
||||
|
||||
show_config() {
|
||||
# here you are supposed to read some config file/database/other then print the values
|
||||
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||
# here you are supposed to read some config file/database/other then print the values
|
||||
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS=$overwrite_setupvars"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL=$overwrite_ftl"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS=$overwrite_setupvars"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL=$overwrite_ftl"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
||||
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint"
|
||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint"
|
||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage"
|
||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN=$php_forced_max_children"
|
||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint"
|
||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint"
|
||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage"
|
||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN=$php_forced_max_children"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -106,60 +106,60 @@ show_config() {
|
|||
|
||||
apply_config() {
|
||||
|
||||
#=================================================
|
||||
# MODIFY OVERWRITTING SETTINGS
|
||||
#=================================================
|
||||
#=================================================
|
||||
# MODIFY OVERWRITTING SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Set overwrite_setupvars
|
||||
ynh_app_setting_set --app=$app --key=overwrite_setupvars --value="$overwrite_setupvars"
|
||||
# Set overwrite_ftl
|
||||
ynh_app_setting_set --app=$app --key=overwrite_ftl --value="$overwrite_ftl"
|
||||
# Set overwrite_nginx
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
|
||||
# Set overwrite_phpfpm
|
||||
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="$overwrite_phpfpm"
|
||||
# Set overwrite_setupvars
|
||||
ynh_app_setting_set --app=$app --key=overwrite_setupvars --value="$overwrite_setupvars"
|
||||
# Set overwrite_ftl
|
||||
ynh_app_setting_set --app=$app --key=overwrite_ftl --value="$overwrite_ftl"
|
||||
# Set overwrite_nginx
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
|
||||
# Set overwrite_phpfpm
|
||||
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="$overwrite_phpfpm"
|
||||
|
||||
#=================================================
|
||||
# MODIFY EMAIL SETTING
|
||||
#=================================================
|
||||
#=================================================
|
||||
# MODIFY EMAIL SETTING
|
||||
#=================================================
|
||||
|
||||
# Set admin_mail_html
|
||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
||||
# Set admin_mail_html
|
||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
||||
|
||||
#=================================================
|
||||
# RECONFIGURE PHP-FPM
|
||||
#=================================================
|
||||
#=================================================
|
||||
# RECONFIGURE PHP-FPM
|
||||
#=================================================
|
||||
|
||||
if [ "$fpm_usage" != "$old_fpm_usage" ] || \
|
||||
[ "$fpm_footprint" != "$old_fpm_footprint" ] || \
|
||||
[ "$free_footprint" != "$old_free_footprint" ] || \
|
||||
[ "$php_forced_max_children" != "$old_php_forced_max_children" ]
|
||||
then
|
||||
# If fpm_footprint is set to 'specific', use $free_footprint value.
|
||||
if [ "$fpm_footprint" = "specific" ]
|
||||
then
|
||||
fpm_footprint=$free_footprint
|
||||
fi
|
||||
if [ "$fpm_usage" != "$old_fpm_usage" ] || \
|
||||
[ "$fpm_footprint" != "$old_fpm_footprint" ] || \
|
||||
[ "$free_footprint" != "$old_free_footprint" ] || \
|
||||
[ "$php_forced_max_children" != "$old_php_forced_max_children" ]
|
||||
then
|
||||
# If fpm_footprint is set to 'specific', use $free_footprint value.
|
||||
if [ "$fpm_footprint" = "specific" ]
|
||||
then
|
||||
fpm_footprint=$free_footprint
|
||||
fi
|
||||
|
||||
if [ "$php_forced_max_children" != "$old_php_forced_max_children" ]
|
||||
then
|
||||
# Set php_forced_max_children
|
||||
if [ $php_forced_max_children -ne 0 ]
|
||||
then
|
||||
ynh_app_setting_set --app=$app --key=php_forced_max_children --value="$php_forced_max_children"
|
||||
else
|
||||
# If the value is set to 0, remove the setting
|
||||
ynh_app_setting_delete --app=$app --key=php_forced_max_children
|
||||
fi
|
||||
fi
|
||||
if [ "$php_forced_max_children" != "$old_php_forced_max_children" ]
|
||||
then
|
||||
# Set php_forced_max_children
|
||||
if [ $php_forced_max_children -ne 0 ]
|
||||
then
|
||||
ynh_app_setting_set --app=$app --key=php_forced_max_children --value="$php_forced_max_children"
|
||||
else
|
||||
# If the value is set to 0, remove the setting
|
||||
ynh_app_setting_delete --app=$app --key=php_forced_max_children
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$fpm_footprint" != "0" ]
|
||||
then
|
||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
|
||||
else
|
||||
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
|
||||
fi
|
||||
fi
|
||||
if [ "$fpm_footprint" != "0" ]
|
||||
then
|
||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
|
||||
else
|
||||
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -169,6 +169,6 @@ apply_config() {
|
|||
#=================================================
|
||||
|
||||
case $1 in
|
||||
show) show_config;;
|
||||
apply) apply_config;;
|
||||
show) show_config;;
|
||||
apply) apply_config;;
|
||||
esac
|
||||
|
|
|
@ -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
|
||||
|
@ -192,10 +194,10 @@ ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
|
|||
|
||||
# Instead of downloading a binary file, we're going to compile it
|
||||
(
|
||||
cd "$FTL_temp_path"
|
||||
ynh_exec_warn_less cmake .
|
||||
ynh_exec_warn_less make
|
||||
ynh_exec_warn_less make install
|
||||
cd "$FTL_temp_path"
|
||||
ynh_exec_warn_less cmake .
|
||||
ynh_exec_warn_less make
|
||||
ynh_exec_warn_less make install
|
||||
)
|
||||
|
||||
ynh_secure_remove --file="$FTL_temp_path"
|
||||
|
@ -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"
|
||||
|
||||
|
|
|
@ -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,26 +26,26 @@ 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
|
||||
|
||||
# Restore dnsmasq as main DNS resolver
|
||||
# Move dnsmasq back to its original place
|
||||
#if [ -e "/usr/sbin/dnsmasq.backup_by_pihole" ]
|
||||
#then # Remove dnsmasq only if we have its backup
|
||||
# ynh_secure_remove --file="/usr/sbin/dnsmasq"
|
||||
# mv /usr/sbin/dnsmasq.backup_by_pihole /usr/sbin/dnsmasq
|
||||
#then # Remove dnsmasq only if we have its backup
|
||||
# ynh_secure_remove --file="/usr/sbin/dnsmasq"
|
||||
# mv /usr/sbin/dnsmasq.backup_by_pihole /usr/sbin/dnsmasq
|
||||
#fi
|
||||
|
||||
# Move back the service configuration for dnsmasq
|
||||
|
@ -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
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
|
|
108
scripts/upgrade
108
scripts/upgrade
|
@ -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
|
||||
|
@ -162,27 +132,15 @@ ynh_system_user_create --username=$app
|
|||
pihole_local_repo="/etc/.pihole"
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=4
|
||||
# Update the last version available
|
||||
ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app
|
||||
# Update admin dashboard
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=4
|
||||
# Update the last version available
|
||||
ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app
|
||||
# Update admin dashboard
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
|
||||
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
|
||||
#=================================================
|
||||
|
@ -249,19 +219,19 @@ ynh_systemd_action --action=stop --service_name=pihole-FTL
|
|||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
# Get the source of Pi-Hole-FTL
|
||||
FTL_temp_path=$(mktemp -d)
|
||||
# Install the last version available
|
||||
ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
|
||||
# Get the source of Pi-Hole-FTL
|
||||
FTL_temp_path=$(mktemp -d)
|
||||
# Install the last version available
|
||||
ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
|
||||
|
||||
# Instead of downloading a binary file, we're going to compile it
|
||||
(
|
||||
cd "$FTL_temp_path"
|
||||
ynh_exec_warn_less cmake .
|
||||
ynh_exec_warn_less make
|
||||
ynh_exec_warn_less make install
|
||||
)
|
||||
ynh_secure_remove --file="$FTL_temp_path"
|
||||
# Instead of downloading a binary file, we're going to compile it
|
||||
(
|
||||
cd "$FTL_temp_path"
|
||||
ynh_exec_warn_less cmake .
|
||||
ynh_exec_warn_less make
|
||||
ynh_exec_warn_less make install
|
||||
)
|
||||
ynh_secure_remove --file="$FTL_temp_path"
|
||||
fi
|
||||
|
||||
# Overwrite pihole-FTL config file only if it's allowed
|
||||
|
@ -279,15 +249,15 @@ ynh_systemd_action --action=stop --service_name=dnsmasq
|
|||
|
||||
# And move the files that make the service available in systemd to really disable it
|
||||
#if [ ! -e "/lib/systemd/system/.dnsmasq.service.backup_by_pihole" ]; then
|
||||
# mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole
|
||||
# mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole
|
||||
#fi
|
||||
#if [ ! -e "/etc/init.d/.dnsmasq.backup_by_pihole" ]; then
|
||||
# mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole
|
||||
# mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole
|
||||
#fi
|
||||
|
||||
# Move dnsmasq to preserve the current binary
|
||||
#if [ ! -e "/usr/sbin/dnsmasq.backup_by_pihole" ]; then
|
||||
# mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
|
||||
# mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
|
||||
#fi
|
||||
# Replace dnsmasq by pihole-FTL
|
||||
# NOTE: pihole-FTL is actually a modified version of dnsmasq
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue