|
@@ -21,6 +21,7 @@ ynh_abort_if_errors
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Retrieve arguments from the manifest"
|
|
|
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
path_url=$YNH_APP_ARG_PATH
|
|
@@ -33,6 +34,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Check if the app can be installed"
|
|
|
|
|
|
|
|
final_path=/var/www/$app
|
|
final_path=/var/www/$app
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
@@ -46,6 +48,7 @@ ynh_webpath_register $app $domain $path_url
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Store settings from manifest" --weight=3
|
|
|
|
|
|
|
|
ynh_app_setting_set $app domain $domain
|
|
ynh_app_setting_set $app domain $domain
|
|
|
ynh_app_setting_set $app path $path_url
|
|
ynh_app_setting_set $app path $path_url
|
|
@@ -62,6 +65,7 @@ ynh_app_setting_set $app overwrite_phpfpm "1"
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# FIND AND OPEN A PORT
|
|
# FIND AND OPEN A PORT
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Find and open a free port" --weight=12
|
|
|
|
|
|
|
|
# Find a free port
|
|
# Find a free port
|
|
|
port=$(ynh_find_port 4711)
|
|
port=$(ynh_find_port 4711)
|
|
@@ -80,12 +84,14 @@ ynh_exec_fully_quiet yunohost firewall allow Both 53 --no-upnp
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# INSTALL DEPENDENCIES
|
|
# INSTALL DEPENDENCIES
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Install dependencies" --weight=12
|
|
|
|
|
|
|
|
ynh_install_app_dependencies $app_depencencies
|
|
ynh_install_app_dependencies $app_depencencies
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Download, check and unpack source" --weight=4
|
|
|
|
|
|
|
|
ynh_app_setting_set $app final_path $final_path
|
|
ynh_app_setting_set $app final_path $final_path
|
|
|
# Make a copy of local pihole repository (for Gravity)
|
|
# Make a copy of local pihole repository (for Gravity)
|
|
@@ -97,6 +103,7 @@ ynh_setup_source "$final_path" admin_dashboard
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# NGINX CONFIGURATION
|
|
# NGINX CONFIGURATION
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Configure nginx" --weight=2
|
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
# Create a dedicated nginx config
|
|
|
ynh_add_nginx_config
|
|
ynh_add_nginx_config
|
|
@@ -104,6 +111,7 @@ ynh_add_nginx_config
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# CREATE DEDICATED USER
|
|
# CREATE DEDICATED USER
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Create a dedicated user" --weight=2
|
|
|
|
|
|
|
|
# Create a dedicated system user
|
|
# Create a dedicated system user
|
|
|
ynh_system_user_create $app
|
|
ynh_system_user_create $app
|
|
@@ -111,6 +119,7 @@ ynh_system_user_create $app
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# PHP-FPM CONFIGURATION
|
|
# PHP-FPM CONFIGURATION
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Configure php-fpm" --weight=2
|
|
|
|
|
|
|
|
# Create a dedicated php-fpm config
|
|
# Create a dedicated php-fpm config
|
|
|
ynh_add_fpm_config
|
|
ynh_add_fpm_config
|
|
@@ -120,6 +129,7 @@ ynh_add_fpm_config
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# CREATE DIRECTORIES AND POPULATE THEM
|
|
# CREATE DIRECTORIES AND POPULATE THEM
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Create and populate directories"
|
|
|
|
|
|
|
|
pihole_storage="/etc/pihole"
|
|
pihole_storage="/etc/pihole"
|
|
|
mkdir -p "$pihole_storage"
|
|
mkdir -p "$pihole_storage"
|
|
@@ -138,6 +148,7 @@ cp -a "$pihole_local_repo/advanced/Scripts/COL_TABLE" "$pihole_dir/"
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# COPY PI-HOLE MAIN SCRIPT
|
|
# COPY PI-HOLE MAIN SCRIPT
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Copy Pi-Hole main script"
|
|
|
|
|
|
|
|
cp -a "$pihole_local_repo/pihole" /usr/local/bin/
|
|
cp -a "$pihole_local_repo/pihole" /usr/local/bin/
|
|
|
cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion.d/pihole
|
|
cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion.d/pihole
|
|
@@ -171,6 +182,7 @@ sed -i "/# su #/d;" "$pihole_storage/logrotate"
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# INSTALLATION OF PIHOLE-FTL
|
|
# INSTALLATION OF PIHOLE-FTL
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Install 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)
|
|
@@ -217,6 +229,7 @@ ynh_store_file_checksum "$setupVars"
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# SET UP DNSMASQ CONFIG
|
|
# SET UP DNSMASQ CONFIG
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Set up Dnsmasq config" --weight=2
|
|
|
|
|
|
|
|
ynh_systemd_action --action=stop --service_name=dnsmasq
|
|
ynh_systemd_action --action=stop --service_name=dnsmasq
|
|
|
|
|
|
|
@@ -246,6 +259,7 @@ ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# CONFIGURE DNS FOR THE LOCAL DOMAINS
|
|
# CONFIGURE DNS FOR THE LOCAL DOMAINS
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Configure dns for the local domains" --weight=7
|
|
|
|
|
|
|
|
# Find the IP associated to the network interface
|
|
# Find the IP associated to the network interface
|
|
|
localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
|
|
localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
|
|
@@ -267,6 +281,7 @@ done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
|
|
|
|
|
|
|
|
if [ $enable_dhcp -eq 1 ]
|
|
if [ $enable_dhcp -eq 1 ]
|
|
|
then
|
|
then
|
|
|
|
|
+ ynh_script_progression --message="Enable dhcp server"
|
|
|
max_dhcp_range=250
|
|
max_dhcp_range=250
|
|
|
dhcp_range=100
|
|
dhcp_range=100
|
|
|
# Define the dhcp range from the current ip
|
|
# Define the dhcp range from the current ip
|
|
@@ -301,6 +316,7 @@ ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# RESTART DNSMASQ
|
|
# RESTART DNSMASQ
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Restart Dnsmasq" --time --weight=2
|
|
|
|
|
|
|
|
ynh_systemd_action --action=restart --service_name=dnsmasq
|
|
ynh_systemd_action --action=restart --service_name=dnsmasq
|
|
|
|
|
|
|
@@ -315,6 +331,7 @@ ynh_replace_string ".*updatechecker.*" "#&" /etc/cron.d/pihole
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# BUILD THE LISTS WITH GRAVITY
|
|
# BUILD THE LISTS WITH GRAVITY
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Build the lists with Gravity" --weight=7
|
|
|
|
|
|
|
|
cp "$pihole_local_repo/adlists.default" "$pihole_storage/adlists.default"
|
|
cp "$pihole_local_repo/adlists.default" "$pihole_storage/adlists.default"
|
|
|
ynh_exec_warn_less /opt/pihole/gravity.sh
|
|
ynh_exec_warn_less /opt/pihole/gravity.sh
|
|
@@ -322,6 +339,7 @@ ynh_exec_warn_less /opt/pihole/gravity.sh
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# START PIHOLE-FTL
|
|
# START PIHOLE-FTL
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Restart PiHole-FTL" --weight=2
|
|
|
|
|
|
|
|
ynh_systemd_action --action=restart --service_name=pihole-FTL
|
|
ynh_systemd_action --action=restart --service_name=pihole-FTL
|
|
|
|
|
|
|
@@ -342,12 +360,14 @@ yunohost service add pihole-FTL --log "/var/log/pihole-FTL.log"
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# RESTRAIN THE ACCESS TO THE ADMIN ONLY
|
|
# RESTRAIN THE ACCESS TO THE ADMIN ONLY
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Restrain the access to the admin only" --weight=2
|
|
|
|
|
|
|
|
yunohost app addaccess --users=$admin $app
|
|
yunohost app addaccess --users=$admin $app
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# RELOAD NGINX
|
|
# RELOAD NGINX
|
|
|
#=================================================
|
|
#=================================================
|
|
|
|
|
+ynh_script_progression --message="Reload nginx" --weight=4
|
|
|
|
|
|
|
|
ynh_systemd_action --action=reload --service_name=nginx
|
|
ynh_systemd_action --action=reload --service_name=nginx
|
|
|
|
|
|
|
@@ -372,5 +392,8 @@ message="${dhcp_alert}You can configure this app easily by using the experimenta
|
|
|
You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions.
|
|
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"
|
|
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"
|
|
|
|
|
+#=================================================
|
|
|
|
|
+# END OF SCRIPT
|
|
|
|
|
+#=================================================
|
|
|
|
|
|
|
|
-ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="install"
|
|
|
|
|
|
|
+ynh_script_progression --message="Installation completed" --last
|