#!/bin/sh

cur_path="${0%/*}"
config_file="$cur_path/VolumeSet.ini"

volume_set=$(awk -F':' '/VolumeSet:/ { gsub(/\r|\n/, "", $2); print $2 }' "$config_file")
default_volume=$(awk -F':' '/DefaultVolume:/ { gsub(/\r|\n/, "", $2); print $2 }' "$config_file")

setflag()
{
	if [ "$1" = "yes" ]; then
		[ -e "$2" ] || touch $2
	else
		[ -e "$2" ] && rm $2
	fi
}

if [ "$volume_set" = "yes" ]; then
    if [ "$default_volume" -le "100" ]; then
        setflag $volume_set /mnt/mtd/Flags/initDefaultVolume
        echo "$default_volume,$default_volume" > /mnt/mtd/Flags/SupportDefaultVolumeFlag
    fi
elif [ "$volume_set" = "no" ]; then
    rm -f /mnt/mtd/Flags/initDefaultVolume
    rm -f /mnt/mtd/Flags/SupportDefaultVolumeFlag
fi
