Parcourir la source

Advertise config-panel and actions

Maniack Crudelis il y a 7 ans
Parent
commit
a4a720a9e8
7 fichiers modifiés avec 86 ajouts et 23 suppressions
  1. 3 3
      README.md
  2. 3 3
      README_fr.md
  3. 2 2
      manifest.json
  4. 37 11
      scripts/_common.sh
  5. 8 2
      scripts/install
  6. 8 2
      scripts/restore
  7. 25 0
      scripts/upgrade

+ 3 - 3
README.md

@@ -46,7 +46,7 @@ Use the admin panel of your Pi-hole to configure this app.
 ## Limitations
 ## Limitations
 
 
 * Activate DHCP with Pi-hole need a manuel configuration of your router.
 * Activate DHCP with Pi-hole need a manuel configuration of your router.
-* Pi-Hole-FTL can't be upgrade above the version 2.13.2, because of the usage of an option of dnsmasq not yet available on Jessie.
+* Pi-Hole can't be updated beyond the version 3.3.1, because higher versions use an integrated version of dnsmasq. This would forces to disable the version of dnsmasq used by YunoHost.
 
 
 ## Additionnal informations
 ## Additionnal informations
 
 
@@ -65,7 +65,7 @@ Please do your pull request to the [testing branch](https://github.com/YunoHost-
 
 
 To try the testing branch, please proceed like that.
 To try the testing branch, please proceed like that.
 ```
 ```
-sudo yunohost app install https://github.com/YunoHost-Apps/pihole_ynh/tree/testing --verbose
+sudo yunohost app install https://github.com/YunoHost-Apps/pihole_ynh/tree/testing --debug
 or
 or
-sudo yunohost app upgrade pihole -u https://github.com/YunoHost-Apps/pihole_ynh/tree/testing --verbose
+sudo yunohost app upgrade pihole -u https://github.com/YunoHost-Apps/pihole_ynh/tree/testing --debug
 ```
 ```

+ 3 - 3
README_fr.md

@@ -46,7 +46,7 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl
 ## Limitations
 ## Limitations
 
 
 * Activer DHCP avec Pi-hole nécessite une configuration manuelle de votre routeur.
 * Activer DHCP avec Pi-hole nécessite une configuration manuelle de votre routeur.
-* Pi-Hole-FTL ne peut pas être mis à jour au-delà de la version 2.13.2, à cause de l'utilisation d'une option de dnsmasq non encore disponible sur Jessie.
+* 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.
 
 
 ## Informations additionnelles
 ## Informations additionnelles
 
 
@@ -65,7 +65,7 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno
 
 
 Pour tester la branche testing, merci de procéder ainsi.
 Pour tester la branche testing, merci de procéder ainsi.
 ```
 ```
-sudo yunohost app install https://github.com/YunoHost-Apps/pihole_ynh/tree/testing --verbose
+sudo yunohost app install https://github.com/YunoHost-Apps/pihole_ynh/tree/testing --debug
 ou
 ou
-sudo yunohost app upgrade pihole -u https://github.com/YunoHost-Apps/pihole_ynh/tree/testing --verbose
+sudo yunohost app upgrade pihole -u https://github.com/YunoHost-Apps/pihole_ynh/tree/testing --debug
 ```
 ```

+ 2 - 2
manifest.json

@@ -6,7 +6,7 @@
 		"en": "Network-wide ad blocking via your own DNS server.",
 		"en": "Network-wide ad blocking via your own DNS server.",
 		"fr": "Filtrage publicitaire sur l'ensemble du réseau via votre propre serveur DNS."
 		"fr": "Filtrage publicitaire sur l'ensemble du réseau via votre propre serveur DNS."
 	},
 	},
-	"version": "3.3.1~ynh3",
+	"version": "3.3.1~ynh4",
 	"url": "https://pi-hole.net/",
 	"url": "https://pi-hole.net/",
 	"license": "EUPL-1.2",
 	"license": "EUPL-1.2",
 	"maintainer": {
 	"maintainer": {
@@ -14,7 +14,7 @@
 		"email": "maniackc_dev@crudelis.fr"
 		"email": "maniackc_dev@crudelis.fr"
 	},
 	},
 	"requirements": {
 	"requirements": {
-		"yunohost": ">= 2.7.14"
+		"yunohost": ">= 3.3.3"
 	},
 	},
 	"multi_instance": false,
 	"multi_instance": false,
 	"services": [
 	"services": [

+ 37 - 11
scripts/_common.sh

@@ -264,7 +264,7 @@ ynh_multimedia_build_main_dir () {
 	local checksum="806a827ba1902d6911095602a9221181"
 	local checksum="806a827ba1902d6911095602a9221181"
 
 
 	# Download yunohost.multimedia scripts
 	# Download yunohost.multimedia scripts
-	wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 
+	wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz
 
 
 	# Check the control sum
 	# Check the control sum
 	echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
 	echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
@@ -607,6 +607,7 @@ ynh_systemd_action() {
 		if [ $i -eq $timeout ]
 		if [ $i -eq $timeout ]
 		then
 		then
 			echo "The service $service_name didn't fully started before the timeout." >&2
 			echo "The service $service_name didn't fully started before the timeout." >&2
+			echo "Please find here an extract of the end of the log of the service $service_name:"
 			journalctl --lines=$length -u $service_name >&2
 			journalctl --lines=$length -u $service_name >&2
 			test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
 			test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
 		fi
 		fi
@@ -630,21 +631,24 @@ ynh_clean_check_starting () {
 
 
 # Send an email to inform the administrator
 # Send an email to inform the administrator
 #
 #
-# usage: ynh_send_readme_to_admin app_message [recipients]
+# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
 # | arg: -m --app_message= - The message to send to the administrator.
 # | arg: -m --app_message= - The message to send to the administrator.
 # | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
 # | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
 #	example: "root admin@domain"
 #	example: "root admin@domain"
 #	If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
 #	If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
 #	example: "root admin@domain user1 user2"
 #	example: "root admin@domain user1 user2"
+# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
 ynh_send_readme_to_admin() {
 ynh_send_readme_to_admin() {
 	# Declare an array to define the options of this helper.
 	# Declare an array to define the options of this helper.
-	declare -Ar args_array=( [m]=app_message= [r]=recipients= )
+	declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
 	local app_message
 	local app_message
 	local recipients
 	local recipients
+	local type
 	# Manage arguments with getopts
 	# Manage arguments with getopts
 	ynh_handle_getopts_args "$@"
 	ynh_handle_getopts_args "$@"
-	local app_message="${app_message:-...No specific information...}"
-	local recipients="${recipients:-root}"
+	app_message="${app_message:-...No specific information...}"
+	recipients="${recipients:-root}"
+	type="${type:-install}"
 
 
 	# Retrieve the email of users
 	# Retrieve the email of users
 	find_mails () {
 	find_mails () {
@@ -670,7 +674,23 @@ ynh_send_readme_to_admin() {
 	}
 	}
 	recipients=$(find_mails "$recipients")
 	recipients=$(find_mails "$recipients")
 
 
-	local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
+	# Subject base
+	local mail_subject="☁️🆈🅽🅷☁️: \`$app\`"
+
+	# Adapt the subject according to the type of mail required.
+	if [ "$type" = "backup" ]; then
+		mail_subject="$mail_subject has just been backup."
+	elif [ "$type" = "change_url" ]; then
+		mail_subject="$mail_subject has just been moved to a new URL!"
+	elif [ "$type" = "remove" ]; then
+		mail_subject="$mail_subject has just been removed!"
+	elif [ "$type" = "restore" ]; then
+		mail_subject="$mail_subject has just been restored!"
+	elif [ "$type" = "upgrade" ]; then
+		mail_subject="$mail_subject has just been upgraded!"
+	else	# install
+		mail_subject="$mail_subject has just been installed!"
+	fi
 
 
 	local mail_message="This is an automated message from your beloved YunoHost server.
 	local mail_message="This is an automated message from your beloved YunoHost server.
 
 
@@ -828,10 +848,16 @@ ynh_download_file () {
 
 
 	# Load value from configuration file (see above for a small doc about this file
 	# Load value from configuration file (see above for a small doc about this file
 	# format)
 	# format)
-	local file_url=$(grep 'FILE_URL=' "$YNH_CWD/../conf/${source_id}.src_file" | cut -d= -f2-)
-	local file_sum=$(grep 'FILE_SUM=' "$YNH_CWD/../conf/${source_id}.src_file" | cut -d= -f2-)
-	local file_sumprg=$(grep 'FILE_SUM_PRG=' "$YNH_CWD/../conf/${source_id}.src_file" | cut -d= -f2-)
-	local filename=$(grep 'FILENAME=' "$YNH_CWD/../conf/${source_id}.src_file" | cut -d= -f2-)
+	local src_file="$YNH_CWD/../conf/${source_id}.src_file"
+	# If the src_file doesn't exist, use the backup path instead, with a "settings" directory
+	if [ ! -e "$src_file" ]
+	then
+		src_file="$YNH_CWD/../settings/conf/${source_id}.src_file"
+	fi
+	local file_url=$(grep 'FILE_URL=' "$src_file" | cut -d= -f2-)
+	local file_sum=$(grep 'FILE_SUM=' "$src_file" | cut -d= -f2-)
+	local file_sumprg=$(grep 'FILE_SUM_PRG=' "$src_file" | cut -d= -f2-)
+	local filename=$(grep 'FILENAME=' "$src_file" | cut -d= -f2-)
 
 
 	# Default value
 	# Default value
 	file_sumprg=${file_sumprg:-sha256sum}
 	file_sumprg=${file_sumprg:-sha256sum}
@@ -853,7 +879,7 @@ ynh_download_file () {
 
 
 	# Create the destination directory, if it's not already.
 	# Create the destination directory, if it's not already.
 	mkdir -p "$dest_dir"
 	mkdir -p "$dest_dir"
-	
+
 	# Move the file to its destination
 	# Move the file to its destination
 	mv $filename $dest_dir
 	mv $filename $dest_dir
 }
 }

+ 8 - 2
scripts/install

@@ -355,6 +355,9 @@ ynh_systemd_action --action=reload --service_name=nginx
 # SEND A README FOR THE ADMIN
 # SEND A README FOR THE ADMIN
 #=================================================
 #=================================================
 
 
+# Get main domain and buid the url of the admin panel of the app.
+admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
+
 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.
@@ -365,6 +368,9 @@ else
 	dhcp_alert=""
 	dhcp_alert=""
 fi
 fi
 
 
-message="${dhcp_alert}If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/pihole_ynh"
+message="${dhcp_alert}You can configure this app easily by using the experimental config-panel feature: $admin_panel/config-panel.
+You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions.
+
+If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/pihole_ynh"
 
 
-ynh_send_readme_to_admin --app_message="$message" --recipients="$admin"
+ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="install"

+ 8 - 2
scripts/restore

@@ -210,6 +210,9 @@ ynh_maintenance_mode_OFF
 # SEND A README FOR THE ADMIN
 # SEND A README FOR THE ADMIN
 #=================================================
 #=================================================
 
 
+# Get main domain and buid the url of the admin panel of the app.
+admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
+
 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.
@@ -220,6 +223,9 @@ else
 	dhcp_alert=""
 	dhcp_alert=""
 fi
 fi
 
 
-message="${dhcp_alert}If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/pihole_ynh"
+message="${dhcp_alert}You can configure this app easily by using the experimental config-panel feature: $admin_panel/config-panel.
+You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions.
+
+If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/pihole_ynh"
 
 
-ynh_send_readme_to_admin --app_message="$message" --recipients="$admin"
+ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="restore"

+ 25 - 0
scripts/upgrade

@@ -22,6 +22,7 @@ path_url=$(ynh_app_setting_get $app path)
 admin=$(ynh_app_setting_get $app admin)
 admin=$(ynh_app_setting_get $app admin)
 query_logging=$(ynh_app_setting_get $app query_logging)
 query_logging=$(ynh_app_setting_get $app query_logging)
 final_path=$(ynh_app_setting_get $app final_path)
 final_path=$(ynh_app_setting_get $app final_path)
+enable_dhcp=$(ynh_app_setting_get $app enable_dhcp)
 port=$(ynh_app_setting_get $app port)
 port=$(ynh_app_setting_get $app port)
 overwrite_setupvars=$(ynh_app_setting_get $app overwrite_setupvars)
 overwrite_setupvars=$(ynh_app_setting_get $app overwrite_setupvars)
 overwrite_ftl=$(ynh_app_setting_get $app overwrite_ftl)
 overwrite_ftl=$(ynh_app_setting_get $app overwrite_ftl)
@@ -271,3 +272,27 @@ ynh_systemd_action --action=reload --service_name=nginx
 #=================================================
 #=================================================
 
 
 ynh_maintenance_mode_OFF
 ynh_maintenance_mode_OFF
+
+#=================================================
+# SEND A README FOR THE ADMIN
+#=================================================
+
+# Get main domain and buid the url of the admin panel of the app.
+admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
+
+if [ $enable_dhcp -eq 1 ]
+then
+	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
+
+"
+else
+	dhcp_alert=""
+fi
+
+message="${dhcp_alert}You can configure this app easily by using the experimental config-panel feature: $admin_panel/config-panel.
+You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions.
+
+If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/pihole_ynh"
+
+ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="upgrade"