# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-
-x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
+cd ${x%/*}
export HOSTNAME="$1"
mirror=$2
--- /dev/null
+# meant to be sourced. copy/pasted from https://iankelling.org/git/?p=errhandle;a=summary
+
+bash-trace() {
+ local -i argc_index=0 arg frame i start=${1:-1} max_indent=8 indent
+ local source
+ local extdebug=false
+ if [[ $(shopt -p extdebug) == *-s* ]]; then
+ extdebug=true
+ fi
+
+ for ((frame=0; frame < ${#FUNCNAME[@]}-1; frame++)); do
+ argc=${BASH_ARGC[frame]}
+ argc_index+=$argc
+ ((frame < start)) && continue
+ if (( ${#BASH_SOURCE[@]} > 1 )); then
+ source="${BASH_SOURCE[frame+1]}:${BASH_LINENO[frame]}:"
+ fi
+ indent=$((frame-start+1))
+ indent=$((indent < max_indent ? indent : max_indent))
+ printf "%${indent}s↳%sin \`%s" '' "$source" "${FUNCNAME[frame]}"
+ if $extdebug; then
+ for ((i=argc_index-1; i >= argc_index-argc; i--)); do
+ printf " %s" "${BASH_ARGV[i]}"
+ done
+ fi
+ echo \'
+ done
+}
+
+
+errcatch() {
+ set -E; shopt -s extdebug
+ _err-trap() {
+ err=$?
+ exec >&2
+ set +x
+ echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]}:in \`$BASH_COMMAND' returned $err"
+ bash-trace 2
+ set -e
+ "${_errcatch_cleanup[@]}"
+ echo "$0: exiting with code $err"
+ exit $err
+ }
+ trap _err-trap ERR
+ set -o pipefail
+}
+
+errcatch
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-cleanup() { :; }
-set -eE -o pipefail
-trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
[[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@"
mount_dir=$(mktemp -d)
cleanup() { cd; umount -f $mount_dir; }
+_errcatch_cleanup=cleanup
e mount -o users wrt:/mnt/usb $mount_dir
# See the License for the specific language governing permissions and
# limitations under the License.
-set -eE -o pipefail
-cleanup() { :; }
-trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
reboot=true
if [[ $1 == -r ]]; then
e myfai-chboot $host
e fai-kexec $host ||:
else
- cleanup() { pxe-server; }
+ cleanup() { pxe-server; }; _errcatch_cleanup=cleanup
e pxe-server $host fai
if $reboot; then
fi
e pxe-server -a
- cleanup() { :; }
+ unset _errcatch_cleanup
fi
error=true
-cleanup() { :; }
-set -eE -o pipefail
-trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-script_dir=$(dirname $(readlink -f "$BASH_SOURCE"))
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
+
+script_dir="$(readlink -f "$BASH_SOURCE")"
e() { echo "$*"; "$@"; }
./pxe-server
./faiserver-disable
}
+_errcatch_cleanup=cleanup
+
if is_arch_revm; then
./pxe-server demohost arch
sleep 2
while ! timeout -s 9 10 ssh -oBatchMode=yes root@$name /bin/true; do
e sleep 5
done
-cleanup() { :; }
+unset _errcatch_cleanup
e pxe-server
if is_arch_revm; then
./arch-init-remote $name
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
[[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@"
set -x
set -eE -o pipefail
-cleanup() { :; }
-trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+cleanup() { :; }; _errcatch_cleanup=cleanup
-x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
+cd ${x%/*}
usage() {
cat <<EOF
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
[[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@"
#!/bin/bash
-shopt -s extdebug
-bash-trace() {
- # shows function args when: shopt -s extdebug
- local -i argc_index=0 arg frame i start=${1:-1} max_indent=8 indent
- local source
- local extdebug=false
- if [[ $(shopt -p extdebug) == *-s* ]]; then
- extdebug=true
- fi
-
- for ((frame=0; frame < ${#FUNCNAME[@]}-1; frame++)); do
- argc=${BASH_ARGC[frame]}
- argc_index+=$argc
- ((frame < start)) && continue
- if (( ${#BASH_SOURCE[@]} > 1 )); then
- source="${BASH_SOURCE[frame+1]}:${BASH_LINENO[frame]}:"
- fi
- indent=$((frame-start+1))
- indent=$((indent < max_indent ? indent : max_indent))
- printf "%${indent}s↳%sin \`%s" '' "$source" "${FUNCNAME[frame]}"
- if $extdebug; then
- for ((i=argc_index-1; i >= argc_index-argc; i--)); do
- printf " %s" "${BASH_ARGV[i]}"
- done
- fi
- echo \'
- done
-}
-
-
-errcatch() {
- set -E; shopt -s extdebug
- _err-trap() {
- err=$?
- exec >&2
- echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]}:in \`$BASH_COMMAND' returned $err"
- bash-trace 2
- echo "$0: exiting with code $err"
- exit $err
- }
- trap _err-trap ERR
- set -o pipefail
-}
-
-errcatch
-
[[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@"
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
+
usage() {
cat <<EOF
Usage: ${0##*/} [OPTIONS] +/-SIZE[g] swap|boot
[[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-
-
-x=$(readlink -f "$BASH_SOURCE"); cd ${x%/*}
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
+cd ${x%/*}
usage() {
cat <<EOF
#!/bin/bash
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
fai_action_arg=I
fai_reboot_arg=,reboot
# default distro is the base debian/fedora type. others are fai & arch.
# for no pxe server, use a no-op like : or true.
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
usage() {
firewall rules, temporarily disabled until I get them working
-#### begin port forwarding rules ####
- # each port forward needs corresponding forward in the vpn server
+# each port forward needs corresponding forward in the vpn server
#http/https
+#### begin rules for nfs ####
+# https://serverfault.com/questions/377170/which-ports-do-i-need-to-open-in-the-firewall-to-use-nfs
+# https://wiki.debian.org/SecuringNFS
+# I had no /etc/default/quota, or any process named quota anything,
+# so, assumed that was unneeded. seems to work.
+config redirect
+ option src wan
+ option src_dport 111
+ option dest_ip 192.168.1.2
+ option dest lan
+config rule
+ option src wan
+ option target ACCEPT
+ option dest_port 111
+config redirect
+ option src wan
+ option src_dport 2049
+ option dest_ip 192.168.1.2
+ option dest lan
+config rule
+ option src wan
+ option target ACCEPT
+ option dest_port 2049
+config redirect
+ option src wan
+ option src_dport 32764
+ option dest_ip 192.168.1.2
+ option dest lan
+config rule
+ option src wan
+ option target ACCEPT
+ option dest_port 32764
+config redirect
+ option src wan
+ option src_dport 32765
+ option dest_ip 192.168.1.2
+ option dest lan
+config rule
+ option src wan
+ option target ACCEPT
+ option dest_port 32765
+config redirect
+ option src wan
+ option src_dport 32766
+ option dest_ip 192.168.1.2
+ option dest lan
+config rule
+ option src wan
+ option target ACCEPT
+ option dest_port 32766
+config redirect
+ option src wan
+ option src_dport 32767
+ option dest_ip 192.168.1.2
+ option dest lan
+config rule
+ option src wan
+ option target ACCEPT
+ option dest_port 32767
+config redirect
+ option src wan
+ option src_dport 32768
+ option dest_ip 192.168.1.2
+ option dest lan
+config rule
+ option src wan
+ option target ACCEPT
+ option dest_port 32768
+#### end rules for nfs ####
+
+
+config redirect
+ option name mariadb
+ option src wan
+ option src_dport 3306
+ option dest lan
+ option dest_ip 192.168.1.2
+ option proto tcp
+config rule
+ option src wan
+ option target ACCEPT
+ option dest_port 3306
+ option proto tcp
-#### end port forwarding rules ####
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-
-# ssh
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
pmirror() {
# background: upgrading all packages is not recommended because it
config redirect
option src wan
- option src_dport 80
+ option src_dport 1194
option dest lan
option dest_ip 192.168.1.2
- option proto tcp
+ option proto udp
config rule
option src wan
option target ACCEPT
- option dest_port 80
- option proto tcp
+ option dest_port 1194
+ option proto udp
-config redirect
- option name syncthing
- option src wan
- option src_dport 22001
- option dest_ip 192.168.1.2
- option dest lan
-config rule
- option src wan
- option target ACCEPT
- option dest_port 22001
-#### begin rules for nfs ####
-# https://serverfault.com/questions/377170/which-ports-do-i-need-to-open-in-the-firewall-to-use-nfs
-# https://wiki.debian.org/SecuringNFS
-# I had no /etc/default/quota, or any process named quota anything,
-# so, assumed that was unneeded. seems to work.
config redirect
option src wan
- option src_dport 111
- option dest_ip 192.168.1.2
- option dest lan
-config rule
- option src wan
- option target ACCEPT
- option dest_port 111
-config redirect
- option src wan
- option src_dport 2049
- option dest_ip 192.168.1.2
- option dest lan
-config rule
- option src wan
- option target ACCEPT
- option dest_port 2049
-config redirect
- option src wan
- option src_dport 32764
- option dest_ip 192.168.1.2
- option dest lan
-config rule
- option src wan
- option target ACCEPT
- option dest_port 32764
-config redirect
- option src wan
- option src_dport 32765
- option dest_ip 192.168.1.2
- option dest lan
-config rule
- option src wan
- option target ACCEPT
- option dest_port 32765
-config redirect
- option src wan
- option src_dport 32766
- option dest_ip 192.168.1.2
+ option src_dport 80
option dest lan
-config rule
- option src wan
- option target ACCEPT
- option dest_port 32766
-config redirect
- option src wan
- option src_dport 32767
option dest_ip 192.168.1.2
- option dest lan
+ option proto tcp
config rule
option src wan
option target ACCEPT
- option dest_port 32767
+ option dest_port 80
+ option proto tcp
+
config redirect
+ option name syncthing
option src wan
- option src_dport 32768
+ option src_dport 22001
option dest_ip 192.168.1.2
option dest lan
config rule
option src wan
option target ACCEPT
- option dest_port 32768
-#### end rules for nfs ####
-
+ option dest_port 22001
-config redirect
- option name mariadb
- option src wan
- option src_dport 3306
- option dest lan
- option dest_ip 192.168.1.2
- option proto tcp
-config rule
- option src wan
- option target ACCEPT
- option dest_port 3306
- option proto tcp
EOF
dnsmasq_restart=false
v cedit /etc/hosts <<EOF || dnsmasq_restart=true
+127.0.1.1 wrt
192.168.1.1 wrt
-192.168.1.2 treetowl $HOME_DOMAIN faiserver
+192.168.1.2 treetowl b8.nz faiserver
192.168.1.3 frodo
192.168.1.4 htpc
192.168.1.5 x2
# avoid using the dns servers that my isp tells me about.
if [[ $(uci get dhcp.@dnsmasq[0].resolvfile) ]]; then
# default is '/tmp/resolv.conf.auto', we switch to the dnsmasq default of
- # /etc/resolv.conf
+ # /etc/resolv.conf. not sure why I did this.
v uci delete dhcp.@dnsmasq[0].resolvfile
uci commit dhcp
dnsmasq_restart=true
fi
+if [[ $(uci get dhcp.@dnsmasq[0].domain) != b8.nz ]]; then
+ v uci set dhcp.@dnsmasq[0].domain=b8.nz
+ uci commit dhcp
+ dnsmasq_restart=true
+fi
+if [[ $(uci get dhcp.@dnsmasq[0].local) != b8.nz ]]; then
+ v uci set dhcp.@dnsmasq[0].local=/b8.nz/
+ uci commit dhcp
+ dnsmasq_restart=true
+fi
+
+if [[ $(uci get system.@system[0].hostname) != wrt ]]; then
+ v uci set system.@system[0].hostname=wrt
+ uci commit system
+fi
+
# useful: http://wiki.openwrt.org/doc/howto/dhcp.dnsmasq