From: Alexander Kharkov <umount@bk.ru> To: community@altlinux.ru Subject: Re: [Comm] synaptic Date: Fri, 3 Oct 2003 01:42:06 +0400 Message-ID: <200310030142.06296.umount@bk.ru> (raw) In-Reply-To: <200309292334.28030.umount@bk.ru> В сообщении от 29 Сентябрь 2003 23:34 Alexander Kharkov написал(a): > В сообщении от 28 Сентябрь 2003 18:36 Pyatnitskich Evgeniy написал(a): > > Опубликуйте, пожалуйста. > > в аттаче > исправления ошибок, ежели найдете или там добавления какие - высылайте, > буду рад люди, просящие меня прислать скрипт, да посмотрите пост, мой преддыдущий для особо непонятливых привожу его тут целиком, я не имею возможности отвечать всем лично к сожалению ------------------------------------кусь-------------------------------- #!/bin/sh # Скрипт для дозвона до провайдера с скачиванием апдейтов для сизифа # с последующим отключением от линии. При возникновении ошибок линия # сбрасывается, и дозвон осуществляеся снова # Copyright (c) Alexander Kharkov 2003 # Установка переменных PATH=/bin:/sbin:/usr/bin:/usr/sbin FREETIME=9 DROPLINE=0 POWEROFF=0 MAXTRYNO=5 DEBUG=0 PIDFILE=/var/run/netnight.pid CURRUNPID=0 # Функция проверяет наличие интерфеса ppp0 # Если интерфес не поднят - возвращает ошибку # Может подождать с определением, если указать # один числовой параметр. В этом случае функция # ждет указанное количество секунд и только после # этого проверяет интерфейс is_ppp_up() { if [ $DEBUG -eq 1 ]; then echo "in is_ppp_up()" fi if [ $# -lt 1 ]; then if [ $DEBUG -eq 1 ]; then echo We will not sleep!!! fi else expr $1 + 1 > /dev/null 2>&1 STATUS=$? if [ "$STATUS" != "0" ]; then echo `basename $0` : First parameter is not valid >&2 echo `basename $0` : $1 is not a number!!!! >&2 echo `basename $0` : Setting default interval - 1 minute >&2 INTERVAL=60 else INTERVAL=$1 fi if [ $DEBUG -eq 1 ]; then echo "Sleeping for $INTERVAL second(s)" fi sleep $INTERVAL fi if ifconfig | grep ppp0 > /dev/null 2>&1 then if [ $DEBUG -eq 1 ]; then echo We are online at `date` fi return 0 else if [ $DEBUG -eq 1 ]; then echo We are offline at `date` fi return 1 fi if [ $DEBUG -eq 1 ]; then echo "out is_ppp_up()" fi } # Функция поднимает интерфейс ppp0. В случае если он # уже поднят функция или перезавниевает, если функции # переается аргумент или не делает ничего ppp_up() { if [ $DEBUG -eq 1 ]; then echo "in ppp_up()" fi if [ $# -lt 1 ]; then if [ $DEBUG -eq 1 ]; then echo We will drop line!!!! echo Trying to down ppp0 at `date` fi STATUS=1 while [ "$STATUS" != "0" ]; do ifdown ppp0 STATUS=$? done echo ppp0 down at `date` else if [ $DEBUG -eq 1 ]; then echo We will not drop line!!! fi fi echo Trying to connect to Internet if is_ppp_up > /dev/null then if [ $DEBUG -eq 1 ]; then echo `basename $0` : We are already online echo `basename $0` : If you want to REdial call ppp_up without echo `basename $0` : any parameters fi return 1 fi STATUS=1 while [ $STATUS -ne 0 ]; do ifup ppp0 STATUS=$? if [ $STATUS -ne 0 ]; then ifdown ppp0 sleep 30 fi done echo ppp0 is upped at `date` if [ $DEBUG -eq 1 ]; then echo "out ppp_up()" fi return 0 } # Функция выводит краткую справку по программе usage() { echo "Program to automatic dialing and downloading" echo "updates for Alt Linux Sisyphus". echo "You can use this parameters:" echo "-h or --help - this screen" echo "-d or --dropline - disconnect from Internet while" echo " download all uodates successfully" echo "-p or --poweroff - power off the machine after" echo " downloading updates" echo "--debug - display debug information" exit 0 } # Функция на выходе из программы atexit() { if [ $DROPLINE -eq 1 ] ; then ifdown ppp0 fi rm -f $PIDFILE # по идее надо бы удалять pid файл в самом конце # но в связи "необычностью" выхода с выклчением # PID файл удалаяется до того, как отработает # вся программа if [ $POWEROFF -eq 1 ] ; then poweroff fi } # Функция при старте atstart() { echo Starting script at `date` echo $$ > $PIDFILE ppp_up 1 } # Запускает строки, которые предаются функции в качестве параметров runcommand() { if [ $DEBUG -eq 1 ]; then echo "Entering runcommand at `date`" fi if [ $# -eq 0 ] ; then echo "`basename $0` : Command not defined in run function runcommand" >&2 exit 1 fi if [ $DEBUG -eq 1 ]; then echo "Entering while cycle in runcommand" fi while [ $# -gt 0 ]; do STAT=1 if [ $DEBUG -eq 1 ]; then echo "Entering buildin while cycle in func runcommand" fi TRYNO=0 while [ $STAT -ne 0 ]; do $1 STAT=$? if [ $STAT -ne 0 ]; then TRYNO=`expr $TRYNO + 1` if [ $DEBUG -eq 1 ]; then echo Running $1 unsuccessfull fi CURHOUR=`date +%k` if [ $CURHOUR -lt $FREETIME ]; then echo "Redialing" ppp_up else echo "Free time is out!" echo "Current time: `date +%T`" atexit exit 0 fi fi if [ $TRYNO -eq $MAXTRYNO ]; then echo "We have maximum number of errors!!! Skipping command $1" return 1 fi done if [ $DEBUG -eq 1 ]; then echo "Leaving buildin while cycle in func runcommand" fi shift done if [ $DEBUG -eq 1 ]; then echo "Leaving while cycle in runcommand" echo "Leaving runcommand at `date`" fi } # Основная программа while [ $# -gt 0 ]; do case $1 in -d|--dropline) DROPLINE=1 ;; -p|--poweroff) POWEROFF=1 ;; -h|--help) usage ;; --debug) DEBUG=1 ;; *) echo "$1 - is not a valid parameter! Try ---help for more information" >&2; atexit; exit 1 esac shift done atstart runcommand "apt-get -q update" runcommand "apt-get -y autoclean" runcommand "apt-get -q -y -d dist-upgrade" runcommand "apt-get -q -y -d install kernel-modules-.*-std-up" #здесь можно загнать другие команды atexit ------------------------------------кусь---------------------------------- ----------------- Всех благ, Alexander
next prev parent reply other threads:[~2003-10-02 21:42 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-09-26 22:39 x-plod 2003-09-26 22:41 ` x-plod 2003-09-27 9:17 ` Egor S. Orlov 2003-09-27 23:00 ` Alexander Kharkov 2003-09-28 14:36 ` Pyatnitskich Evgeniy 2003-09-29 19:34 ` Alexander Kharkov 2003-10-02 21:42 ` Alexander Kharkov [this message] 2003-09-29 9:08 ` Re[2]: " "KoLyA"
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=200310030142.06296.umount@bk.ru \ --to=umount@bk.ru \ --cc=community@altlinux.ru \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Community general discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 community community/ http://lore.altlinux.org/community \ mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com public-inbox-index community Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.community AGPL code for this site: git clone https://public-inbox.org/public-inbox.git