From ff242e6e618ee53ebcd7251f9c26ff721c7a03b4 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 12 Mar 2016 15:33:23 +0100 Subject: Initial import. --- build-openwrt-dev.sh | 408 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 408 insertions(+) create mode 100755 build-openwrt-dev.sh (limited to 'build-openwrt-dev.sh') diff --git a/build-openwrt-dev.sh b/build-openwrt-dev.sh new file mode 100755 index 0000000..79ea750 --- /dev/null +++ b/build-openwrt-dev.sh @@ -0,0 +1,408 @@ +#!/bin/bash +# +# Work derived from ./quick_740n_ttn_bb.sh (Laurent Guerby ) +# +# Copyright 2016 Ludovic Pouzenc +# +# CHD OpenWRT 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 OpenWRT 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 OpenWRT. If not, see . +# +echo -n "$0 - " ; date + +# Directories and source file URL +BUILD_DIR=${BUILD_DIR:-./build} +CACHE_DIR=${CACHE_DIR:-.} +ORIG_TARBALL=OpenWrt-ImageBuilder-15.05-ar71xx-generic.Linux-x86_64.tar.bz2 +ORIG_URL=http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/$ORIG_TARBALL +PACKAGES="luci luci-mod-admin-full ip" # Base packages +PACKAGES="$PACKAGES luci-i18n-base-en luci-i18n-firewall-en luci-i18n-base-fr luci-i18n-firewall-fr" # internationnalisation +PACKAGES="$PACKAGES miniupnpd luci-app-upnp luci-i18n-upnp-fr" # Extra packages +PACKAGES="$PACKAGES kmod-ledtrig-default-on kmod-ledtrig-netdev kmod-ledtrig-timer kmod-ledtrig-usbdev kmod-leds-gpio" # Additionnal kernel modules +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" + +profile=$1 +case "$profile" in + TLWR740|TLWR841) + ;; + *) echo "Unsupported profile '$profile', should be TLWR740 or TLWR841" + exit 2 + ;; +esac + +ip4pub=$2 +case "$ip4pub" in + 185.131.40.*) ;; + 185.131.41.*) ;; + *) 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 -e 's#.*:\(....:....\)::$#fe80::\1/64#') + +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=10 ;; + 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16) wireless_disabled=0; wireless_txpower=$8 ;; + *) echo "Unknown txpower '$8'"; exit 4 ;; +esac + +wanip4addr=${9:-'no-nat'} +case "$wanip4addr" in + 172.16.20.*|172.16.21.*) wanip4mask=255.255.0.0; wanip4gw=172.16.0.254 ;; + *) wanip4addr=$ip4pub; wanip4mask=255.255.254.0; wanip4gw=185.131.40.1 ;; +esac + +wanip6gw=fe80::31 + +cat < extra_files/etc/dropbear/authorized_keys < extra_files/etc/shadow < extra_files/etc/rc.local < extra_files/etc/config/network < extra_files/etc/config/wireless < extra_files/etc/config/dhcp < extra_files/etc/config/dropbear < extra_files/etc/config/firewall < extra_files/etc/config/upnpd < extra_files/etc/hotplug.d/button/01onoff <<"EOF" +#!/bin/sh + +[ "$BUTTON" = "wps" ] && [ "$ACTION" = "pressed" ] && { + SW=$(uci get wireless.@wifi-device[0].disabled) + [ $SW == '0' ] && uci set wireless.@wifi-device[0].disabled=1 + [ $SW == '0' ] || uci set wireless.@wifi-device[0].disabled=0 + wifi +} +EOF + +####################### +# Build Openwrt image # +####################### + +# Bug fix for RC3 (make clean forget things) +#if [ -d $BUILD_DIR/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/tmp ] +#then rm -r $BUILD_DIR/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/tmp +#fi + +make clean +make image PROFILE=$profile PACKAGES="$PACKAGES" FILES="extra_files/" +res=$? + +echo +if [ $res -eq 0 ] +then echo "Image ready: " + ls -la bin/ar71xx/openwrt-*-ar71xx-generic-tl-*-v[49]-squashfs-* + echo +else echo "Something went wrong, sorry" +fi + +echo -n "$0 - " ; date +exit $res -- cgit v1.1