mirror of
https://github.com/YunoHost-Apps/pihole_ynh.git
synced 2024-09-03 20:05:58 +02:00
Start to work on an upgrade to 4.x
This commit is contained in:
parent
67a49f5b8c
commit
2beb564e7c
11 changed files with 156 additions and 29 deletions
6
conf/FTL_last.src
Normal file
6
conf/FTL_last.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://github.com/pi-hole/FTL/archive/v4.3.1.tar.gz
|
||||||
|
SOURCE_SUM=1c0df5fa42e7f7b89c7e704fdc1b5154
|
||||||
|
SOURCE_SUM_PRG=md5sum
|
||||||
|
SOURCE_FORMAT=tar.gz
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=
|
19
conf/adlists.default
Normal file
19
conf/adlists.default
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# The below list amalgamates several lists we used previously.
|
||||||
|
# See `https://github.com/StevenBlack/hosts` for details
|
||||||
|
##StevenBlack's list
|
||||||
|
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
||||||
|
|
||||||
|
##MalwareDomains
|
||||||
|
https://mirror1.malwaredomains.com/files/justdomains
|
||||||
|
|
||||||
|
##Cameleon
|
||||||
|
http://sysctl.org/cameleon/hosts
|
||||||
|
|
||||||
|
##Disconnect.me Tracking
|
||||||
|
https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
|
||||||
|
|
||||||
|
##Disconnect.me Ads
|
||||||
|
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
||||||
|
|
||||||
|
##Hosts-file.net
|
||||||
|
https://hosts-file.net/ad_servers.txt
|
6
conf/admin_dashboard_last.src
Normal file
6
conf/admin_dashboard_last.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://github.com/pi-hole/AdminLTE/archive/v4.3.3.tar.gz
|
||||||
|
SOURCE_SUM=3f9da0e1f9134393758b7a1425ca66f6
|
||||||
|
SOURCE_SUM_PRG=md5sum
|
||||||
|
SOURCE_FORMAT=tar.gz
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=
|
6
conf/app_last.src
Normal file
6
conf/app_last.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v4.4.tar.gz
|
||||||
|
SOURCE_SUM=970013bf8e273b868dd184ac2ffb1348
|
||||||
|
SOURCE_SUM_PRG=md5sum
|
||||||
|
SOURCE_FORMAT=tar.gz
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=
|
|
@ -76,6 +76,20 @@
|
||||||
"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> !"
|
"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
|
"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.",
|
||||||
|
"fr": "The last available version will replace the Debian version of dnsmasq by FTLDNS.<br>See the readme for more information."
|
||||||
|
},
|
||||||
|
"choices" : ["Last 3.X","Last available"],
|
||||||
|
"default": "Last 3.X"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
app_depencencies="sqlite idn2 php7.0-sqlite3"
|
app_depencencies="sqlite idn2 php7.0-sqlite3 nettle-dev libcap2-bin"
|
||||||
|
|
105
scripts/install
105
scripts/install
|
@ -28,6 +28,7 @@ path_url=$YNH_APP_ARG_PATH
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
query_logging=$YNH_APP_ARG_QUERY_LOGGING
|
query_logging=$YNH_APP_ARG_QUERY_LOGGING
|
||||||
enable_dhcp=$YNH_APP_ARG_ENABLE_DHCP
|
enable_dhcp=$YNH_APP_ARG_ENABLE_DHCP
|
||||||
|
pihole_version="$YNH_APP_ARG_PIHOLE_VERSION"
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ 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=admin --value=$admin
|
||||||
ynh_app_setting_set --app=$app --key=query_logging --value=$query_logging
|
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=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_setupvars --value=1
|
||||||
ynh_app_setting_set --app=$app --key=overwrite_ftl --value=1
|
ynh_app_setting_set --app=$app --key=overwrite_ftl --value=1
|
||||||
|
@ -95,9 +97,18 @@ ynh_script_progression --message="Setting up source files..." --weight=4
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
# Make a copy of local pihole repository (for Gravity)
|
# Make a copy of local pihole repository (for Gravity)
|
||||||
pihole_local_repo="/etc/.pihole"
|
pihole_local_repo="/etc/.pihole"
|
||||||
ynh_setup_source --dest_dir="$pihole_local_repo"
|
if [ "$pihole_version" == "Last 3.X" ]
|
||||||
# Install admin dashboard
|
then
|
||||||
ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
|
# 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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -166,7 +177,12 @@ chown $dnsmasq_user:root /var/log/pihole.log
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# This sudoers config allow pihole to execute /usr/local/bin/pihole as root without password. Nothing more.
|
# This sudoers config allow pihole to execute /usr/local/bin/pihole as root without password. Nothing more.
|
||||||
cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole
|
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
|
||||||
echo "$app ALL=NOPASSWD: /usr/local/bin/pihole" >> /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
|
# echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole
|
||||||
chmod 0440 /etc/sudoers.d/pihole
|
chmod 0440 /etc/sudoers.d/pihole
|
||||||
|
@ -175,7 +191,12 @@ chmod 0440 /etc/sudoers.d/pihole
|
||||||
# INSTALL LOGROTATE SCRIPT FOR PI-HOLE
|
# INSTALL LOGROTATE SCRIPT FOR PI-HOLE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate"
|
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
|
||||||
sed -i "/# su #/d;" "$pihole_storage/logrotate"
|
sed -i "/# su #/d;" "$pihole_storage/logrotate"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -185,7 +206,14 @@ ynh_script_progression --message="Installing PiHole-FTL..." --weight=30
|
||||||
|
|
||||||
# Get the source of Pi-Hole-FTL
|
# Get the source of Pi-Hole-FTL
|
||||||
FTL_temp_path=$(mktemp -d)
|
FTL_temp_path=$(mktemp -d)
|
||||||
ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
|
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
|
||||||
|
|
||||||
# Instead of downloading a binary file, we're going to compile it
|
# Instead of downloading a binary file, we're going to compile it
|
||||||
( cd "$FTL_temp_path"
|
( cd "$FTL_temp_path"
|
||||||
|
@ -197,9 +225,24 @@ cp "../conf/pihole-FTL.conf" "$pihole_storage"
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$pihole_storage/pihole-FTL.conf"
|
ynh_store_file_checksum --file="$pihole_storage/pihole-FTL.conf"
|
||||||
|
|
||||||
cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL
|
if [ "$pihole_version" == "Last 3.X" ]
|
||||||
chmod +x /etc/init.d/pihole-FTL
|
then
|
||||||
ynh_exec_warn_less systemctl enable pihole-FTL
|
# Version 3.3.1
|
||||||
|
cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL
|
||||||
|
chmod +x /etc/init.d/q
|
||||||
|
ynh_exec_warn_less systemctl enable pihole-FTL
|
||||||
|
else
|
||||||
|
# Last version available
|
||||||
|
# Stopped dnsmasq to replace it by pihole-FTL
|
||||||
|
ynh_systemd_action --action=stop --service_name=dnsmasq
|
||||||
|
# Move dnsmasq to preserve the current version
|
||||||
|
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
|
||||||
|
update-alternatives --install /usr/sbin/dnsmasq dnsmasq /usr/bin/pihole-FTL 50
|
||||||
|
update-alternatives --install /usr/sbin/dnsmasq dnsmasq /usr/sbin/dnsmasq.backup_by_pihole 40
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD VARIABLES FILE
|
# BUILD VARIABLES FILE
|
||||||
|
@ -312,6 +355,20 @@ fi
|
||||||
# Open the UDP port 67 for dhcp
|
# Open the UDP port 67 for dhcp
|
||||||
ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp
|
ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -320,28 +377,29 @@ ynh_script_progression --message="Restarting Dnsmasq..." --weight=2
|
||||||
ynh_systemd_action --action=restart --service_name=dnsmasq
|
ynh_systemd_action --action=restart --service_name=dnsmasq
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL CRON JOB
|
# START PIHOLE-FTL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
|
if [ "$pihole_version" == "Last 3.X" ]
|
||||||
# Remove git usage for version. Which fails because we use here a release instead of master.
|
then
|
||||||
ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole
|
ynh_script_progression --message="Restarting PiHole-FTL..." --weight=2
|
||||||
|
|
||||||
|
ynh_systemd_action --action=restart --service_name=pihole-FTL
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD THE LISTS WITH GRAVITY
|
# BUILD THE LISTS WITH GRAVITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building the lists with Gravity..." --weight=7
|
ynh_script_progression --message="Building the lists with Gravity..." --weight=7
|
||||||
|
|
||||||
cp "$pihole_local_repo/adlists.default" "$pihole_storage/adlists.default"
|
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
|
||||||
ynh_exec_warn_less /opt/pihole/gravity.sh
|
ynh_exec_warn_less /opt/pihole/gravity.sh
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# START PIHOLE-FTL
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restarting PiHole-FTL..." --weight=2
|
|
||||||
|
|
||||||
ynh_systemd_action --action=restart --service_name=pihole-FTL
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SET UP CONF_REGEN HOOK
|
# SET UP CONF_REGEN HOOK
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -354,7 +412,10 @@ cp ../conf/dnsmasq_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-dnsmas
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
yunohost service add pihole-FTL --description "PiHole backend service" --log "/var/log/pihole-FTL.log"
|
if [ "$pihole_version" == "Last 3.X" ]
|
||||||
|
then
|
||||||
|
yunohost service add pihole-FTL --description "PiHole backend service" --log "/var/log/pihole-FTL.log"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTRAIN THE ACCESS TO THE ADMIN ONLY
|
# RESTRAIN THE ACCESS TO THE ADMIN ONLY
|
||||||
|
|
|
@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
pihole_version="$(ynh_app_setting_get --app=$app --key=pihole_version)"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -25,11 +26,14 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
# REMOVE SERVICE FROM ADMIN PANEL
|
# REMOVE SERVICE FROM ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Check if the service is declared in YunoHost
|
if [ "$pihole_version" == "Last 3.X" ]
|
||||||
if ynh_exec_fully_quiet yunohost service status pihole-FTL
|
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing pihole-FTL service..." --weight=2
|
# Check if the service is declared in YunoHost
|
||||||
yunohost service remove pihole-FTL
|
if ynh_exec_fully_quiet yunohost service status pihole-FTL
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Removing pihole-FTL service..." --weight=2
|
||||||
|
yunohost service remove pihole-FTL
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -37,8 +41,19 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stop and remove the service"
|
ynh_script_progression --message="Stop and remove the service"
|
||||||
|
|
||||||
ynh_systemd_action --action=stop --service_name=pihole-FTL
|
if [ "$pihole_version" == "Last 3.X" ]
|
||||||
ynh_exec_warn_less systemctl disable pihole-FTL
|
then
|
||||||
|
ynh_systemd_action --action=stop --service_name=pihole-FTL
|
||||||
|
ynh_exec_warn_less systemctl disable pihole-FTL
|
||||||
|
else
|
||||||
|
ynh_systemd_action --action=stop --service_name=dnsmasq
|
||||||
|
# Restore dnsmasq as main DNS resolver
|
||||||
|
# Remove alternatives
|
||||||
|
update-alternatives --remove dnsmasq /usr/bin/pihole-FTL
|
||||||
|
update-alternatives --remove dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
|
||||||
|
# Move dnsmasq back to its original place
|
||||||
|
mv /usr/sbin/dnsmasq.backup_by_pihole /usr/sbin/dnsmasq
|
||||||
|
fi
|
||||||
rm -f "/etc/init.d/pihole-FTL" "/usr/bin/pihole-FTL" "/var/run/pihole-FTL.pid" "/var/run/pihole-FTL.port"
|
rm -f "/etc/init.d/pihole-FTL" "/usr/bin/pihole-FTL" "/var/run/pihole-FTL.pid" "/var/run/pihole-FTL.port"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue