From 6f99b444a62783d67b92956ffbbd93d059798674 Mon Sep 17 00:00:00 2001 From: Giulio Date: Fri, 22 May 2020 18:10:12 +0200 Subject: [PATCH] Build script update, ssh and signign keys --- build.sh | 24 +++++++++++++++++++---- conf/etc/init.d/S10cfgbin | 40 +++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/build.sh b/build.sh index 53266d9..4783dc6 100755 --- a/build.sh +++ b/build.sh @@ -5,17 +5,33 @@ echo "[+] Starting build script..." mkdir -p target/overlay/var/www/html + echo "[+] Cloning buildroot" git clone https://github.com/buildroot/buildroot.git target/buildroot -echo "[+] Building the keygen" -mkdir -p conf/usr/sbin -gcc -lm -static -o conf/usr/sbin/cfgbin keygen/keygen.c -strip conf/usr/sbin/cfgbin + echo "[+] Adding customization files" cp -R buildroot/* target/buildroot # copy buildroot configs cp -R conf/* target/overlay # copy target system config files cp -R webpanel/* target/overlay/var/www/html # copy the webpanel cp -R update/* target/overlay #copy the update script and certificate + +echo "[+] Building the keygen" +mkdir -p target/overlay/usr/sbin +gcc -lm -static -o target/overlay/usr/sbin/cfgbin keygen/keygen.c +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/ + echo "[+] Building the image" N=`grep -c '^processor' /proc/cpuinfo` cd target/buildroot diff --git a/conf/etc/init.d/S10cfgbin b/conf/etc/init.d/S10cfgbin index 36db9bf..8a8bb23 100755 --- a/conf/etc/init.d/S10cfgbin +++ b/conf/etc/init.d/S10cfgbin @@ -1,20 +1,20 @@ -#!/bin/sh - -case "$1" in - start) - printf "Starting cfgbin: " - /usr/sbin/cfgbin - test -f /etc/serial || exit 0 - test -f /etc/ssid || exit 0 - test -f /etc/wpa || exit 0 - $SSID=`cat /etc/ssid` - $WPA=`cat /etc/wpa` - sed -i "s/{{SSID}}/$SSID/g" /etc/hostapd.conf - sed -i "s/{{WPA}}/$WPA/g" /etc/hostapd.conf - ;; - *) - echo "Usage: $0 {start}" - exit 1 -esac - -exit 0 +#!/bin/sh + +case "$1" in + start) + printf "Starting cfgbin: " + /usr/sbin/cfgbin + test -f /etc/serial || exit 0 + test -f /etc/ssid || exit 0 + test -f /etc/wpa || exit 0 + SSID=`cat /etc/ssid` + WPA=`cat /etc/wpa` + sed -i "s/{{SSID}}/$SSID/g" /etc/hostapd.conf + sed -i "s/{{WPA}}/$WPA/g" /etc/hostapd.conf + ;; + *) + echo "Usage: $0 {start}" + exit 1 +esac + +exit 0 \ No newline at end of file