From c40317222ff5d46de7a763809addc66edc688c51 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Thu, 6 Jan 2022 14:48:11 +0100 Subject: [PATCH 1/3] WIP: remove old version of pihole --- check_process | 20 --- conf/{FTL_last.src => FTL.src} | 0 conf/FTL_3.src | 5 - ...dashboard_last.src => admin_dashboard.src} | 0 conf/admin_dashboard_3.src | 5 - conf/{app_last.src => app.src} | 0 conf/app_3.src | 6 - doc/DISCLAIMER.md | 2 - doc/DISCLAIMER_fr.md | 2 - manifest.json | 14 -- scripts/_variables | 13 +- scripts/actions/reset_default_app | 75 +++------- scripts/install | 135 +++++------------- scripts/remove | 45 +++--- scripts/restore | 63 ++++---- scripts/upgrade | 131 ++++++----------- 16 files changed, 149 insertions(+), 367 deletions(-) rename conf/{FTL_last.src => FTL.src} (100%) delete mode 100644 conf/FTL_3.src rename conf/{admin_dashboard_last.src => admin_dashboard.src} (100%) delete mode 100644 conf/admin_dashboard_3.src rename conf/{app_last.src => app.src} (100%) delete mode 100644 conf/app_3.src diff --git a/check_process b/check_process index 0931364..020c8a2 100644 --- a/check_process +++ b/check_process @@ -5,7 +5,6 @@ admin="john" query_logging=1 enable_dhcp=0 - pihole_version="Last available" ; Config_panel main.overwrite_files.overwrite_setupvars=0|1 main.overwrite_files.overwrite_ftl=0|1 @@ -30,25 +29,6 @@ change_url=1 actions=1 config_panel=1 -;; Test version 3 - ; Manifest - domain="domain.tld" - path="/path" - admin="john" - query_logging=1 - enable_dhcp=0 - pihole_version="Last 3.X" - ; Checks - setup_sub_dir=1 - setup_root=1 - upgrade=1 - upgrade=1 from_commit=d79ec131b3038ff4695c3317b5d3ee4eda9c8932 - backup_restore=1 - actions=1 ;;; Options Email= Notification=change -;;; Upgrade options - ; commit=d79ec131b3038ff4695c3317b5d3ee4eda9c8932 - name= Stretch fix - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&query_logging=1& diff --git a/conf/FTL_last.src b/conf/FTL.src similarity index 100% rename from conf/FTL_last.src rename to conf/FTL.src diff --git a/conf/FTL_3.src b/conf/FTL_3.src deleted file mode 100644 index 5c35de5..0000000 --- a/conf/FTL_3.src +++ /dev/null @@ -1,5 +0,0 @@ -SOURCE_URL=https://github.com/pi-hole/FTL/archive/v3.0.tar.gz -SOURCE_SUM=8c3d55eb3054698172e59ae81b8562ce235d73da461389840da62d90b32f0057 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true diff --git a/conf/admin_dashboard_last.src b/conf/admin_dashboard.src similarity index 100% rename from conf/admin_dashboard_last.src rename to conf/admin_dashboard.src diff --git a/conf/admin_dashboard_3.src b/conf/admin_dashboard_3.src deleted file mode 100644 index d892835..0000000 --- a/conf/admin_dashboard_3.src +++ /dev/null @@ -1,5 +0,0 @@ -SOURCE_URL=https://github.com/pi-hole/AdminLTE/archive/v3.3.tar.gz -SOURCE_SUM=caba2129fe8753b0c7aaf611b7c7b2146ff1ac56d5ac58987053b1553d09c49f -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true diff --git a/conf/app_last.src b/conf/app.src similarity index 100% rename from conf/app_last.src rename to conf/app.src diff --git a/conf/app_3.src b/conf/app_3.src deleted file mode 100644 index ac08837..0000000 --- a/conf/app_3.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v3.3.1.tar.gz -SOURCE_SUM=6a80e4b6b38fc65df83459fe52f3a61623763709a077645f25ac9e29247e6d6d -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 02f09ba..fdd0fd7 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -5,8 +5,6 @@ Use the admin panel of your Pi-hole to configure this app. You may also need to ## Limitations * Activate DHCP with Pi-hole needs manual configuration of your router. -* Pi-Hole can't be updated beyond version 3.3.1, because higher versions use an integrated version of dnsmasq. This would require disabling the version of dnsmasq used by YunoHost. - ## Using Pi-hole as your DHCP server diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index b5f17f2..a8c55e6 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -5,8 +5,6 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl ## Limitations * Activer DHCP avec Pi-hole nécessite une configuration manuelle de votre routeur. -* Pi-Hole ne peut pas être mis à jour au-delà de la version 3.3.1, car les versions supérieures utilisent une version intégrée de dnsmasq. Ce qui oblige a désactiver la version de dnsmasq utilisée par YunoHost. - ## Faire de Pi-hole votre serveur DHCP diff --git a/manifest.json b/manifest.json index d36de66..b3a59f0 100644 --- a/manifest.json +++ b/manifest.json @@ -72,20 +72,6 @@ "fr": "Si vous voulez faire ça, vous devez vraiment lire cela avant !" }, "default": false - }, - { - "name": "pihole_version", - "type": "string", - "ask": { - "en": "Which version of Pi-Hole do you want to install?", - "fr": "Quelle version de Pi-Hole voulez-vous installer ?" - }, - "help": { - "en": "The last 3.X version is the last version available with the Debian version of dnsmasq. The last available version will replace the Debian version of dnsmasq by FTLDNS.
See the readme for more information.", - "fr": "La dernière version 3.X est la dernière version disponible avec la version Debian de dnsmasq. La dernière version disponible remplacera la version Debian de dnsmasq par FTLDNS.
Voir le readme pour plus d'informations." - }, - "choices": ["Last 3.X","Last available"], - "default": "Last 3.X" } ] } diff --git a/scripts/_variables b/scripts/_variables index f6ca2f5..b613306 100644 --- a/scripts/_variables +++ b/scripts/_variables @@ -3,13 +3,6 @@ # Dependencies app_depencencies="sqlite3 idn2 php7.3-sqlite3 nettle-dev libcap2-bin build-essential libgmp-dev m4 cmake libidn11-dev libreadline-dev xxd" -if [ "$YNH_APP_ARG_PIHOLE_VERSION" == "Last 3.X" ] -then - pihole_core_version=3.3.1 - dashboard_version=3.3 - FTL_version=3.0 -else - pihole_core_version=5.6 - dashboard_version=5.8 - FTL_version=5.11 -fi +pihole_core_version=5.6 +dashboard_version=5.8 +FTL_version=5.11 diff --git a/scripts/actions/reset_default_app b/scripts/actions/reset_default_app index adbebb1..61a94d7 100755 --- a/scripts/actions/reset_default_app +++ b/scripts/actions/reset_default_app @@ -32,7 +32,6 @@ app=$YNH_APP_INSTANCE_NAME path_url=$(ynh_app_setting_get --app=$app --key=path) domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -pihole_version="$(ynh_app_setting_get --app=$app --key=pihole_version)" #================================================= # SPECIFIC ACTION @@ -58,21 +57,14 @@ 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 -if [ "$pihole_version" == "Last 3.X" ] -then - # Overwrite the version 3.3.1 - YNH_CWD=$PWD ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_3 - # Overwrite admin dashboard - YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_3 -else +( + cd scripts # Overwrite the last version available - YNH_CWD=$PWD ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_last + 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_last -fi + 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" ) @@ -133,12 +125,7 @@ chown $dnsmasq_user:root /var/log/{pihole,pihole-FTL}.log #================================================= # This sudoers config allow pihole to execute /usr/local/bin/pihole as root without password. Nothing more. -if [ "$pihole_version" == "Last 3.X" ] -then - cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole -else - cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole -fi +cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole echo "$app ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole # echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole chmod 0440 /etc/sudoers.d/pihole @@ -147,12 +134,7 @@ chmod 0440 /etc/sudoers.d/pihole # REINSTALL LOGROTATE SCRIPT FOR PI-HOLE #================================================= -if [ "$pihole_version" == "Last 3.X" ] -then - cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate" -else - cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate" -fi +cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate" sed -i "/# su #/d;" "$pihole_storage/logrotate" #================================================= @@ -162,19 +144,15 @@ ynh_script_progression --message="Reinstalling PiHole-FTL..." --weight=30 # Get the source of Pi-Hole-FTL FTL_temp_path=$(mktemp -d) -if [ "$pihole_version" == "Last 3.X" ] -then - # Install the version 3.3.1 - ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_3 -else - # Install the last version available - ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_last -fi +# 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 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" cp "../conf/dns-servers.conf" "$pihole_storage" @@ -182,20 +160,12 @@ cp "../conf/dns-servers.conf" "$pihole_storage" # Restore the default pihole-FTL.conf yunohost app action run $app reset_default_ftl -if [ "$pihole_version" == "Last 3.X" ] -then - # Version 3.3.1 - cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL - chmod +x /etc/init.d/pihole-FTL - ynh_exec_warn_less systemctl enable pihole-FTL -else - cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL - chmod +x /etc/init.d/pihole-FTL - ynh_exec_warn_less systemctl enable pihole-FTL +cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL +chmod +x /etc/init.d/pihole-FTL +ynh_exec_warn_less systemctl enable pihole-FTL - # Reload systemd config - systemctl daemon-reload -fi +# Reload systemd config +systemctl daemon-reload #================================================= # RESET THE VARIABLES FILE @@ -215,12 +185,7 @@ yunohost app action run $app reset_default_dnsmasq # REINSTALL CRON JOB #================================================= -if [ "$pihole_version" == "Last 3.X" ] -then - cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole -else - cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole -fi +cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole # Remove git usage for version. Which fails because we use here a release instead of master. ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole diff --git a/scripts/install b/scripts/install index 3258471..e5a844b 100644 --- a/scripts/install +++ b/scripts/install @@ -28,7 +28,6 @@ path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN query_logging=$YNH_APP_ARG_QUERY_LOGGING enable_dhcp=$YNH_APP_ARG_ENABLE_DHCP -pihole_version="$YNH_APP_ARG_PIHOLE_VERSION" app=$YNH_APP_INSTANCE_NAME @@ -53,7 +52,6 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=query_logging --value=$query_logging ynh_app_setting_set --app=$app --key=enable_dhcp --value=$enable_dhcp -ynh_app_setting_set --app=$app --key=pihole_version --value="$pihole_version" ynh_app_setting_set --app=$app --key=overwrite_setupvars --value=1 ynh_app_setting_set --app=$app --key=overwrite_ftl --value=1 @@ -103,18 +101,11 @@ ynh_script_progression --message="Setting up source files..." --weight=4 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Make a copy of local pihole repository (for Gravity) pihole_local_repo="/etc/.pihole" -if [ "$pihole_version" == "Last 3.X" ] -then - # Install the version 3.3.1 - ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_3 - # Install admin dashboard - ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_3 -else - # Install the last version available - ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_last - # Install admin dashboard - ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_last -fi + +# Install the last version available +ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app +# Install admin dashboard +ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard chown $app:www-data "$final_path" @@ -177,12 +168,7 @@ chown $dnsmasq_user:root /var/log/{pihole,pihole-FTL}.log #================================================= # This sudoers config allow pihole to execute /usr/local/bin/pihole as root without password. Nothing more. -if [ "$pihole_version" == "Last 3.X" ] -then - cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole -else - cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole -fi +cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole echo "$app ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole # echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole chmod 0440 /etc/sudoers.d/pihole @@ -191,12 +177,7 @@ chmod 0440 /etc/sudoers.d/pihole # INSTALL LOGROTATE SCRIPT FOR PI-HOLE #================================================= -if [ "$pihole_version" == "Last 3.X" ] -then - cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate" -else - cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate" -fi +cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate" sed -i "/# su #/d;" "$pihole_storage/logrotate" #================================================= @@ -206,65 +187,51 @@ ynh_script_progression --message="Installing PiHole-FTL..." --weight=30 # Get the source of Pi-Hole-FTL FTL_temp_path=$(mktemp -d) -if [ "$pihole_version" == "Last 3.X" ] -then - # Install the version 3.3.1 - ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_3 -else - # Install the last version available - ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_last -fi +# 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" -if [ "$pihole_version" == "Last available" ] -then +( + cd "$FTL_temp_path" ynh_exec_warn_less cmake . -fi -ynh_exec_warn_less make -ynh_exec_warn_less make install ) + ynh_exec_warn_less make + ynh_exec_warn_less make install +) ynh_secure_remove --file="$FTL_temp_path" cp "../conf/dns-servers.conf" "$pihole_storage" ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf" -if [ "$pihole_version" == "Last 3.X" ] -then - # Version 3.3.1 - cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL - chmod +x /etc/init.d/pihole-FTL - ynh_exec_warn_less systemctl enable pihole-FTL --quiet -else - # Last version available - # Stopped dnsmasq to replace it by pihole-FTL - ynh_systemd_action --action=stop --service_name=dnsmasq +# Last version available +# Stopped dnsmasq to replace it by pihole-FTL +ynh_systemd_action --action=stop --service_name=dnsmasq - # Disable the real dnsmasq service - ynh_exec_warn_less systemctl disable dnsmasq --quiet +# Disable the real dnsmasq service +#ynh_exec_warn_less systemctl disable dnsmasq --quiet - # And move the files that make the service available in systemd to really disable it - mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole - mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole +# And move the files that make the service available in systemd to really disable it +#mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole +#mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole - # Move dnsmasq to preserve the current binary - mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole - # Replace dnsmasq by pihole-FTL - # NOTE: pihole-FTL is actually a modified version of dnsmasq - # https://github.com/pi-hole/FTL/tree/master/dnsmasq - ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq +# Move dnsmasq to preserve the current binary +#mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole +# Replace dnsmasq by pihole-FTL +# NOTE: pihole-FTL is actually a modified version of dnsmasq +# https://github.com/pi-hole/FTL/tree/master/dnsmasq +#ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq - cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL - chmod +x /etc/init.d/pihole-FTL - ynh_exec_warn_less systemctl enable pihole-FTL --quiet +cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL +chmod +x /etc/init.d/pihole-FTL +ynh_exec_warn_less systemctl enable pihole-FTL --quiet - # Replace the service dnsmasq by pihole-FTL - # That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL - ln -s /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service +# Replace the service dnsmasq by pihole-FTL +# That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL +#ln -s /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service +systemctl mask dnsmasq.service - # Reload systemd config - systemctl daemon-reload -fi +# Reload systemd config +systemctl daemon-reload #================================================= # BUILD VARIABLES FILE @@ -327,41 +294,17 @@ echo "$pihole_core_version $dashboard_version $FTL_version" | tee $pihole_storag # INSTALL CRON JOB #================================================= -if [ "$pihole_version" == "Last 3.X" ] -then - cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole -else - cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole -fi +cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole # Remove git usage for version. Which fails because we use here a release instead of master. ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole -#================================================= -# RESTART DNSMASQ -#================================================= - -# Restart dnsmasq only for the version 3.X, otherwise we're going to restart it twice. -if [ "$pihole_version" == "Last 3.X" ] -then - ynh_script_progression --message="Restarting Dnsmasq..." --weight=2 - - ynh_systemd_action --action=restart --service_name=dnsmasq - - ynh_systemd_action --action=restart --service_name=pihole-FTL -fi - #================================================= # BUILD THE LISTS WITH GRAVITY #================================================= ynh_script_progression --message="Building the lists with Gravity..." --weight=7 -if [ "$pihole_version" == "Last 3.X" ] -then - cp "$pihole_local_repo/adlists.default" "$pihole_storage/adlists.default" -else - cp "../conf/adlists.default" "$pihole_storage/adlists.list" -fi +cp "../conf/adlists.default" "$pihole_storage/adlists.list" ynh_exec_warn_less /opt/pihole/gravity.sh #================================================= diff --git a/scripts/remove b/scripts/remove index 0870673..007425d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) -pihole_version="$(ynh_app_setting_get --app=$app --key=pihole_version)" #================================================= # STANDARD REMOVE @@ -38,30 +37,25 @@ fi #================================================= ynh_script_progression --message="Stop and remove the service" -if [ "$pihole_version" == "Last 3.X" ] -then - ynh_systemd_action --action=stop --service_name=pihole-FTL - ynh_exec_warn_less systemctl disable pihole-FTL --quiet -else - ynh_systemd_action --action=stop --service_name=pihole-FTL +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 - fi +# 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 +#fi - # Move back the service configuration for dnsmasq - ynh_secure_remove --file="/etc/systemd/system/dnsmasq.service" - mv /lib/systemd/system/.dnsmasq.service.backup_by_pihole /lib/systemd/system/dnsmasq.service - mv /etc/init.d/.dnsmasq.backup_by_pihole /etc/init.d/dnsmasq +# Move back the service configuration for dnsmasq +#ynh_secure_remove --file="/etc/systemd/system/dnsmasq.service" +#mv /lib/systemd/system/.dnsmasq.service.backup_by_pihole /lib/systemd/system/dnsmasq.service +#mv /etc/init.d/.dnsmasq.backup_by_pihole /etc/init.d/dnsmasq +systemctl unmask dnsmasq.service - ynh_exec_warn_less systemctl enable dnsmasq --quiet - # Reload systemd config - systemctl daemon-reload -fi +#ynh_exec_warn_less systemctl enable dnsmasq --quiet +# Reload systemd config +systemctl daemon-reload ynh_secure_remove --file="/etc/init.d/pihole-FTL" ynh_secure_remove --file="/usr/bin/pihole-FTL" @@ -188,11 +182,8 @@ ynh_systemd_action --action=restart --service_name=dnsmasq #================================================= ynh_script_progression --message="Removing the dedicated system user..." --weight=2 -if [ "$pihole_version" == "Last 3.X" ] -then - # Dirty hack to remove correctly the user - killall -u $app -fi +# Dirty hack to remove correctly the user +killall -u $app ynh_system_user_delete --username=$app #================================================= diff --git a/scripts/restore b/scripts/restore index a0f1e61..e8e9d74 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,7 +31,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) enable_dhcp=$(ynh_app_setting_get --app=$app --key=enable_dhcp) admin=$(ynh_app_setting_get --app=$app --key=admin) -pihole_version="$(ynh_app_setting_get --app=$app --key=pihole_version)" # Get variables from ynh_add_fpm_config fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) @@ -153,38 +152,36 @@ ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_ # REPLACE THE DEFAULT DNSMASQ BY PIHOLE-FTL #================================================= -if [ "$pihole_version" == "Last available" ] -then - # Last version available - # Stopped dnsmasq to replace it by pihole-FTL - ynh_systemd_action --action=stop --service_name=dnsmasq +# Last version available +# Stopped dnsmasq to replace it by pihole-FTL +ynh_systemd_action --action=stop --service_name=dnsmasq - # Disable the real dnsmasq service - ynh_exec_warn_less systemctl disable dnsmasq --quiet +# Disable the real dnsmasq service +#ynh_exec_warn_less systemctl disable dnsmasq --quiet - # And move the files that make the service available in systemd to really disable it - mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole - mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole +# And move the files that make the service available in systemd to really disable it +#mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole +#mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole - # Move dnsmasq to preserve the current binary - mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole - # Replace dnsmasq by pihole-FTL - # NOTE: pihole-FTL is actually a modified version of dnsmasq - # https://github.com/pi-hole/FTL/tree/master/dnsmasq - ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq +# Move dnsmasq to preserve the current binary +#mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole +# Replace dnsmasq by pihole-FTL +# NOTE: pihole-FTL is actually a modified version of dnsmasq +# https://github.com/pi-hole/FTL/tree/master/dnsmasq +#ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq - pihole_local_repo="/etc/.pihole" - cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL - chmod +x /etc/init.d/pihole-FTL - ynh_exec_warn_less systemctl enable pihole-FTL --quiet +pihole_local_repo="/etc/.pihole" +cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL +chmod +x /etc/init.d/pihole-FTL +ynh_exec_warn_less systemctl enable pihole-FTL --quiet - # Replace the service dnsmasq by pihole-FTL - # That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL - ln -s /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service +# Replace the service dnsmasq by pihole-FTL +# That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL +#ln -s /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service +systemctl mask dnsmasq.service - # Reload systemd config - systemctl daemon-reload -fi +# Reload systemd config +systemctl daemon-reload #================================================= # RESTORE DNSMASQ CONFIG @@ -218,18 +215,6 @@ do echo "$localipv4 $perdomain #Added by pihole#" >> /etc/hosts done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')" -#================================================= -# RESTART DNSMASQ -#================================================= - -# Restart dnsmasq only for the version 3.X, otherwise we're going to restart it twice. -if [ "$pihole_version" == "Last 3.X" ] -then - ynh_script_progression --message="Restarting Dnsmasq..." - - ynh_systemd_action --action=restart --service_name=dnsmasq -fi - #================================================= # UPDATE VARIABLES FILE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9bb1904..40e6f71 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -141,18 +141,10 @@ pihole_local_repo="/etc/.pihole" if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=4 - if [ "$pihole_version" == "Last 3.X" ] - then - # Update the version 3.X - ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_3 - # Update admin dashboard - ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_3 - else - # Update the last version available - ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_last - # Update admin dashboard - ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_last - fi + # 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" @@ -207,12 +199,7 @@ cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion. #================================================= # This sudoers config allow pihole to execute /usr/local/bin/pihole as root without password. Nothing more. -if [ "$pihole_version" == "Last 3.X" ] -then - cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole -else - cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole -fi +cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole echo "$app ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole chmod 0440 /etc/sudoers.d/pihole @@ -221,14 +208,7 @@ chmod 0440 /etc/sudoers.d/pihole #================================================= pihole_storage="/etc/pihole" -if [ "$pihole_version" == "Last 3.X" ] -then - cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate" - dnsmasq_user=$(grep DNSMASQ_USER= /etc/init.d/dnsmasq | cut -d'"' -f2) -else - cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate" - dnsmasq_user=$(grep FTLUSER= /etc/init.d/pihole-FTL | cut -d'=' -f2) -fi +cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate" sed -i "/# su #/d;" "$pihole_storage/logrotate" #================================================= @@ -242,23 +222,16 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then # Get the source of Pi-Hole-FTL FTL_temp_path=$(mktemp -d) - if [ "$pihole_version" == "Last 3.X" ] - then - # Install the version 3.3.1 - ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_3 - else - # Install the last version available - ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_last - fi + # 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" - if [ "$pihole_version" == "Last available" ] - then + ( + cd "$FTL_temp_path" ynh_exec_warn_less cmake . - fi - ynh_exec_warn_less make - ynh_exec_warn_less make install ) + ynh_exec_warn_less make + ynh_exec_warn_less make install + ) ynh_secure_remove --file="$FTL_temp_path" fi @@ -268,48 +241,41 @@ then ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf" fi -if [ "$pihole_version" == "Last 3.X" ] -then - # Version 3.3.1 - cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL - chmod +x /etc/init.d/pihole-FTL - ynh_exec_warn_less systemctl enable pihole-FTL --quiet -else - # Last version available - # Stopped dnsmasq to replace it by pihole-FTL - ynh_systemd_action --action=stop --service_name=dnsmasq +# Last version available +# Stopped dnsmasq to replace it by pihole-FTL +ynh_systemd_action --action=stop --service_name=dnsmasq - # Disable the real dnsmasq service - ynh_exec_warn_less systemctl disable dnsmasq --quiet +# Disable the real dnsmasq service +#ynh_exec_warn_less systemctl disable dnsmasq --quiet - # 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 - fi - if [ ! -e "/etc/init.d/.dnsmasq.backup_by_pihole" ]; then - mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole - fi +# 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 +#fi +#if [ ! -e "/etc/init.d/.dnsmasq.backup_by_pihole" ]; then +# 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 - fi - # Replace dnsmasq by pihole-FTL - # NOTE: pihole-FTL is actually a modified version of dnsmasq - # https://github.com/pi-hole/FTL/tree/master/dnsmasq - ln -sf /usr/bin/pihole-FTL /usr/sbin/dnsmasq +# 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 +#fi +# Replace dnsmasq by pihole-FTL +# NOTE: pihole-FTL is actually a modified version of dnsmasq +# https://github.com/pi-hole/FTL/tree/master/dnsmasq +#ln -sf /usr/bin/pihole-FTL /usr/sbin/dnsmasq - cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL - chmod +x /etc/init.d/pihole-FTL - ynh_exec_warn_less systemctl enable pihole-FTL --quiet +cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL +chmod +x /etc/init.d/pihole-FTL +ynh_exec_warn_less systemctl enable pihole-FTL --quiet - # Replace the service dnsmasq by pihole-FTL - # That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL - ln -sf /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service +# Replace the service dnsmasq by pihole-FTL +# That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL +#ln -sf /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service +systemctl mask dnsmasq.service - # Reload systemd config - systemctl daemon-reload -fi +# Reload systemd config +systemctl daemon-reload #================================================= # BUILD VARIABLES FILE @@ -353,12 +319,7 @@ echo "$pihole_core_version $dashboard_version $FTL_version" | tee $pihole_storag # UPDATE CRON JOB #================================================= -if [ "$pihole_version" == "Last 3.X" ] -then - cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole -else - cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole -fi +cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole # Remove git usage for version. Which fails because we use here a release instead of master. ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole @@ -372,10 +333,8 @@ yunohost service add pihole-FTL --description="PiHole backend service" --log="/v # UPDATE CONF_REGEN HOOK #================================================= -ynh_add_config --template="../conf/dnsmasq_regenconf_hook" --destination="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app" - -#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" +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" systemctl daemon-reload ynh_exec_warn_less yunohost tools regen-conf dnsmasq From 16696e479b9558d57c9e1fc4eccc4c6d1f0be81f Mon Sep 17 00:00:00 2001 From: Kay0u Date: Thu, 6 Jan 2022 14:48:25 +0100 Subject: [PATCH 2/3] fix dnsmasq regenconf --- conf/dnsmasq_regenconf_hook | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conf/dnsmasq_regenconf_hook b/conf/dnsmasq_regenconf_hook index e181ac4..54419ff 100755 --- a/conf/dnsmasq_regenconf_hook +++ b/conf/dnsmasq_regenconf_hook @@ -37,9 +37,10 @@ fi # ynh_replace_string --match_string="^cache-size=" --replace_string="#pihole# cache-size=" --target_file="${pending_conf}/etc/dnsmasq.conf" -ynh_replace_string --match_string="^listen-address=" --replace_string="#pihole# cache-size=" --target_file="${pending_conf}/etc/dnsmasq.conf" +ynh_replace_string --match_string="^listen-address=" --replace_string="#pihole# listen-address=" --target_file="${pending_conf}/etc/dnsmasq.conf" -echo "conf-dir=/etc/dnsmasq.d/" >> "${pending_conf}/etc/dnsmasq.conf" +echo " +conf-dir=/etc/dnsmasq.d/" >> "${pending_conf}/etc/dnsmasq.conf" # # Regen /etc/dnsmasq.d/02-pihole-dhcp.conf From b4403336f04f315e4100862a1f8c4eed2ef3c200 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Thu, 6 Jan 2022 13:48:31 +0000 Subject: [PATCH 3/3] Auto-update README --- README.md | 2 -- README_fr.md | 2 -- 2 files changed, 4 deletions(-) diff --git a/README.md b/README.md index fa661f7..d09912f 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,6 @@ Use the admin panel of your Pi-hole to configure this app. You may also need to ## Limitations * Activate DHCP with Pi-hole needs manual configuration of your router. -* Pi-Hole can't be updated beyond version 3.3.1, because higher versions use an integrated version of dnsmasq. This would require disabling the version of dnsmasq used by YunoHost. - ## Using Pi-hole as your DHCP server diff --git a/README_fr.md b/README_fr.md index 89be07a..8f39f19 100644 --- a/README_fr.md +++ b/README_fr.md @@ -30,8 +30,6 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl ## Limitations * Activer DHCP avec Pi-hole nécessite une configuration manuelle de votre routeur. -* Pi-Hole ne peut pas être mis à jour au-delà de la version 3.3.1, car les versions supérieures utilisent une version intégrée de dnsmasq. Ce qui oblige a désactiver la version de dnsmasq utilisée par YunoHost. - ## Faire de Pi-hole votre serveur DHCP