script 1 root@time:~# cat arec.sh #!/bin/sh while [ 1==1 ] ; do ping=0 for n in `awk '/nameserver/{print $2}' /etc/resolv.conf | xargs` ; do if ping -c 1 $n > /dev/null ; then ping=1 fi done if ! [ $ping == "1" ] ; then logger ADSL connection restarted /etc/init.d/dial start #killall pppd #ifconfig nas0 0 #killall br2684ctl #/etc/init.d/dial start fi sleep 60 done root@time:~# nu am stiut ce sa ii fac,am tot incercat sa modific si etc,dar kkt script 2 #5 * * * * if ! ping -c 1 -n 193.231.100.2 > /dev/null ; then /etc/init.d/dial start ; logger ADSL connection restarted ; fi asta nu prea e script dar ma rog,tot nu a mers script 3. asta l-a facut cineva pentru mine,dar tot nu merge si nu ne-am dat seama de ce root@time:~# cat autorecon.sh #!/bin/bash SLEEP=60 GATEWAY=$(ip addr show dev ppp0 | \ sed -n 3p | \ awk '{ print $4 }' | \ sed -e 's:/[0-9]*::' \ ) #TIMER=/var/run/autorecon.timer TIMER=/tmp/autorecon.timer # for non-root tests PASS=0 do_dnsstuff() { # Whatever ;) echo "DNS stuff..." } do_pass() { ((PASS++)) echo $(($(date +%s)+($SLEEP*2+5))) > $TIMER echo $PASS >> $TIMER take_action } take_action() { # Here are the reconnect attemps number and actions to take. case $PASS in 2|4|5|6) echo /etc/init.d/dial restart;; 3) echo /etc/init.d/natfire restart;; 7) echo reboot;; esac exit -$PASS } if [ -e $TIMER ]; then if [ $(date +%s) -lt $(sed -n "1p" $TIMER) ]; then PASS=$(sed -n "2p" $TIMER) rm $TIMER else rm $TIMER fi fi # See if the ATM bridge or pppd died. if [ -z $(pidof pppd) ] || [ -z $(pidof br2684ctl) ]; then echo "pppd or ATM bridge died." do_pass fi # See if ppp0 exist in the links. if [ -z $GATEWAY ]; then echo "ppp0 does not exist." do_pass fi # If ping fails, take actions. ping -c 3 $GATEWAY > /dev/null || do_pass echo "Ping OK" # If DNS fails, take actions for DNS. host google.com > /dev/null || do_dnsstuff echo "DNS OK" exit 0 root@time:~# script 4 asta este scriptul de dial pe care il folosesc cand dau /etc/init.d/dial start sa se reconecteze dupa ce pica root@time:~# cat /etc/init.d/dial #!/bin/bash modprobe ppp_generic modprobe pppoatm modprobe br2684 fix_config() { sed -i 's@gateway@# gateway@g' /etc/network/interfaces && sed -i 's@dns@# dns@g' /etc/network/interfaces && rm -f /etc/resolv.conf } start_modem() { br2684ctl -b -c 0 -a 0.35 sleep 3s ifconfig nas0 192.168.0.1 netmask 255.255.255.0 up pppd call speedtch } stop_modem() { killall pppd ifconfig nas0 0 killall br2684ctl } case $1 in start) SYNCHED=0 fix_config for COUNT in $(seq 0 30) do stop_modem sleep 2s start_modem sleep 8s if [ ! -z $(pidof pppd) ]; then echo "ADSL is up and running." exit 0 fi done cp -L /etc/ppp/resolv.conf /etc ;; stop) stop_modem ;; restart) $0 stop sleep 5s $0 start ;; status) BRIDGE="up" MODEM="up" [ -z $(pidof br2684ctl) ] && BRIDGE="down" [ -z $(pidof pppd) ] && MODEM="down" echo "Bridge is $BRIDGE and modem is $MODEM." ;; *) echo "Usage: $0 start|stop|restart|status" ;; esac root@time:~# cam asta e tot