mirror of
https://github.com/YunoHost-Apps/adguardhome_ynh.git
synced 2024-09-03 18:06:23 +02:00
65 lines
2 KiB
Text
65 lines
2 KiB
Text
|
#!/bin/bash
|
||
|
|
||
|
#=================================================
|
||
|
# GENERIC STARTING
|
||
|
#=================================================
|
||
|
# IMPORT GENERIC HELPERS
|
||
|
#=================================================
|
||
|
|
||
|
source scripts/_common.sh
|
||
|
source /usr/share/yunohost/helpers
|
||
|
|
||
|
#=================================================
|
||
|
# MANAGE SCRIPT FAILURE
|
||
|
#=================================================
|
||
|
|
||
|
# Exit if an error occurs during the execution of the script
|
||
|
ynh_abort_if_errors
|
||
|
|
||
|
#=================================================
|
||
|
# RETRIEVE ARGUMENTS
|
||
|
#=================================================
|
||
|
|
||
|
app=$YNH_APP_INSTANCE_NAME
|
||
|
|
||
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||
|
password=$(ynh_app_setting_get --app=$app --key=password)
|
||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||
|
adguard_port=$(ynh_app_setting_get --app=$app --key=adguard_port)
|
||
|
|
||
|
ipv4_route_output=$(ip -4 route get 1.2.3.4 | head -n1)
|
||
|
ipv6_route_output=$(ip -6 route get ::1.2.3.4 | head -n1)
|
||
|
|
||
|
ipv4_addr=""
|
||
|
for i in $(seq "$(echo $ipv4_route_output | wc -w)" -1 1); do
|
||
|
ip=$(echo $ipv4_route_output | awk "{print \$$i}")
|
||
|
if ynh_validate_ip4 --ip_address=$ip; then
|
||
|
ipv4_addr="- $ip"
|
||
|
break
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
ipv6_addr=""
|
||
|
for i in $(seq "$(echo $ipv6_route_output | wc -w)" -1 1); do
|
||
|
ip=$(echo $ipv6_route_output | awk "{print \$$i}")
|
||
|
if ynh_validate_ip6 --ip_address=$ip; then
|
||
|
ipv6_addr="- $ip"
|
||
|
break
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
#=================================================
|
||
|
# RESET THE CONFIG FILE
|
||
|
#=================================================
|
||
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||
|
|
||
|
ynh_add_config --template="../conf/AdGuardHome.yaml" --destination="$final_path/AdGuardHome.yaml"
|
||
|
|
||
|
#=================================================
|
||
|
# RESTART SYSTEMD SERVICE
|
||
|
#=================================================
|
||
|
ynh_script_progression --message="Restarting a systemd service..." --weight=1
|
||
|
|
||
|
ynh_systemd_action --service_name=$app --action="restart"
|