#!/bin/bash
# Example script to push configuration to an Internet-Box via SSH.
# Requires that SSH access is enabled on the box.

set -e

BOX_IP=${BOX_IP:-192.168.0.254}
CONFIG_FILE=${1:-config.cfg}

if [ ! -f "$CONFIG_FILE" ]; then
  echo "Config file $CONFIG_FILE not found" >&2
  exit 1
fi

echo "Uploading $CONFIG_FILE to $BOX_IP..."
scp "$CONFIG_FILE" root@"$BOX_IP":/tmp/

ssh root@"$BOX_IP" \
  "nvram set \$(cat /tmp/$(basename $CONFIG_FILE)); nvram commit"

echo "Configuration applied"
