2020-05-21 16:44:20 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# for dependencies
|
|
|
|
# apt install -t build-essential libncurses-dev bison flex libssl-dev libelf-dev
|
|
|
|
|
|
|
|
echo "[+] Starting build script..."
|
2020-05-21 16:52:16 +02:00
|
|
|
mkdir -p target/overlay/var/www/html
|
2020-05-22 18:10:12 +02:00
|
|
|
|
2020-05-21 16:44:20 +02:00
|
|
|
echo "[+] Cloning buildroot"
|
2020-05-21 16:52:16 +02:00
|
|
|
git clone https://github.com/buildroot/buildroot.git target/buildroot
|
2020-05-22 18:10:12 +02:00
|
|
|
|
2020-05-21 16:44:20 +02:00
|
|
|
echo "[+] Adding customization files"
|
|
|
|
cp -R buildroot/* target/buildroot # copy buildroot configs
|
2020-05-21 16:52:16 +02:00
|
|
|
cp -R conf/* target/overlay # copy target system config files
|
2020-05-21 16:44:20 +02:00
|
|
|
cp -R webpanel/* target/overlay/var/www/html # copy the webpanel
|
2020-05-22 18:34:46 +02:00
|
|
|
cp -R update/update.sh target/overlay #copy the update script and certificate
|
2020-05-22 18:10:12 +02:00
|
|
|
|
|
|
|
echo "[+] Building the keygen"
|
|
|
|
mkdir -p target/overlay/usr/sbin
|
2020-05-22 18:36:28 +02:00
|
|
|
gcc -o target/overlay/usr/sbin/cfgbin keygen/keygen.c -static -lm
|
2020-05-22 18:10:12 +02:00
|
|
|
strip target/overlay/usr/sbin/cfgbin
|
|
|
|
|
|
|
|
echo "[+] Generating Update Key"
|
|
|
|
mkdir -p target/keys
|
|
|
|
openssl genrsa -out target/keys/signingkey.pem 2048
|
|
|
|
openssl rsa -in target/keys/signingkey.pem -outform PEM -pubout -out target/keys/signingpub.pem
|
|
|
|
cp target/keys/signingpub.pem target/overlay/pub.pem
|
|
|
|
|
|
|
|
echo "[+] Generating Monitoring SSH Key"
|
|
|
|
ssh-keygen -t ecdsa -f target/keys/sshkey -q -N ""
|
|
|
|
mkdir -p target/overlay/root/.ssh
|
|
|
|
cp target/keys/sshkey target/overlay/root/.ssh/authorized_keys
|
|
|
|
chmod -R 600 target/overlay/root/.ssh/
|
|
|
|
|
2020-05-21 16:44:20 +02:00
|
|
|
echo "[+] Building the image"
|
|
|
|
N=`grep -c '^processor' /proc/cpuinfo`
|
|
|
|
cd target/buildroot
|
2020-05-21 16:52:16 +02:00
|
|
|
make pcengines_apu2_defconfig
|
2020-05-21 16:44:20 +02:00
|
|
|
make -j$N
|