#!/bin/bash

cd /dev
if [ -e ttyUSB0 ]
then
	cd /home/server
	     if [ -e lock_up_restart ]
	     then
	         a=$(sed -n '1p' lock_up_restart)
	           if [ $a = 1 ] || [ $a = 2 ] || [ $a = 3 ]
	              then
	                 cd /usr/local/pressnet/etc
	                 if [ -e record ]
	                 then
	                    b=$(sed -n '1p' record)
	                    bR=`expr $b + 1`
	                    sed -ie '1d' record
	                    echo $bR >> record
	                 else
	                    exit
	                 fi
	           else
	               exit
	           fi
	     else
	         exit
	     fi
else
   cd /usr/local/pressnet/etc
   if [ -e record ]
   then
      number=$(sed -n '1p' record)
      numberR=`expr $number + 1`
      sed -ie '1d' record
      echo $numberR >> record
   else
     exit
   fi
fi
