|
|
@@ -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
|
|
|
-
|
|
|
- # 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
|
|
|
-
|
|
|
- # 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
|
|
|
-
|
|
|
- # 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
|
|
|
-
|
|
|
- # Reload systemd config
|
|
|
- systemctl daemon-reload
|
|
|
-fi
|
|
|
+# 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
|
|
|
+
|
|
|
+# 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
|
|
|
+
|
|
|
+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
|
|
|
+systemctl mask dnsmasq.service
|
|
|
+
|
|
|
+# 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
|
|
|
|
|
|
#=================================================
|