Лясны жыхар (soko1) wrote,
Лясны жыхар
soko1

  • Music:

spp.sh

Опять подарок для диалапщиков:)
Надоел мне этот долбаный провайдер - почти час трачу на дозвоны.
Поскольку надоедает по сто раз перезапускать ppp - написал скрипт, который дозванивается до провайдера указанное число раз, с указанным интервалом времени.
Юзайте на здоровье, кому надо.

#!/bin/sh

# Copyright (c) 2006 Sokolov Alexey <nullbsd@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.

time=3 # время ожидания (в секундах) перед дозвонами
ctr_connect=10 # колличесво попыток дозвона
logfile="/tmp/spp.log" # лог-файл

ctr=0 # счетчик
sudo_program="sudo" # программа для получения привилегий root
sleep_program="sleep $time" # программа для "засыпания"
ppp_program="ppp -background" # программа для дозвона

:> $logfile # создаем/очищаем лог-файл

# это для моего вин-модема на чипсете gLucent (должен быть установлен порт: /usr/ports/comms/ltmdm)
# если у вас не вин-модем - можете закомментить эти две строки
(kldstat | grep ltmdm) >> $logfile
if [ $? -ne 0 ]; then ($sudo_program kldload ltmdm) >> $logfile; fi

#ps -A | grep $ppp_program >/dev/null 2>&1
#if [ $? -ne 0 ]; then
#       echo "Program running!"
#       exit
#fi

ARGS=$#
arg1=$1

if [ $ARGS -ne 1 ]; then
        echo "usage: spp [join_name]"
        echo " example:"
        echo ' $spp papchap'
        echo
        exit
fi

while [ $ctr -ne $ctr_connect ]; do
        let "ctr += 1" > /dev/null # увеличиваем на единицу
        echo "Attempt No: $ctr (out of $ctr_connect)";
        ($sleep_program; $sudo_program $ppp_program $1) >> $logfile # "засыпаем" и дозваниваемся до провайдера

        if [ $? -ne 0 ]; then # если не дозвонились...
                echo "No connection!"
                echo
        else
                echo "Connection: OK!"
                exit
        fi
done
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 8 comments