Skip to content

Instantly share code, notes, and snippets.

@StalkingKillah
Last active February 23, 2018 00:20
Show Gist options
  • Save StalkingKillah/66c660e9d584e6d318c6f12158110ed8 to your computer and use it in GitHub Desktop.
Save StalkingKillah/66c660e9d584e6d318c6f12158110ed8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Tested on Debian/Ubuntu
GITHUB_USER="StalkingKillah"
DEVICE="TLMR3020"
RELEASE='15.05'
case "$RELEASE" in
trunk)
BUILDER="https://archive.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-ImageBuilder-ar71xx-generic.Linux-x86_64.tar.bz2"
;;
15.05)
BUILDER="https://archive.openwrt.org/chaos_calmer/15.05/ar71xx/generic/OpenWrt-ImageBuilder-15.05-ar71xx-generic.Linux-x86_64.tar.bz2"
;;
15.05.1)
BUILDER="https://archive.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64.tar.bz2"
;;
esac
BUILD_PATH="$(basename -s .tar.bz2 $BUILDER)"
ADDITIONAL_FILES_PATH="$BUILD_PATH/additional-files"
# https://openwrt.org/faq/before_installation#which_packages_can_i_safely_remove_to_save_space
INSTALL_PACKAGES="uhttpd uhttpd-mod-ubus libiwinfo-lua luci-base luci-app-firewall luci-mod-admin-full luci-theme-bootstrap"
REMOVE_PACKAGES="-ppp -ppp-mod-pppoe -ip6tables -odhcp6c -kmod-ipv6 -kmod-ip6tables"
EXTRA_PACKAGES="kmod-usb-storage kmod-fs-ext4 block-mount"
if [ ! -e "$(basename $BUILDER)" ]; then
echo "Downloading Image Builder..."
wget $BUILDER
fi
if [ ! -d "$BUILD_PATH" ]; then
echo "Setting up dependencies..."
apt-get -qq update
apt-get -qq -y install subversion build-essential libncurses5-dev zlib1g-dev gawk git ccache gettext libssl-dev xsltproc wget unzip python2.7
echo "Extracting Image Builder..."
tar -xjf $(basename $BUILDER)
fi
if [ ! -d "$ADDITIONAL_FILES_PATH" ]; then
# Script
mkdir -p $ADDITIONAL_FILES_PATH
wget -q -P $ADDITIONAL_FILES_PATH https://gist.github.com/StalkingKillah/0c3daa04dbf7c6564e23b7877c6006f9/raw/create-root-on-usb.sh
# Custom feeds
# mkdir -p $ADDITIONAL_FILES_PATH/etc/opkg
# wget -q -P $ADDITIONAL_FILES_PATH/etc/opkg https://gist.github.com/StalkingKillah/2f0ed66ad4a262cf1118ceeecbf4554e/raw/customfeeds.conf
# Authorized keys (from GitHub)
mkdir -p $ADDITIONAL_FILES_PATH/etc/dropbear
wget -q -O $ADDITIONAL_FILES_PATH/etc/dropbear/authorized_keys https://github.com/$GITHUB_USER.keys
fi
cd $BUILD_PATH
echo "Cleaning up old builds..."
make clean > /dev/null
echo "Building image..."
make image PROFILE="$DEVICE" PACKAGES="$INSTALL_PACKAGES $REMOVE_PACKAGES $EXTRA_PACKAGES" FILES="$(basename $ADDITIONAL_FILES_PATH)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment