#!/bin/bash
###############################################################################
#Script pentru configurarea conexiunii ppp pe un telefon Zapp (Hyundai 100)
#Realizat de Dalis-Adrian Pantalache la data  Dec 12 12:02:13 EET 2001
# este necesara existenta pachetului ppp pentru realizarea conexiunii
#
###############################################################################
#
#Setari cai
CAT=/bin/cat
PPP=/usr/sbin/pppd
#
# Crearea fisierelor de chat si configurare a modemului
#echo -e " "
#echo -e " "
clear
echo -en "\n Acest program de instalare a unei conexiuni zapp, este gratis, se afla sub licenta GNU, programul scrie in fisierele /usr/bin/zapp /etc/ppp/chat-zappmobile si in /etc/ppp/peers/hyundai-zappmobile , daca aveti aceste fisiere va rog sa faceti o copie a originalului deoarece este posibil sa fie suprascrise, programul este livrat cu sursa.  Autorul acestui program si firma Telemobil nu isi asuma nici o responsabilitate pentru orice tip de daune care pot apare pagube (d/n):"

dataflag0=""
read dataflag0

if [ $dataflag0 = d ]
    then


echo -en "\nInstalez telefonul \033[41;33;1m Zapp \033[m pe portul serial ? (d/n):"

dataflag1=""
read dataflag1

if [ $dataflag1 = d ]
    then
echo -en " \n"
echo -en "Pe ce com ? COM1 tasteaza= 1, COM2 tasteaza= 2 :"
read cmd
case "$cmd" in
	"1")
		COM=ttyS0
		;;
	"2")
		COM=ttyS1
		;;
	 *)
		echo -en " \n"
		echo -en "Nu ai ales \033[41;33;1m COM-UL \033[m corect te rog reporneste programul \n"
		exit
		
		
		
esac

mkdir -p /etc/ppp/peers
mv /etc/ppp/chat-zappmobile /etc/ppp/chat-zappmobile.bk
$CAT <<EOF >>/etc/ppp/chat-zappmobile
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
ABORT "BUSY"
ABORT "Username/Password Incorrect"
"" "ATZ"
OK "AT&C0+CRM=1"
OK "ATDT#777"
EOF
mv /etc/ppp/peers/hyundai-zappmobile /etc/ppp/peers/hyundai-zappmobile.bk
$CAT <<EOF >>/etc/ppp/peers/hyundai-zappmobile
$COM 115200 crtscts
connect '/usr/sbin/chat -v -f /etc/ppp/chat-zappmobile'
noauth
#defaultroute
replacedefaultroute
#-detach
persist
passive
EOF
echo "*		*	*	*" >>/etc/ppp/pap-secrets
mv /usr/bin/zapp /usr/bin/zapp.bk
$CAT <<EOF >>/usr/bin/zapp
$PPP call hyundai-zappmobile &
EOF
chmod 700 /usr/bin/zapp

echo -en "\nTe rog verifica telefonul sa fie setat pe viteza de transfer  \033[41;33;1m 115200 \033[m"
echo -en "\nMENU->7->3->( 115200 )"
echo -en "\nMENU->7->2->( HARDWARE )"
echo -en "\n\nE configurat corect telefonul ? (d/n):"
dataflag2=""
read dataflag2
if [ $dataflag2 = d ]
    then
echo -en " \n"
echo -en "\nVrei sa intrii acum pe Internet ?(d/n):"
dataflag3=""
read dataflag3

if [ $dataflag3 = d ]
    then

cat <<EOF

 Scripturile au fost configurate acestea se afla in urmatoarele locuri
 /usr/bin/zapp, /etc/ppp/chat-zappmobile si in /etc/ppp/peers/hyundai-zappmobile
 pentru a porni o conexiune tasteaza comanda urmatoare de pe contul root
 
 zapp
EOF


$PPP call hyundai-zappmobile &


####
    else 
cat <<EOF

  Scripturile au fost configurate acestea se afla in urmatoarele locuri
 /usr/bin/zapp, /etc/ppp/chat-zappmobile si in /etc/ppp/peers/hyundai-zappmobile
 pentru a porni o conexiune tasteaza comanda urmatoare de pe contul root

 zapp
EOF

fi
fi
####aici pe USB


    else echo " iesire"
fi

    else echo "iesire"
fi