-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Renamed path to firmware overlay data * [#48] Show HNAP version in MOTD and website * [#8] Show motd warning in case root passwd is default * Redirect version checker to HNAP Github releases * Remove obsole png files in buildroot msd/img folder * Don't fail rm over nonexistant files * Re-Add information about libiio usage as we still support this * Fix version comparison for our version string format * Insert HNAP version to version.js instead of firmware version
- Loading branch information
chris007de
authored
Nov 13, 2020
1 parent
27c614d
commit 48b157d
Showing
13 changed files
with
675 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/sh | ||
# Server-side demuxing by default | ||
|
||
source /etc/device_config | ||
|
||
CONF=/opt/config.txt | ||
file=/sys/kernel/config/usb_gadget/composite_gadget/functions/mass_storage.0/lun.0/file | ||
img=/opt/vfat.img | ||
|
||
patch_html_page() { | ||
LINUX=`uname -a | tr / - | tr '\n' ';' ; echo -n $(nproc) "core(s)"` | ||
MODEL=`cat /etc/libiio.ini | grep hw_model= | cut -d '=' -f 2` | ||
SERIAL=`cat /sys/kernel/config/usb_gadget/composite_gadget/strings/0x409/serialnumber` | ||
MACHOST=`cat /sys/kernel/config/usb_gadget/composite_gadget/functions/rndis.0/host_addr` | ||
MAC=`cat /sys/kernel/config/usb_gadget/composite_gadget/functions/rndis.0/dev_addr` | ||
IIO=`iio_info 2>/dev/null | grep "Library version:"` | ||
BUILD=`grep device-fw /opt/VERSIONS | cut -d ' ' -f 2` | ||
FPGA=`grep hdl /opt/VERSIONS | cut -d ' ' -f 2` | ||
ROOTFS=`grep buildroot /opt/VERSIONS | cut -d ' ' -f 2` | ||
UBOOT=`cat /proc/cmdline | tr "=" "\n" | grep "U-Boot"` | ||
|
||
sed -i -e "s/#LINUX#/$LINUX/g" -e "s/#MODEL#/$MODEL/g" -e "s/#SERIAL#/$SERIAL/g" -e "s/#MACHOST#/$MACHOST/g" -e "s/#MAC#/$MAC/g" -e "s/#IIO#/$IIO/g" -e "s/#BUILD#/$BUILD/g" -e "s/#FPGA#/$FPGA/g" -e "s/#ROOTFS#/$ROOTFS/g" -e "s/#UBOOT#/$UBOOT/g" $1 | ||
|
||
CALLSIGN=$(fw_printenv -n hnap_callsign) | ||
PLATFORM=$(grep plutosdr-fw /root/VERSION) | ||
HNAP=$(grep hnap /root/VERSION | cut -d' ' -f2) | ||
|
||
sed -i -e "s/#CALLSIGN#/$CALLSIGN/g" -e "s/#PLATFORM#/$PLATFORM/g" -e "s/#HNAP#/$HNAP/g" $1 | ||
sed -i -e "s/#CALLSIGN#/$CALLSIGN/g" -e "s/#PLATFORM#/$PLATFORM/g" -e "s/#HNAP#/$HNAP/g" /etc/motd | ||
|
||
sed -i -e "s/#BUILD#/$HNAP/g" $2 | ||
|
||
# Warning because of default root pw | ||
PWWARNING="" | ||
SHADOW="$(grep -E '^root:' /etc/shadow 2>/dev/null)" | ||
SALT=$(echo "${SHADOW}" | sed -n 's/root:\$5\$//;s/\$.*//p') | ||
HASH=$(mkpasswd -msha-256 analog "$SALT") | ||
|
||
if echo "${SHADOW}" | grep -q "${HASH}"; then | ||
PWWARNING="The default password for the 'root' user has not been changed.\n" | ||
PWWARNING="${PWWARNING}This is a security risk - please login as the 'root' user and type 'device_passwd' to set a new password" | ||
fi | ||
sed -i -e "s/#PWWARNING#/$PWWARNING/g" /etc/motd | ||
} | ||
|
||
|
||
case "$1" in | ||
start) | ||
echo -n "Starting MSD Daemon: " | ||
patch_html_page /www/index.html /www/img/version.js | ||
losetup /dev/loop7 $img -o 512 | ||
mount /dev/loop7 /mnt/msd | ||
|
||
if [ "$TARGET" == "m2k" ]; then | ||
cp /opt/${CALIBFILENAME} /mnt | ||
md5sum /mnt/msd/${CALIBFILENAME} > /opt/${CALIBFILENAME}.md5 | ||
fi | ||
|
||
cp $CONF /mnt/msd | ||
md5sum /mnt/msd/config.txt > /opt/config.md5 | ||
|
||
cp -a /www/* /mnt/msd | ||
mv /mnt/msd/index.html /mnt/msd/info.html | ||
umount /mnt/msd | ||
echo $img > $file | ||
|
||
start-stop-daemon -S -b -q -m -p /var/run/update.pid -x /bin/sh -- /sbin/update.sh | ||
[ $? = 0 ] && echo "OK" || echo "FAIL" | ||
;; | ||
|
||
stop) | ||
echo -n "Stopping MSD Daemon: " | ||
start-stop-daemon -K -q -p /var/run/update.pid 2>/dev/null | ||
[ $? = 0 ] && echo "OK" || echo "FAIL" | ||
;; | ||
|
||
restart) | ||
$0 stop | ||
sleep 1 | ||
$0 start | ||
;; | ||
|
||
*) | ||
echo "Usage: $0 {start|stop|restart}" | ||
exit 1 | ||
esac |
Oops, something went wrong.