mirror of
https://github.com/YunoHost-Apps/pihole_ynh.git
synced 2024-09-03 20:05:58 +02:00
Fix
This commit is contained in:
parent
5cc3670440
commit
3c22639cae
6 changed files with 32 additions and 39 deletions
|
@ -19,7 +19,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -31,11 +31,13 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MAIN APP DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..." --weight=5
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="/etc/.pihole"
|
||||
|
@ -45,14 +47,12 @@ ynh_backup --src_path="/opt/pihole"
|
|||
#=================================================
|
||||
# BACKUP NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up php-fpm configuration..."
|
||||
|
||||
ynh_backup --src_path="$fpm_config_dir/php-fpm-$app.conf"
|
||||
ynh_backup --src_path="$fpm_config_dir/pool.d/$app.conf"
|
||||
|
@ -62,14 +62,12 @@ ynh_backup --src_path="$fpm_config_dir/pool.d/$app.conf"
|
|||
#=================================================
|
||||
# BACKUP CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up cron file..."
|
||||
|
||||
ynh_backup --src_path="/etc/cron.d/pihole"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SPECIFIC FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing specific files..."
|
||||
|
||||
ynh_backup --src_path="/usr/local/bin/pihole"
|
||||
ynh_backup --src_path="/etc/bash_completion.d/pihole"
|
||||
|
@ -96,4 +94,4 @@ ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=11
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=11
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -75,7 +75,7 @@ fi
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --weight=4
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=4
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
|
@ -109,7 +109,7 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
|
@ -66,14 +66,16 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
|
|||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring firewall..." --weight=12
|
||||
ynh_script_progression --message="Finding an available port..." --weight=12
|
||||
|
||||
# Find a free port
|
||||
port=$(ynh_find_port --port=4711)
|
||||
if [ $port -gt 4720 ]
|
||||
then
|
||||
ynh_die --message="The ports 4711 to 4720 are already in use. Pi-hole can't works on another port. Please try to free one of this ports."
|
||||
ynh_die --message="The ports 4711 to 4720 are already in use. Pi-hole can't work on another port. Please try to free one of these ports."
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
||||
# Open this port
|
||||
ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
@ -238,14 +240,14 @@ 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
|
||||
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
|
||||
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
|
||||
|
@ -260,7 +262,7 @@ 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
|
||||
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
|
||||
|
@ -447,7 +449,7 @@ cp ../conf/dnsmasq_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-dnsmas
|
|||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
yunohost service add pihole-FTL --description "PiHole backend service" --log "/var/log/pihole-FTL.log"
|
||||
yunohost service add pihole-FTL --description="PiHole backend service" --log="/var/log/pihole-FTL.log" --needs_exposed_ports="$port"
|
||||
|
||||
#=================================================
|
||||
# RESTRAIN THE ACCESS TO THE ADMIN ONLY
|
||||
|
@ -459,7 +461,7 @@ ynh_permission_update --permission="main" --add="$admin" --remove="all_users"
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=3
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=3
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ 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
|
||||
ynh_exec_warn_less systemctl disable pihole-FTL --quiet
|
||||
else
|
||||
ynh_systemd_action --action=stop --service_name=pihole-FTL
|
||||
|
||||
|
@ -58,7 +58,7 @@ else
|
|||
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
|
||||
|
||||
ynh_exec_warn_less systemctl enable dnsmasq
|
||||
ynh_exec_warn_less systemctl enable dnsmasq --quiet
|
||||
# Reload systemd config
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
@ -93,7 +93,7 @@ ynh_secure_remove --file="/etc/.pihole"
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing nginx web server configuration..."
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -101,7 +101,7 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing php-fpm configuration..." --weight=2
|
||||
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
@ -109,7 +109,7 @@ ynh_remove_fpm_config
|
|||
#=================================================
|
||||
# CLOSE PORTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Closing port $port et 67..." --weight=13
|
||||
ynh_script_progression --message="Closing ports $port et 67..." --weight=13
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
|
|
|
@ -97,7 +97,7 @@ chown root: -R "/etc/pihole/logrotate"
|
|||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reconfiguring php-fpm..." --weight=7
|
||||
ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=7
|
||||
|
||||
# Restore the file first, so it can have a backup if different
|
||||
ynh_restore_file --origin_path="$fpm_config_dir/php-fpm-$app.conf"
|
||||
|
@ -265,7 +265,7 @@ ynh_systemd_action --action=restart --service_name=pihole-FTL
|
|||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..."
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
|
||||
|
||||
ynh_systemd_action --service_name=$fpm_service --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
@ -286,7 +286,7 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
|
|||
|
||||
if [ $enable_dhcp -eq 1 ]
|
||||
then
|
||||
dhcp_alert="You asked to use the internal DHCP server of dnsmasq with PiHole.
|
||||
dhcp_alert="You asked to use the internal DHCP server of Dnsmasq with PiHole.
|
||||
You should really read the __URL_TAG1__documentation about that__URL_TAG2__https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md__URL_TAG3__
|
||||
|
||||
"
|
||||
|
|
|
@ -109,13 +109,6 @@ ynh_clean_setup () {
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
@ -171,7 +164,7 @@ chown $app:www-data "$final_path"
|
|||
# Overwrite the nginx configuration only if it's allowed
|
||||
if [ $overwrite_nginx -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
@ -183,7 +176,7 @@ fi
|
|||
# Overwrite the php-fpm configuration only if it's allowed
|
||||
if [ $overwrite_phpfpm -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=3
|
||||
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=3
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
|
||||
fi
|
||||
|
@ -284,14 +277,14 @@ 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
|
||||
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
|
||||
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
|
||||
|
@ -377,7 +370,7 @@ ynh_systemd_action --action=restart --service_name=pihole-FTL
|
|||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
yunohost service add pihole-FTL --description "PiHole backend service" --log "/var/log/pihole-FTL.log"
|
||||
yunohost service add pihole-FTL --description="PiHole backend service" --log="/var/log/pihole-FTL.log" --needs_exposed_ports="$port"
|
||||
|
||||
#=================================================
|
||||
# UPDATE CONF_REGEN HOOK
|
||||
|
@ -388,7 +381,7 @@ cp ../conf/dnsmasq_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-dnsmas
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue