|
@@ -1,7 +1,7 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
-# GENERIC STARTING
|
|
|
|
|
|
|
+# GENERIC START
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# IMPORT GENERIC HELPERS
|
|
# IMPORT GENERIC HELPERS
|
|
|
#=================================================
|
|
#=================================================
|
|
@@ -30,16 +30,40 @@ overwrite_setupvars=$(ynh_app_setting_get --app=$app --key=overwrite_setupvars)
|
|
|
overwrite_ftl=$(ynh_app_setting_get --app=$app --key=overwrite_ftl)
|
|
overwrite_ftl=$(ynh_app_setting_get --app=$app --key=overwrite_ftl)
|
|
|
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
|
|
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
|
|
|
overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)
|
|
overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)
|
|
|
-
|
|
|
|
|
|
|
+admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
|
|
|
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
|
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
|
|
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
|
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# CHECK VERSION
|
|
# CHECK VERSION
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Checking version..."
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
|
|
+#=================================================
|
|
|
|
|
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
|
+#=================================================
|
|
|
|
|
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=7
|
|
|
|
|
+
|
|
|
|
|
+# Backup the current version of the app
|
|
|
|
|
+ynh_backup_before_upgrade
|
|
|
|
|
+ynh_clean_setup () {
|
|
|
|
|
+ # Restore it if the upgrade fails
|
|
|
|
|
+ ynh_restore_upgradebackup
|
|
|
|
|
+}
|
|
|
|
|
+# Exit if an error occurs during the execution of the script
|
|
|
|
|
+ynh_abort_if_errors
|
|
|
|
|
+
|
|
|
|
|
+#=================================================
|
|
|
|
|
+# ACTIVATE MAINTENANCE MODE
|
|
|
|
|
+#=================================================
|
|
|
|
|
+ynh_script_progression --message="Activating maintenance mode..."
|
|
|
|
|
+
|
|
|
|
|
+ynh_maintenance_mode_ON
|
|
|
|
|
+
|
|
|
|
|
+#=================================================
|
|
|
|
|
+# STANDARD UPGRADE STEPS
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
#=================================================
|
|
#=================================================
|
|
@@ -47,50 +71,50 @@ ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
|
|
|
|
# If overwrite_setupvars doesn't exist, create it
|
|
# If overwrite_setupvars doesn't exist, create it
|
|
|
if [ -z "$overwrite_setupvars" ]; then
|
|
if [ -z "$overwrite_setupvars" ]; then
|
|
|
- overwrite_setupvars=1
|
|
|
|
|
- ynh_app_setting_set --app=$app --key=overwrite_setupvars --value=$overwrite_setupvars
|
|
|
|
|
|
|
+ overwrite_setupvars=1
|
|
|
|
|
+ ynh_app_setting_set --app=$app --key=overwrite_setupvars --value=$overwrite_setupvars
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# If overwrite_ftl doesn't exist, create it
|
|
# If overwrite_ftl doesn't exist, create it
|
|
|
if [ -z "$overwrite_ftl" ]; then
|
|
if [ -z "$overwrite_ftl" ]; then
|
|
|
- overwrite_ftl=1
|
|
|
|
|
- ynh_app_setting_set --app=$app --key=overwrite_ftl --value=$overwrite_ftl
|
|
|
|
|
|
|
+ overwrite_ftl=1
|
|
|
|
|
+ ynh_app_setting_set --app=$app --key=overwrite_ftl --value=$overwrite_ftl
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# If overwrite_nginx doesn't exist, create it
|
|
# If overwrite_nginx doesn't exist, create it
|
|
|
if [ -z "$overwrite_nginx" ]; then
|
|
if [ -z "$overwrite_nginx" ]; then
|
|
|
- overwrite_nginx=1
|
|
|
|
|
- ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
|
|
|
|
|
|
|
+ overwrite_nginx=1
|
|
|
|
|
+ ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# If overwrite_phpfpm doesn't exist, create it
|
|
# If overwrite_phpfpm doesn't exist, create it
|
|
|
if [ -z "$overwrite_phpfpm" ]; then
|
|
if [ -z "$overwrite_phpfpm" ]; then
|
|
|
- overwrite_phpfpm=1
|
|
|
|
|
- ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm
|
|
|
|
|
|
|
+ overwrite_phpfpm=1
|
|
|
|
|
+ ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# If admin_mail_html doesn't exist, create it
|
|
# If admin_mail_html doesn't exist, create it
|
|
|
if [ -z "$admin_mail_html" ]; then
|
|
if [ -z "$admin_mail_html" ]; then
|
|
|
- admin_mail_html=1
|
|
|
|
|
- ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
|
|
|
|
|
|
+ admin_mail_html=1
|
|
|
|
|
+ ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# If fpm_footprint doesn't exist, create it
|
|
# If fpm_footprint doesn't exist, create it
|
|
|
if [ -z "$fpm_footprint" ]; then
|
|
if [ -z "$fpm_footprint" ]; then
|
|
|
- fpm_footprint=low
|
|
|
|
|
- ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
|
|
|
|
|
|
+ fpm_footprint=low
|
|
|
|
|
+ ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# If fpm_usage doesn't exist, create it
|
|
# If fpm_usage doesn't exist, create it
|
|
|
if [ -z "$fpm_usage" ]; then
|
|
if [ -z "$fpm_usage" ]; then
|
|
|
- fpm_usage=low
|
|
|
|
|
- ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
|
|
|
|
|
|
+ fpm_usage=low
|
|
|
|
|
+ ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# If pihole_version doesn't exist, create it
|
|
# If pihole_version doesn't exist, create it
|
|
|
if [ -z "$pihole_version" ]; then
|
|
if [ -z "$pihole_version" ]; then
|
|
|
- pihole_version="Last 3.X"
|
|
|
|
|
- ynh_app_setting_set --app=$app --key=pihole_version --value="$pihole_version"
|
|
|
|
|
|
|
+ pihole_version="Last 3.X"
|
|
|
|
|
+ ynh_app_setting_set --app=$app --key=pihole_version --value="$pihole_version"
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
@@ -154,11 +178,18 @@ chown $app:www-data "$final_path"
|
|
|
# Overwrite the nginx configuration only if it's allowed
|
|
# Overwrite the nginx configuration only if it's allowed
|
|
|
if [ $overwrite_nginx -eq 1 ]
|
|
if [ $overwrite_nginx -eq 1 ]
|
|
|
then
|
|
then
|
|
|
- ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
|
|
|
|
- # Create a dedicated nginx config
|
|
|
|
|
- ynh_add_nginx_config
|
|
|
|
|
|
|
+ ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
|
|
|
|
+ # Create a dedicated NGINX config
|
|
|
|
|
+ ynh_add_nginx_config
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
+#=================================================
|
|
|
|
|
+# UPGRADE DEPENDENCIES
|
|
|
|
|
+#=================================================
|
|
|
|
|
+ynh_script_progression --message="Upgrading dependencies..." --weight=6
|
|
|
|
|
+
|
|
|
|
|
+ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
+
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# PHP-FPM CONFIGURATION
|
|
# PHP-FPM CONFIGURATION
|
|
|
#=================================================
|
|
#=================================================
|
|
@@ -166,9 +197,9 @@ fi
|
|
|
# Overwrite the php-fpm configuration only if it's allowed
|
|
# Overwrite the php-fpm configuration only if it's allowed
|
|
|
if [ $overwrite_phpfpm -eq 1 ]
|
|
if [ $overwrite_phpfpm -eq 1 ]
|
|
|
then
|
|
then
|
|
|
- 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
|
|
|
|
|
|
|
+ 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
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
@@ -236,7 +267,7 @@ fi
|
|
|
# Overwrite pihole-FTL config file only if it's allowed
|
|
# Overwrite pihole-FTL config file only if it's allowed
|
|
|
if [ $overwrite_ftl -eq 1 ]
|
|
if [ $overwrite_ftl -eq 1 ]
|
|
|
then
|
|
then
|
|
|
- ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf"
|
|
|
|
|
|
|
+ ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf"
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# Last version available
|
|
# Last version available
|
|
@@ -284,26 +315,26 @@ setupVars="$pihole_storage/setupVars.conf"
|
|
|
# Overwrite the setupVars config file only if it's allowed
|
|
# Overwrite the setupVars config file only if it's allowed
|
|
|
if [ $overwrite_setupvars -eq 1 ]
|
|
if [ $overwrite_setupvars -eq 1 ]
|
|
|
then
|
|
then
|
|
|
- # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
|
|
|
|
- ynh_backup_if_checksum_is_different --file="$setupVars"
|
|
|
|
|
-
|
|
|
|
|
- # Get the default network interface
|
|
|
|
|
- main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
|
|
|
|
|
- echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
|
|
|
|
|
- echo "IPV4_ADDRESS=127.0.0.1" >> $setupVars
|
|
|
|
|
- echo "IPV6_ADDRESS=::1" >> $setupVars
|
|
|
|
|
- echo "PIHOLE_DNS_1=" >> $setupVars
|
|
|
|
|
- echo "PIHOLE_DNS_2=" >> $setupVars
|
|
|
|
|
- if [ $query_logging -eq 1 ]; then
|
|
|
|
|
- query_logging=true
|
|
|
|
|
- else
|
|
|
|
|
- query_logging=false
|
|
|
|
|
- fi
|
|
|
|
|
- echo "QUERY_LOGGING=$query_logging" >> $setupVars
|
|
|
|
|
- echo "INSTALL_WEB=true" >> $setupVars
|
|
|
|
|
-
|
|
|
|
|
- # Recalculate and store the checksum of the file for the next upgrade.
|
|
|
|
|
- ynh_store_file_checksum --file="$setupVars"
|
|
|
|
|
|
|
+ # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
|
|
|
|
+ ynh_backup_if_checksum_is_different --file="$setupVars"
|
|
|
|
|
+
|
|
|
|
|
+ # Get the default network interface
|
|
|
|
|
+ main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
|
|
|
|
|
+ echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
|
|
|
|
|
+ echo "IPV4_ADDRESS=127.0.0.1" >> $setupVars
|
|
|
|
|
+ echo "IPV6_ADDRESS=::1" >> $setupVars
|
|
|
|
|
+ echo "PIHOLE_DNS_1=" >> $setupVars
|
|
|
|
|
+ echo "PIHOLE_DNS_2=" >> $setupVars
|
|
|
|
|
+ if [ $query_logging -eq 1 ]; then
|
|
|
|
|
+ query_logging=true
|
|
|
|
|
+ else
|
|
|
|
|
+ query_logging=false
|
|
|
|
|
+ fi
|
|
|
|
|
+ echo "QUERY_LOGGING=$query_logging" >> $setupVars
|
|
|
|
|
+ echo "INSTALL_WEB=true" >> $setupVars
|
|
|
|
|
+
|
|
|
|
|
+ # Recalculate and store the checksum of the file for the next upgrade.
|
|
|
|
|
+ ynh_store_file_checksum --file="$setupVars"
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
@@ -318,18 +349,21 @@ echo "$pihole_core_version $dashboard_version $FTL_version" | tee $pihole_storag
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
|
|
|
cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
|
|
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.
|
|
# 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
|
|
ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
-# ADVERTISE SERVICE IN ADMIN PANEL
|
|
|
|
|
|
|
+# INTEGRATE SERVICE IN YUNOHOST
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Integrating service in YunoHost..."
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# UPDATE CONF_REGEN HOOK
|
|
# UPDATE CONF_REGEN HOOK
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Updating conf_regen hook..."
|
|
|
|
|
|
|
|
cp ../conf/dnsmasq_regenconf_hook /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"
|
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
|
|
@@ -367,20 +401,20 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
|
|
|
|
|
|
|
|
# If a html email is required. Apply html to the changelog.
|
|
# If a html email is required. Apply html to the changelog.
|
|
|
if [ "$admin_mail_html" -eq 1 ]; then
|
|
if [ "$admin_mail_html" -eq 1 ]; then
|
|
|
- format=html
|
|
|
|
|
|
|
+ format=html
|
|
|
else
|
|
else
|
|
|
- format=plain
|
|
|
|
|
|
|
+ format=plain
|
|
|
fi
|
|
fi
|
|
|
ynh_app_changelog --format=$format
|
|
ynh_app_changelog --format=$format
|
|
|
|
|
|
|
|
if [ $enable_dhcp -eq 1 ]
|
|
if [ $enable_dhcp -eq 1 ]
|
|
|
then
|
|
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 documentation about that, https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md
|
|
You should really read the documentation about that, https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md
|
|
|
|
|
|
|
|
"
|
|
"
|
|
|
else
|
|
else
|
|
|
- dhcp_alert=""
|
|
|
|
|
|
|
+ dhcp_alert=""
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
echo "${dhcp_alert}You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
|
|
echo "${dhcp_alert}You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
|