#!/bin/bash # # Work derived from ./quick_740n_ttn_bb.sh (Laurent Guerby ) # Renamed from "CHD OpenWRT" to "CHD LEDE" on 2017-06-21 # # Copyright 2017 Ludovic Pouzenc # Copyright 2017 Nicolas Goaziou # # CHD LEDE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # CHD LEDE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with CHD LEDE. If not, see . # echo -n "$0 - " ; date # Directories and source file URL BUILD_DIR=${BUILD_DIR:-./build} CACHE_DIR=${CACHE_DIR:-.} ORIG_TARBALL=lede-imagebuilder-17.01.4-ar71xx-generic.Linux-x86_64.tar.xz ORIG_URL=https://downloads.lede-project.org/releases/17.01.4/targets/ar71xx/generic/$ORIG_TARBALL PACKAGES="luci luci-mod-admin-full ip kmod-leds-gpio" # Base packages PACKAGES="$PACKAGES luci-i18n-base-en luci-i18n-firewall-en luci-i18n-base-fr luci-i18n-firewall-fr" # internationalisation PACKAGES="$PACKAGES -kmod-ppp -kmod-pppoe -kmod-pppox" # Unusefull kernel modules PACKAGES="$PACKAGES -luci-proto-ppp -ppp -ppp-mod-pppoe -odhcp6c" # Unusefull packages # Argument parsing if [ $# -lt 8 -o $# -gt 9 ] then echo "Usage: $0 [wanip4addr]" exit 1 fi dnslist="185.131.40.1 fe80::31" logserv="172.16.0.253" profile=$1 ip4pub=$2 case "$ip4pub" in 185.131.4[0-3].[0-9]*) ;; *) echo "Unknown Ip4 $ip4pub"; exit 3;; esac lanip4addr=$3 ip6prefix=$4 wanip6addr=${ip6prefix}1/56 lanip6addr=${ip6prefix%%0::}1::1/64 wanip6ll=$(echo $ip6prefix | sed -ne 's#.*:\([0-9a-f]\{1,4\}:[0-9a-f]\{1,4\}\)::$#fe80::\1/64#pi') if [ -z "$wanip6ll" ] then echo "Error while generating link-local WAN IPv6 address" exit 2 fi if [ '$1$' = "${5:0:3}" ] then root_password=$5 else root_password=$(mkpasswd -5 "$5") fi wireless_ssid=$6 wireless_key=$7 case $8 in -1) wireless_disabled=1; wireless_txpower=17 ;; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18) wireless_disabled=0; wireless_txpower=$8 ;; *) echo "Unknown txpower '$8'"; exit 4 ;; esac wanip4addr=${9:-'no-nat'} case "$wanip4addr" in 172.16.*) wanip4mask=255.255.0.0; wanip4gw=172.16.0.254 ;; no-nat|185.131.*) wanip4addr=$ip4pub; wanip4mask=255.255.254.0; wanip4gw=185.131.40.1 ;; *) echo "Unknown WAN IP address: $wanip4addr"; exit 6;; esac wanip6gw=fe80::31 # Sumary for interactive user cat < extra_files/etc/dropbear/authorized_keys < extra_files/etc/shadow < extra_files/etc/rc.local </var/log/initconf.log 2>&1 exit 0 EOF cat > extra_files/etc/rc.initconf < extra_files/etc/config/network < extra_files/etc/config/dropbear < extra_files/etc/firewall.user < extra_files/etc/sysctl.d/dad.conf <