wrt setup fixes and improvements
[automated-distro-installer] / wrt-setup
index 746b16f29e84966720cbe21bcb4427b548958d4d..3e71ef5099816bcdc45dd6b76785008ce0ea5819 100755 (executable)
--- a/wrt-setup
+++ b/wrt-setup
@@ -23,28 +23,44 @@ x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
 
 usage() {
   cat <<EOF
-usage: ${0##*/} [-h|--help] [HOST/IP]
+usage: ${0##*/} [-h|--help] [-d|--dev2] [HOST/IP]
 setup my router in general: dhcp, dns, etc.
+
+dev2 is for setting up a second device for testing etc.
 EOF
   exit $1
 }
 
 h=root@10.0.0.1
 
-if [[ $1 ]]; then
+temp=$(getopt -l help,dev2 h2 "$@") || usage 1
+eval set -- "$temp"
+while true; do
   case $1 in
+    -2|--dev2) local_arg=-2; shift ;;
     -h|--help) usage ;;
-    *) h=root@$1 ;;
+    --) shift; break ;;
+    *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
   esac
+done
+
+if (( $# > 1 )); then
+  usage 1
+fi
+
+if [[ $# == 1 ]]; then
+  read h <<<"$@"
 fi
 
 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 <<EOF
 if ! opkg list-installed|grep bash; then
     opkg update
     opkg install bash
 fi
 export HOME_DOMAIN=$HOME_DOMAIN
-wrt-setup-local
+wrt-setup-local $local_arg
 EOF