#!/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.1-ar71xx-generic.Linux-x86_64.tar.bz2 ORIG_URL=http://downloads.openwrt.org/chaos_calmer/15.05.1/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 < repositories.conf <<"EOT" ## Place your custom repositories here, they must match the architecture and version. # src/gz chaos_calmer http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages # src custom file:///usr/src/openwrt/bin/ar71xx/packages ## Remote package repositories src/gz chaos_calmer_base http://localhost/openwrt/chaos_calmer/15.05.1/ar71xx/generic/packages/base src/gz chaos_calmer_luci http://localhost/openwrt/chaos_calmer/15.05.1/ar71xx/generic/packages/luci #src/gz chaos_calmer_packages http://localhost/openwrt/chaos_calmer/15.05.1/ar71xx/generic/packages/packages src/gz chaos_calmer_routing http://localhost/openwrt/chaos_calmer/15.05.1/ar71xx/generic/packages/routing #src/gz chaos_calmer_telephony http://localhost/openwrt/chaos_calmer/15.05.1/ar71xx/generic/packages/telephony #src/gz chaos_calmer_management http://localhost/openwrt/chaos_calmer/15.05.1/ar71xx/generic/packages/management ## This is the local package repository, do not remove! src imagebuilder file:packages EOT 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