Newer
Older
clusterSetupDev / scripts / lxc / getSeq.sh
DIR=$PWD/counter
mkdir -p $DIR
agrc=$#
seqName=default
action="next"
if [ ! "$agrc"  -le 0 ]
then
#{
#	echo "WARNING: There is no argument, sequence name is used default"
#}
#else
#{
	seqName=$1
	if [ "$2" != "" ]
	then
		action=$2
	fi
#}
fi
fileName=$DIR/$seqName
count=0
returnCount=0
if [  -f $fileName ]
then
#{
 
	count=$(cat  $fileName)
	if [ "$action" == "current" ]
	then
		returnCount=$count
 
	elif [ "$action" == "current++" ]
	then
		returnCount=$count
		count=`expr $count + 1`
	elif [ "$action" == "++current" ]
	then
		count=`expr $count + 1`
		returnCount=$count
	elif [ "$action" == "--current" ]
	then
		count=`expr $count - 1`
		returnCount=$count
	elif [ "$action" == "current--" ]
	then
		returnCount=$count
		count=`expr $count - 1`
	elif [ "$action" == "previous" ]
	then
		count=`expr $count - 1`
		returnCount=$count
	else
		count=`expr $count + 1`
		returnCount=$count
	fi
#}
else
#{
	#echo "initilize count"
	returnCount=$count
#}
fi
 
echo "$count" > $fileName
#return $count
echo $returnCount
exit 0