188 lines
6.1 KiB
Bash
Executable File
188 lines
6.1 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 $$
|
|
export MAKEOPTS="-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
|
|
|
|
./scripts/feeds update -a
|
|
./scripts/feeds install -a
|
|
|
|
make $MAKEOPTS defconfig
|
|
# Enable collectd network encryption
|
|
echo "CONFIG_PACKAGE_COLLECTD_ENCRYPTED_NETWORK=y" >> .config
|
|
|
|
make $MAKEOPTS package/kmod-nvme/compile
|
|
make $MAKEOPTS package/kmod-i2c-mux-pinctrl/compile
|
|
make $MAKEOPTS package/kmod-rtc-pcf85063/compile
|
|
make $MAKEOPTS package/nvme-cli/compile
|
|
make $MAKEOPTS package/asterisk-chan-quectel/compile
|
|
make $MAKEOPTS package/collectd/compile
|
|
|
|
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}
|
|
|
|
cd openwrt-imagebuilder-*/
|
|
cp ${sdkdir}/${BINPATH}/packages/*.ipk packages/
|
|
cp ${sdkdir}/bin/packages/aarch64_cortex-a72/packages/*.ipk packages/
|
|
cp ${sdkdir}/bin/packages/aarch64_cortex-a72/telephony/*.ipk packages/
|
|
cp ${sdkdir}/bin/packages/aarch64_cortex-a72/local/*.ipk packages/
|
|
|
|
ls -lah packages
|
|
|
|
make $MAKEOPTS 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
|
|
# re-enable collectd encrypted network, it gets removed somewhere
|
|
echo "CONFIG_PACKAGE_COLLECTD_ENCRYPTED_NETWORK=y" >> .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-packages python3-yaml \
|
|
openssh-sftp-server tcpdump \
|
|
iptables-nft ip6tables-nft \
|
|
wireguard-tools wget-ssl \
|
|
"
|
|
|
|
BOOTSOURCE=target/linux/${OPENWRT_TARGET}/image
|
|
BOOTCONFIG=${BOOTSOURCE}/config.txt
|
|
KERNELSOURCE=build_dir/target-aarch64_cortex-a72_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/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
|
|
|
|
# reorder packages so the local ones have a higher priority
|
|
sed -i -E 's/^(src imagebuilder file:packages.*)/#\1/
|
|
5i src imagebuilder file:packages' \
|
|
repositories.conf
|
|
|
|
# debug
|
|
cat repositories.conf
|
|
|
|
make $MAKEOPTS image PROFILE=${PROFILE} \
|
|
PACKAGES="${PACKAGES}" DISABLED_SERVICES="dropbear" FILES="files" || exit 1
|
|
|
|
mv ${IMAGE_PATH}-squashfs-factory.img.gz ${IMAGE_PATH}-squashfs-factory-dualeth.img.gz
|
|
mv ${IMAGE_PATH}-squashfs-sysupgrade.img.gz ${IMAGE_PATH}-squashfs-sysupgrade-dualeth.img.gz
|
|
|
|
sed -i "s|,i2c_csi_dsi||g" ${BOOTSOURCE}/current.txt
|
|
sed -i "s/CONFIG_TARGET_ROOTFS_PARTSIZE=.*/CONFIG_TARGET_ROOTFS_PARTSIZE=768/g" .config
|
|
|
|
make $MAKEOPTS image PROFILE=${PROFILE} \
|
|
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
|
|
|
|
mv ${IMAGE_PATH}-squashfs-factory.img.gz ${IMAGE_PATH}-squashfs-factory-waveshare.img.gz
|
|
mv ${IMAGE_PATH}-squashfs-sysupgrade.img.gz ${IMAGE_PATH}-squashfs-sysupgrade-waveshare.img.gz
|
|
|
|
|
|
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
|
|
|
|
|
|
make $MAKEOPTS image PROFILE=${PROFILE} \
|
|
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
|
|
|
|
mv ${IMAGE_PATH}-squashfs-factory.img.gz ${IMAGE_PATH}-squashfs-factory-sensing.img.gz
|
|
mv ${IMAGE_PATH}-squashfs-sysupgrade.img.gz ${IMAGE_PATH}-squashfs-sysupgrade-sensing.img.gz
|
|
|
|
|
|
cat ${BINPATH}/*.manifest
|
|
|
|
out=../../out
|
|
|
|
mkdir -p ${out}
|
|
mv ${BINPATH}/*.gz ${out}
|