X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=wrt-setup;h=1e0d6362befbc4d56a9d1352cbf901f632cb0538;hp=e9d620efb2e800187f5a02aef36dbdf86c799a4f;hb=6ca069946c8ff88d79d1ae421e0eda60ae1c514c;hpb=917fa30617ccafa3a7ed5218a418cf058948b729 diff --git a/wrt-setup b/wrt-setup index e9d620e..1e0d636 100755 --- a/wrt-setup +++ b/wrt-setup @@ -19,49 +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" +# todo: ecdsa key not working with dropbear +cat ~/.ssh/{h,hrsa,home}.pub | ssh $h dd of=/etc/dropbear/authorized_keys 2>/dev/null +scp /a/work/libremanage/libremanage /a/bin/fai/wrt-init /a/bin/fai/wrt-setup-local /a/bin/cedit/cedit $h:/usr/bin +# relay is built for openwrt 18.06.2, r7676-cddd7b4c77 -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 -sudo scp /q/root/shadow/router \ - /a/opt/openwrt/source/bin/packages/mips_24kc/mypackages/relay_1.0-1_mips_24kc.ipk $h: -ssh $h <