diff options
| author | Anton Bobov <anton@bobov.name> | 2026-03-21 10:14:09 +0500 |
|---|---|---|
| committer | Anton Bobov <anton@bobov.name> | 2026-04-20 13:24:19 +0500 |
| commit | 5dfdfa41fbe6400a1789b073a8dd4c9e3afaff26 (patch) | |
| tree | 29750fcfde48f6d5d345adf600f5777ede38ad8f /through-vpn.sh | |
| parent | 7848ce81682846be21ce373dbdbbf874a8ed48d8 (diff) | |
replace through-vpn.sh with enhanced ros-al-add script
Diffstat (limited to 'through-vpn.sh')
| -rwxr-xr-x | through-vpn.sh | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/through-vpn.sh b/through-vpn.sh deleted file mode 100755 index b35623b..0000000 --- a/through-vpn.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -# Add host to RouterOS address list. -# - -set -euo pipefail - -LIST_NAME="through-vpn" -ROUTER_HOST="riga" - -usage() { - cat <<EOF -Usage: ${0##*/} [-t|-n|-h] name... - -Name could be a domain name or URL. - -Options: - -h print this help - -t timeout value (ex: 1m, 8h) - -n dry run, just print commands -EOF -} - -extract_domain() { - cat <<EOF | python3 -from urllib.parse import urlparse - -url = urlparse(r'$1') -print(url.hostname or '$1') -EOF -} - -create_router_commands() { - local timeout="$1" - shift - for name in "$@"; do - domain=$(extract_domain "$name") - echo "/ip firewall address-list add address=$domain list=$LIST_NAME timeout=$timeout" - done -} - -main() { - local timeout= - local dryrun=0 - while getopts ":nt:" opt; do - case "${opt}" in - t) - timeout="${OPTARG}" - ;; - n) - dryrun=1 - ;; - *) - usage - exit - ;; - esac - done - shift $((OPTIND - 1)) - - if [ $# -eq 0 ]; then - echo 'First argument must be domain or URL' - exit 1 - elif [ $dryrun -eq 0 ]; then - create_router_commands "$timeout" "$@" | ssh "$ROUTER_HOST" - else - create_router_commands "$timeout" "$@" - fi -} - -main "$@" |
