2021-05-19 20:31:20 +03:00
|
|
|
#!/bin/sh
|
2020-06-26 14:19:29 +03:00
|
|
|
|
2024-11-08 17:18:16 +03:00
|
|
|
# shellcheck disable=SC2154
|
2023-06-29 15:29:52 +03:00
|
|
|
conf_file="${SNAP_DATA}/AdGuardHome.yaml"
|
|
|
|
readonly conf_file
|
|
|
|
|
2024-11-08 17:18:16 +03:00
|
|
|
if ! [ -f "$conf_file" ]; then
|
|
|
|
xdg-open 'http://localhost:3000'
|
2023-06-29 15:29:52 +03:00
|
|
|
|
2024-11-08 17:18:16 +03:00
|
|
|
exit
|
2023-06-29 15:29:52 +03:00
|
|
|
fi
|
|
|
|
|
2021-05-19 20:31:20 +03:00
|
|
|
# Get the admin interface port from the configuration.
|
2024-11-08 17:18:16 +03:00
|
|
|
#
|
|
|
|
# shellcheck disable=SC2016
|
2023-06-29 15:29:52 +03:00
|
|
|
awk_prog='/^[^[:space:]]/ { is_http = /^http:/ };/^[[:space:]]+address:/ { if (is_http) print $2 }'
|
|
|
|
readonly awk_prog
|
|
|
|
|
2024-11-08 17:18:16 +03:00
|
|
|
bind_port="$(awk "$awk_prog" "$conf_file" | awk -F ':' '{print $NF}')"
|
2021-05-19 20:31:20 +03:00
|
|
|
readonly bind_port
|
|
|
|
|
2024-11-08 17:18:16 +03:00
|
|
|
if [ "$bind_port" = '' ]; then
|
2021-05-19 20:31:20 +03:00
|
|
|
xdg-open 'http://localhost:3000'
|
2020-06-26 14:19:29 +03:00
|
|
|
else
|
2021-05-19 20:31:20 +03:00
|
|
|
xdg-open "http://localhost:${bind_port}"
|
2020-06-26 14:19:29 +03:00
|
|
|
fi
|