From: Ian Kelling Date: Wed, 3 Jul 2019 11:22:46 +0000 (-0400) Subject: wrt improvements X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=commitdiff_plain;h=f664dba85a21a70e2ab2fde5a8d0c44dfa7dc18f wrt improvements --- diff --git a/wrt-setup-local b/wrt-setup-local index f5711d0..b4af55d 100755 --- a/wrt-setup-local +++ b/wrt-setup-local @@ -24,8 +24,9 @@ usage() { usage: ${0##*/} [-h] [-t 2|test] [-m WIRELESS_MAC] setup my router in general: dhcp, dns, etc. -Type 2 is for setting up a backup device. Type test is for setting up a -testing device. +Type 2 or 3 is for setting up a backup device, there are two kinds so +that you can switch the main device to a backup, then a backup to the +main. Type test is for setting up a testing device. Passing an empty string for WIRELESS_MAC will cause the device's native mac to be used. @@ -47,11 +48,17 @@ while getopts hm:t: opt; do h) usage ;; t) case $2 in - 2) + 2|3) dev2=true + libremanage_host=wrt + ;;& + 2) lanip=4 hostname=wrt2 - libremanage_host=wrt + ;; + 3) + lanip=14 + hostname=wrt3 ;; test) test=true @@ -79,23 +86,37 @@ fi macpre=${mac:0: -1} macsuf=${mac: -1} + +p_updated=false pmirror() { + if $p_updated; then + return + fi # background: upgrading all packages is not recommended because it # doesn't go into the firmware. build new firmware if you want # lots of upgrades. I think /tmp/opkg-lists is a pre openwrt 14 location. f=(/var/opkg-lists/*) if ! (( $(date -r $f +%s) + 60*60*24 > $(date +%s) )); then - opkg update + if ! opkg update; then + echo "$0: warning: opkg update failed" >&2 + fi + p_updated=true fi } pi() { - for x in "$@"; do - if [[ ! $(opkg list-installed "$x") ]]; then + to_install=() + for p in "$@"; do + pname=${p##*/} + pname=${pname%%_*} + if [[ ! $(opkg list-installed "$pname") ]]; then + to_install+=($p) pmirror - opkg install "$@" fi done + if [[ $to_install ]]; then + opkg install ${to_install[@]} + fi } v() { @@ -116,6 +137,7 @@ v() { ####### end uci example ##### uset() { + printf "+ uset %s\n" "$*" local key="$1" local val="$2" local service="${key%%.*}" @@ -200,8 +222,8 @@ mkdir -p /run/parabolaiso/bootmnt # wiki says safe to do in case of fstab changes: ## ian: usb broke on old router. if that happens, can just comment this to disable problems -echo | cedit /etc/config/fstab ||: -cedit /etc/config/fstab <