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

Merge remote-tracking branch 'origin/remove-old-version' into 5.7

This commit is contained in:
ericgaspar 2022-01-24 23:43:39 +01:00
commit 7a715f5140
No known key found for this signature in database
GPG key ID: 574F281483054D44
19 changed files with 152 additions and 373 deletions

View file

@ -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

View file

@ -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

View file

@ -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&

View file

@ -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

View file

@ -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

View file

@ -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=

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -72,20 +72,6 @@
"fr": "Si vous voulez faire ça, <a href=https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md target=_blank>vous devez vraiment lire cela avant</a> !"
},
"default": false
},
{
"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.<br>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.<br>Voir le readme pour plus d'informations."
},
"choices": ["Last 3.X","Last available"],
"default": "Last 3.X"
}
]
}

View file

@ -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

View file

@ -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

View file

@ -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
#=================================================

View file

@ -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
#=================================================

View file

@ -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)
@ -152,38 +151,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
@ -217,18 +214,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
#=================================================

View file

@ -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