~voidraven/s4

beebcfd23abefae981309cbba39c7a7d096d9e44 — lotus 1 year, 7 months ago d91ee3e
added resolution input checking
1 files changed, 18 insertions(+), 12 deletions(-)

M s4ctl.sh
M s4ctl.sh => s4ctl.sh +18 -12
@@ 42,17 42,24 @@ fun_make_tree () {
# 2: video recording resolution (640x480, 1280x720, etc)
fun_check_input () {
    L2_CAMERAS=$1
    L2_REZ=$2
    if [ $L2_CAMERAS -lt 0 ] ; then
	GBL_ERROR_MSG="Bad number of cameras given! (cannot be negative)"
    L2_REZ="$2"
    L_REZOK="FALSE"
    if [ $L2_CAMERAS -lt 1 -o $L2_CAMERAS -gt 99 ] ; then
	unset L2_CAMERAS L2_REZ
	return 1
    elif  [ $L2_CAMERAS -gt 99 ] ; then
	GBL_ERROR_MSG="Bad number of cameras given! (over 99 is too many)"
	unset L2_CAMERAS L2_REZ
	return 1
	fun_error "Bad number of cameras given! (0 < cameras < 100)"
    elif  [ "$L2_REZ" = "1920x1080" ] ; then
        L_REZOK="TRUE"
    elif  [ "$L2_REZ" = "1280x720" ] ; then
        L_REZOK="TRUE"
    elif  [ "$L2_REZ" = "640x480" ] ; then
        L_REZOK="TRUE"
    elif  [ "$L2_REZ" = "320x240" ] ; then
        L_REZOK="TRUE"
    fi
    unset L2_CAMERAS L2_REZ
    if [ "$L_REZOK" = "FALSE" ] ; then
	fun_error "Bad resolution: use 1920x1080, 1280x720, 640x480, or 320x240"
    fi
    return 0
}



@@ 102,9 109,9 @@ fun_get_input () {
	fi
	if [ "$L_WRITE" = "y" ] || [ "$L_WRITE" = "" ] ; then
	    echo "#!/bin/sh" > ~/.s4/config
	    echo "S4_CAMERAS=$L_CAMERAS" >> ~/.s4/config
	    echo "S4_REZ=$L_REZ" >> ~/.s4/config
	    echo "S4_STORAGE=$L_STORAGE" >> ~/.s4/config
	    echo "S4_CAMERAS=\"$L_CAMERAS\"" >> ~/.s4/config
	    echo "S4_REZ=\"$L_REZ\"" >> ~/.s4/config
	    echo "S4_STORAGE=\"$L_STORAGE\"" >> ~/.s4/config
	    # check if s4 folder exists in user provided path
	    if ! [ -d "$L_STORAGE/s4" ] ; then
		fun_make_tree $L_CAMERAS $L_STORAGE


@@ 119,7 126,6 @@ fun_get_input () {
	fi
    else
	unset L_CAMERAS L_REZ L_STORAGE L_FRAMER8 L_WRITE
	fun_error $GBL_ERROR_MSG
    fi
}