diff --git a/Makefile b/Makefile index b4f2f69..98acf2a 100644 --- a/Makefile +++ b/Makefile @@ -80,6 +80,8 @@ installkali: cp -R dist/HIDScripts /usr/local/P4wnP1/ cp -R dist/www /usr/local/P4wnP1/ cp -R dist/db /usr/local/P4wnP1/ + cp -R dist/helper /usr/local/P4wnP1/ + cp -R dist/ums /usr/local/P4wnP1/ cp build/webapp.js /usr/local/P4wnP1/www cp build/webapp.js.map /usr/local/P4wnP1/www diff --git a/dist/helper/genimg b/dist/helper/genimg new file mode 100755 index 0000000..8b44c2f --- /dev/null +++ b/dist/helper/genimg @@ -0,0 +1,104 @@ +#!/bin/bash + +usage() { + echo "genimg" + echo "-------------------" + echo "Generates FAT32 or ISO CD-Rom images for P4wnP1 A.L.O.A." + echo "USB mass storage emulation" + echo + echo "Usage: genimage -i -o " + echo + echo "Options:" + echo + echo " -h, --help" + echo " This help text." + echo + echo " -c, --cdrom" + echo " Build UDF joilet ISO image, if not given build FAT32 image." + echo + echo " -l , --label " + echo " Used as volume ID for ISO image or drive label for FAT32" + echo + echo " -s , --size " + echo " Image size in MByte (applies only to FAT32 image)" + echo + echo " -i , --input " + echo " Input folder used to build the CD-Rom image." + echo " Optional for FAT32 iamge, if given content is copied." + echo + echo " -o , --output " + echo " Output file name (without extension and path)." + echo +} + +if [ "$#" -eq 0 ]; then + usage + exit +fi + +# defaults +label="P4wnP1 ALOA" +size=128 +cdrom=false +ISO_PATH="/usr/local/P4wnP1/ums/cdrom" +FAT_PATH="/usr/local/P4wnP1/ums/flashdrive" + +while [ "$#" -gt 0 ] +do + case "$1" in + -h|--help) + usage + exit 0 + ;; + -c|--cdrom) + cdrom=true + ;; + -i|--input) + input="$2" + ;; + -l|--label) + label="$2" + ;; + -s|--size) + size="$2" + ;; + -o|--output) + output="$2" + ;; + -*) + echo "Invalid option '$1'. Use --help to see the valid options" >&2 + exit 1 + ;; + # an option argument, continue + *) ;; + esac + shift +done + +if $cdrom; then + OUTFILE="$ISO_PATH/$output.iso" + echo "Generating ISO image from $input at $OUTFILE" + genisoimage -udf -joliet-long -V "$label" -o $OUTFILE $input +else + OUTFILE="$FAT_PATH/$output.bin" + echo "Generating $size""MB FAT32 image at $OUTFILE" + dd if=/dev/zero of=$OUTFILE bs=1M count=$size + mkdosfs $OUTFILE + fatlabel $OUTFILE "$label" + + if [ "$input" != "" ]; then + echo "Copying in input from $input" + # find free loop device + loopdev=$(losetup -f) + # bind image to loop device + losetup $loopdev $OUTFILE + # mount to /mnt + mount -t vfat -o loop $OUTFILE /mnt + + # copy files and subfolders + cp -R $input/* /mnt + + umount /mnt + losetup -d $loopdev + fi +fi diff --git a/dist/ums/cdrom/test.iso b/dist/ums/cdrom/test.iso new file mode 100644 index 0000000..178a33b Binary files /dev/null and b/dist/ums/cdrom/test.iso differ diff --git a/dist/ums/flashdrive/test.bin b/dist/ums/flashdrive/test.bin new file mode 100644 index 0000000..a898659 Binary files /dev/null and b/dist/ums/flashdrive/test.bin differ diff --git a/web_client/hvueCompUSBSettings.go b/web_client/hvueCompUSBSettings.go index 5b3e365..6a217b5 100644 --- a/web_client/hvueCompUSBSettings.go +++ b/web_client/hvueCompUSBSettings.go @@ -149,26 +149,23 @@ const ( USB Mass Storage - - {{ value }} - - + CD-Rom - If enabled, a CD-ROM drinve is emulated instead of a writable flash-drive + If enabled, a CD-ROM drive is emulated instead of a writable flashdrive - + Image file to use