├── README.md ├── package-sync ├── LICENSE ├── centurylink-6rd └── centurylink-6rd.md /README.md: -------------------------------------------------------------------------------- 1 | # ubiquiti-scripts 2 | Helper scripts to get more out of ubiquiti 3 | -------------------------------------------------------------------------------- /package-sync: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Install this script in /config/scripts/post-config.d 4 | # 5 | # Place package names, one per line, in /config/packages 6 | # 7 | # On boot, this script will be automatically called and will install 8 | # your desired packages, ensuring persistence across firmware upgrades 9 | 10 | for pkg in $(cat /config/packages) ; do 11 | if ! dpkg --status $pkg >/dev/null 2>&1 ; then 12 | TO_INSTALL="${TO_INSTALL} $pkg" 13 | fi 14 | done 15 | 16 | [ -n "${TO_INSTALL}" ] && apt-get update && apt-get -y install ${TO_INSTALL} 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, cpcowart 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /centurylink-6rd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This first pass script is intended to be installed as 4 | # /config/scripts/ppp/ip-up.d/6rd-up 5 | # 6 | # /etc/ppp/ip-up exports the following variables to this script: 7 | # PPP_IFACE - interface name (e.g., pppoe0) 8 | # PPP_TTY 9 | # PPP_SPEED 10 | # PPP_LOCAL - our IPv4 address 11 | # PPP_REMOTE 12 | # PPP_IPPARAM 13 | # PPP_TTYNAME 14 | 15 | # Future goals: 16 | # - pull configuration out of the script 17 | # - use a template for the config scripts 18 | # - act like a PD client and auto-compute assignments to downstream interfaces 19 | 20 | # I want to make this more automatic in the future. Not used yet. 21 | SIXRD_ISP_PREFIX=2602::/24 22 | SIXRD_PREFIX_LEN=$(echo ${SIXRD_ISP_PREFIX} | /usr/bin/cut -d/ -f2) 23 | CPE_PREFIX_LEN=$(( ${SIXRD_PREFIX_LEN} + 32 )) 24 | 25 | # This unrolls '::' and 0-pads the quads. Not used yet, but will be useful 26 | # soon 27 | normalize_ipv6() { 28 | ipv6="$1" 29 | /usr/bin/awk -v ipv6="$ipv6" 'END { 30 | while (gsub(/:/,":",ipv6) < 7) { 31 | sub(/::/,":::",ipv6) 32 | } 33 | split(ipv6, arr, /:/) 34 | for (i=1; i <= 8 ; i = i + 1) { 35 | printf "%04x", strtonum("0x" arr[i]) 36 | if (i < 8) { 37 | printf ":" 38 | } else { 39 | printf "\n" 40 | } 41 | } 42 | }' /config/ppp-6rd-cleanup <