X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=wrt-setup;h=01c270515ab868c416fd4647e0a6e6c157ed15f0;hp=3e71ef5099816bcdc45dd6b76785008ce0ea5819;hb=9fefba0a7ad0f7d9cac32b81f960ae8828de2a66;hpb=2ee7b55c3811815cdec75025cefa94918cf99ba7 diff --git a/wrt-setup b/wrt-setup index 3e71ef5..01c2705 100755 --- a/wrt-setup +++ b/wrt-setup @@ -19,48 +19,65 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR +[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" + x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*} usage() { cat < 1 )); then - usage 1 +if [[ ! $h ]]; then + read -r _ _ gateway _ < <(ip -4 route get 8.8.8.8) + case $gateway in + 10.0.0.1|10.2.0.1) + h=root@$gateway + ;; + *) + echo "$0: error: gateway = $gateway and no HOST/IP specified" + exit 1 + ;; + esac fi -if [[ $# == 1 ]]; then - read h <<<"$@" -fi +echo "$0: h=$h" cat ~/.ssh/home.pub | ssh $h dd of=/etc/dropbear/authorized_keys 2>/dev/null -scp /a/bin/fai/wrt-setup-local /a/bin/cedit/cedit $h:/usr/bin -# build for openwrt 18.06.2, r7676-cddd7b4c77 -scp /a/opt/openwrt/source/bin/packages/mips_24kc/mypackages/relay_1.0-1_mips_24kc.ipk $h: -ssh $h <