189 lines
5.9 KiB
Bash
Executable File
189 lines
5.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# use the SDK to build the module:
|
|
# https://github.com/IchthysMaranatha/asterisk-chan-quectel
|
|
# The module is for two vendors, the Quectel-EC* and Simcom SIM7600. In
|
|
# preparation I bought one of each (EC25EUX and SIM7600G specifically), I don't
|
|
# really care if only one will work, then I'll just buy more of that specific
|
|
# vendor's model.
|
|
# now I noticed there is actually a Makefile for openwrt in the repo already:
|
|
# https://github.com/IchthysMaranatha/asterisk-chan-quectel/tree/master/openwrt
|
|
|
|
set -x
|
|
|
|
renice -n 19 $$
|
|
MAKE="make -j$(nproc)"
|
|
|
|
tar -xJf /Downloads/openwrt-sdk-${OPENWRT_VERSION}-*.tar.xz
|
|
|
|
cp -r feed openwrt-sdk-*/
|
|
|
|
pwd=$(pwd)
|
|
cd openwrt-sdk-*/
|
|
|
|
cp feeds.conf.default feeds.conf
|
|
cat ${pwd}/feeds.conf >> feeds.conf
|
|
|
|
OPENWRT_BRANCH=$(echo ${OPENWRT_VERSION} | cut -d. -f 1,2)
|
|
|
|
sed -i "s/\(packages.git\)\^.*/\1;openwrt-${OPENWRT_BRANCH}/g" feeds.conf
|
|
|
|
./scripts/feeds update -a
|
|
./scripts/feeds install -a
|
|
|
|
make defconfig
|
|
# Enable collectd network encryption
|
|
echo "CONFIG_PACKAGE_COLLECTD_ENCRYPTED_NETWORK=y" >> .config
|
|
|
|
# Kernel modules
|
|
make target/linux/bcm27xx/bcm2711
|
|
|
|
${MAKE} package/i2c-tools/compile
|
|
make package/kmod-i2c-mux-pinctrl/compile
|
|
make package/kmod-nvme/compile
|
|
make package/kmod-rtc-pcf85063/compile
|
|
make package/nvme-cli/compile
|
|
make package/ansible-core/compile
|
|
${MAKE} package/asterisk-chan-quectel/compile
|
|
${MAKE} package/collectd/compile
|
|
|
|
# Kernel image
|
|
make target/linux/bcm27xx/bcm2711
|
|
|
|
sdkdir=$(pwd)
|
|
cd ${pwd}
|
|
|
|
tar -xJf /Downloads/openwrt-imagebuilder-${OPENWRT_VERSION}-*.tar.xz
|
|
|
|
PROFILE=rpi-4
|
|
BINPATH=bin/targets/${OPENWRT_TARGET}/${OPENWRT_DEVICE}
|
|
IMAGE_PATH=${BINPATH}/openwrt-${OPENWRT_VERSION}-${OPENWRT_TARGET}-${OPENWRT_DEVICE}-${PROFILE}
|
|
PKG_ARCH=aarch64_cortex-a72
|
|
|
|
cd openwrt-imagebuilder-*/
|
|
cp ${sdkdir}/${BINPATH}/packages/*.ipk packages/
|
|
cp ${sdkdir}/bin/packages/${PKG_ARCH}/base/*.ipk packages/
|
|
cp ${sdkdir}/bin/packages/${PKG_ARCH}/packages/*.ipk packages/
|
|
cp ${sdkdir}/bin/packages/${PKG_ARCH}/telephony/*.ipk packages/
|
|
cp ${sdkdir}/bin/packages/${PKG_ARCH}/local/*.ipk packages/
|
|
|
|
make info
|
|
|
|
# Increase the size of the root partition
|
|
echo "CONFIG_TARGET_ROOTFS_PARTSIZE=308" >> .config
|
|
# Disable ext4 images
|
|
echo "CONFIG_TARGET_ROOTFS_EXT4FS=n" >> .config
|
|
|
|
PACKAGES="kmod-i2c-bcm2835 kmod-i2c-mux kmod-i2c-mux-pinctrl \
|
|
kmod-nf-nathelper-extra \
|
|
kmod-rtc-ds1307 kmod-rtc-pcf8563 kmod-rtc-pcf85063 \
|
|
kmod-usb-audio kmod-usb-net-rtl8152 \
|
|
alsa-lib pciutils usbutils \
|
|
kmod-usb-net-qmi-wwan libqmi qmi-utils uqmi luci-proto-qmi \
|
|
shadow-usermod \
|
|
ca-certificates \
|
|
collectd collectd-mod-contextswitch collectd-mod-cpu \
|
|
collectd-mod-curl collectd-mod-df \
|
|
collectd-mod-dhcpleases collectd-mod-disk \
|
|
collectd-mod-dns collectd-mod-entropy \
|
|
collectd-mod-ethstat collectd-mod-exec \
|
|
collectd-mod-filecount collectd-mod-fscache \
|
|
collectd-mod-interface collectd-mod-ipstatistics \
|
|
collectd-mod-iptables collectd-mod-irq \
|
|
collectd-mod-iwinfo collectd-mod-load \
|
|
collectd-mod-memory collectd-mod-network \
|
|
collectd-mod-nginx collectd-mod-ping \
|
|
collectd-mod-processes collectd-mod-protocols \
|
|
collectd-mod-sensors collectd-mod-smart \
|
|
collectd-mod-sqm collectd-mod-tcpconns \
|
|
collectd-mod-thermal collectd-mod-uptime \
|
|
collectd-mod-users collectd-mod-vmem \
|
|
collectd-mod-wireless \
|
|
curl etherwake fail2ban hwclock i2c-tools \
|
|
luci-app-mwan3 luci-app-upnp \
|
|
luci-proto-wireguard \
|
|
luci-ssl-nginx luci-app-acme \
|
|
python3-ansible-core python3-ansible-core-src \
|
|
python3-yaml \
|
|
openssh-sftp-server tcpdump \
|
|
iptables-nft ip6tables-nft \
|
|
wireguard-tools wget-ssl \
|
|
"
|
|
|
|
BOOTSOURCE=target/linux/${OPENWRT_TARGET}/image
|
|
BOOTCONFIG=${BOOTSOURCE}/config.txt
|
|
BOOTCMDLINE=${BOOTSOURCE}/cmdline.txt
|
|
KERNELSOURCE=build_dir/target-${PKG_ARCH}_musl/linux-${OPENWRT_TARGET}_${OPENWRT_DEVICE}/linux-5.10.146
|
|
OVERLAYSOURCE=${KERNELSOURCE}/arch/arm64/boot/dts/overlays
|
|
|
|
# Setup files
|
|
mkdir -p files/etc/dropbear
|
|
chmod 0750 files/etc/dropbear
|
|
cp ${pwd}/authorized_keys files/etc/dropbear
|
|
chmod 0400 files/etc/dropbear/authorized_keys
|
|
mkdir -p files/etc/docker
|
|
chmod 0750 files/etc/docker
|
|
cp ${pwd}/daemon.json files/etc/docker
|
|
mkdir -p files/etc/uci-defaults
|
|
cp ${pwd}/defaults/* files/etc/uci-defaults
|
|
|
|
cp ${pwd}/overlays/dualeth.txt ${BOOTSOURCE}/current.txt
|
|
|
|
cp ${BOOTCONFIG} .
|
|
|
|
cat << "EOF" >> ${BOOTCONFIG}
|
|
dtparam=i2c1=on
|
|
dtparam=spi=on
|
|
dtparam=i2s=on
|
|
dtoverlay=i2c-rtc,ds1307
|
|
|
|
include current.txt
|
|
EOF
|
|
|
|
pushd ${BOOTSOURCE}
|
|
git apply ${pwd}/patches/bootconfig-add.patch
|
|
popd
|
|
|
|
make image PROFILE=${PROFILE} EXTRA_IMAGE_NAME="dualeth" \
|
|
PACKAGES="${PACKAGES}" DISABLED_SERVICES="dropbear" FILES="files" || exit 1
|
|
|
|
|
|
sed -i "s|,i2c_csi_dsi||g" ${BOOTSOURCE}/current.txt
|
|
sed -i "s/CONFIG_TARGET_ROOTFS_PARTSIZE=.*/CONFIG_TARGET_ROOTFS_PARTSIZE=768/g" .config
|
|
#sed -i 's/root=\/dev\/mmcblk0p2/root=\/dev\/nvme0n1p2/' $BOOTCMDLINE
|
|
|
|
make image PROFILE=${PROFILE} EXTRA_IMAGE_NAME="waveshare" \
|
|
PACKAGES=" \
|
|
${PACKAGES} cryptsetup kmod-ata-ahci smartmontools hdparm fdisk parted \
|
|
kmod-hwmon-drivetemp btrfs-progs kmod-fs-btrfs kmod-nvme nvme-cli \
|
|
docker dockerd docker-compose block-mount" \
|
|
DISABLED_SERVICES="dropbear" FILES="files" || exit 1
|
|
|
|
|
|
cp ${pwd}/overlays/sensing.txt ${BOOTSOURCE}/current.txt
|
|
cp ${pwd}/overlays/*.dtbo ${OVERLAYSOURCE}
|
|
cp config.txt ${BOOTCONFIG}
|
|
echo "include current.txt" >> ${BOOTCONFIG}
|
|
pushd ${KERNELSOURCE}
|
|
git apply ${pwd}/patches/overlay-add.patch
|
|
popd
|
|
|
|
sed -i "s/CONFIG_TARGET_ROOTFS_PARTSIZE=.*/CONFIG_TARGET_ROOTFS_PARTSIZE=308/g" .config
|
|
#sed -i 's/root=\/dev\/nvme0n1p2/root=\/dev\/mmcblk0p2/' $BOOTCMDLINE
|
|
|
|
make image PROFILE=${PROFILE} EXTRA_IMAGE_NAME="sensing" \
|
|
PACKAGES="${PACKAGES} asterisk \
|
|
asterisk-app-sms asterisk-pjsip asterisk-bridge-simple \
|
|
asterisk-codec-alaw asterisk-codec-ulaw \
|
|
asterisk-res-rtp-asterisk \
|
|
asterisk-chan-quectel" \
|
|
DISABLED_SERVICES="dropbear" FILES="files" || exit 1
|
|
|
|
|
|
cat ${BINPATH}/*.manifest
|
|
|
|
out=../../out
|
|
|
|
mkdir -p ${out}
|
|
mv ${BINPATH}/*.gz ${out}
|