From: Dolgov OV <dov@media-link.info>
To: community@altlinux.ru
Cc: Michael Shigorin <mike@osdn.org.ua>
Subject: [Comm] [SUMMARY] Дозвон по cron и исполнение скрипта.
Date: Sat, 19 Feb 2005 16:33:39 +0200
Message-ID: <20050219163339.56db09d7@localhost.localdomain> (raw)
In-Reply-To: <20050218145505.1c222934@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 431 bytes --]
On Fri, 18 Feb 2005 14:55:05 +0200 Dolgov OV wrote:
> На выходных постараюсь подготовить подробный рецепт "Обратный звонок с
> PAP+CBCP, несколько учетных записей и качаем по cron'у" для размещения
> в FAQ. Куда направлять результат?
Наваял. Кидаю пока сюда. Кто там за FAQ ответственен, если стоит -
размещайте. Вдруг я не один такой :-)
--
С наилучшими,
Олег Долгов
<dov AT media-link DOT info>
Registered Linux user #315454
[-- Attachment #2: CallBack,PAP+CBCP,other.txt --]
[-- Type: text/plain, Size: 7916 bytes --]
1. Îáðàòíûé çâîíîê ñ PAP+CBCP.
Äàííûé ìàòåðèàë îñíîâûâàþòñÿ íà ñòàòüå Àëåêñàíäðà Îãóðöîâà
(ã.Íèêîëàåâ, Óêðàèíà) è ñëåãêà äîïîëíÿåò åãî.
Îïèñàíûé íèæå ñïîñîá íå ïðåòåíäóåò íà îïòèìàëüíîñòü. Íî îáåñïå÷èâàåò
ñîåäèíåíèå è ðàáîòàåò.
Ñèñòåìà ALT Linux Compact-2.3
Ïðè ïåðâîíà÷àëüíîé ïðîçâîíêå ê ïðîâàéäåðó pppd îñóùåñòâëÿåò ñîåäèíåíèå,
ïðîèçâîäèò PAP àâòîðèçàöèþ è ñîãëàñíî ïðîòîêîëó CBCP ïåðåäàåò òåëåôîííûé
íîìåð ïî êîòîðîìó äîëæíà ïåðåçâîíèòü óäàëåííàÿ ñèñòåìà. Ïîñëå ýòîãî
ñîåäèíåíèå ðàçðûâàåòñÿ. Íàøà ñèñòåìà íà÷èíàÿ ñ ýòîãî ìîìåíòà æä¸ò
äîçâîíà îò óçëà ïðîâàéäåðà, ïîñëå îñóùåñâëåíèÿ êîòîðîãî è îñóùåñòâëÿåòñÿ
ñîáñòâåííî ñîåäèíåíèå, ïîäíÿòèå IP àäðåñîâ etc. Òàêèì îáðàçîì äîëæíû
ñóùåñòâîâàòü äâà ñöåíàðèÿ ïîâåäåíèÿ äåìîíà pppd (chat ñêðèïòà) ïðè
ñîåäèíåíèÿ â òàêèõ óñëîâèÿõ. Îäèí äëÿ èñõîäÿùåãî, âòîðîé äëÿ âõîäÿùåãî
ñîåäèíåíèÿ. À âîò òóò è íà÷èíàåòñÿ ñàìîå èíòåðåñíîå â äèñòðèáóòèâå Àëüò
äåìîí pppd ñîáðàí ñ ïîääåðæêîé ïðîòîêîëà îáðàòíîãî äîçâîíà â òîì ÷èñëå è
CBCP, â áîëåå ðàííèõ âåðñèÿõ äèñòðèáóòèâà ïàêåò ïîõîæå íàçûâàëñÿ
pppd-callback. Òàê âîò âòîðîé ñêðèïò - îòâåòà íà çâîíîê ñîçäàåòñÿ
àâòîìàòè÷åñêè è íàõîäèòñÿ â ôàéëå /etc/ppp/callback-client. Ïðîòîêîë
îáðàáîòêè îáðàòíîãî çâîíêà ðåãèñòðèðóåòñÿ â ñîáûòèÿõ netevent è äîçâîí
îò ïðîâàéäåðà îáðàáàòûâàåòñÿ èìåííî ýòèì ñêðèïòîì.
/etc/ppp/callback-client
==================================
#!/bin/sh
# Script callback-client
# Script parameters: delay time in seconds
DELAY="$1"
/usr/sbin/chat -v -t 2 "" \d+++\d\c OK ATH0 OK
sleep $DELAY
/usr/sbin/chat -v "" ATZ OK "" RING ATA SAY "RING" CONNECT
==================================
Äàëüøå ñîçäà¸ì ôàéë äîçâîíà ê ïðîâàéäåðó /etc/ppp/chat-cbcp
ñ ñîäåðæèìûì òèïà òàêîãî (íå çàáóäüòå â ñòðîêå ATDT óêàçàòü íîìåð ñâîåãî
ïðîâàéäåðà):
/etc/ppp/chat-cbcp
==================================
#!/bin/sh
#Request for CallbacK
#
/usr/sbin/chat -v \
TIMEOUT 7 \
ABORT "\nERROR\r" \
ABORT "\nNO DIALTONE\r" \
ABORT "\nBUSY\r" \
ABORT "\nNO ANSWER\r" \
ABORT "\nNO CARRIER\r" \
ABORT "\nLogin incorect\r" \
'' AT \
SAY "Modem Initialization\n" \
'OK-+++\c-OK' 'ATH0L2M2V1W2X4&c1E1q0' \
SAY "Dialing to ISP\n" \
TIMEOUT 60 \
OK ATDT479700 \
CONNECT '' \
SAY "Connected...\n" \
TIMEOUT 30 \
ogin: \c
exit 0
===================================
Ïèøåì ôàéë /etc/ppp/options.cbcp
===================================
defaultroute
noipdefault
persist
nodetach
connect '/etc/ppp/chat-cbcp'
user Âàø_ëîãèí
remotename Èìÿ_ïðîâàéäåðà
callback Íîìåð_äîçâîíà_ê_Âàì
===================================
È íàêîíåö ñîçäà¸ì ñêðèïò êîòîðûé áóäåò äîçâàíèâàòüñÿ, îí î÷åíü ïðîñòîé
/etc/ppp/ppp-on-dialer
===================================
#!/bin/sh
#
#Try to Connect Farlep CallBack
/usr/sbin/pppd /dev/modem 115200 file /etc/ppp/options.cbcp
===================================
Óáåäèòåñü ÷òî â ôàéëå /etc/ppp/pap-secrets ïðîïèñàíà ñòðîêà âèäà
Âàø ëîãèí Èìÿ_ïðîâàéäåðà Ïàðîëü_ó_ïðîâàéäåðà
Ïðè êîðåêòíî íàñòðîåíîé ñåòè âñ¸ ãîòîâî äëÿ ñîåäèíåíèÿ ñ ïðîâàéäåðîì. Äà
êñòàòè íå çàáóäüòå, ÷òî îáðàòíûé äîçâîí ó ïðîâàéäåðà ÿâëÿåòñÿ îòäåëüíîé
óñëóãîé, ïðîêîíñóëüòèðóéòåñü â ñëóæáå òåõ.ïîääåðæêè ïðîâàéäåðà î
ïðåäîñòàâëåíèè âàì òàêîâîé.
Âòîðîé âîïðîñ î òîì êàê ñäåëàòü ýòîò äîçâîí äîñòóïíûì ïîä
ïîëüçîâàòåëüñêèì àêêàóíòîì? Âîñïîëüçóþñü ñîâåòîì Ìèõàèëà Øèãîðèíà.
Äîçâàíèâàòüñÿ ìîãóò ïîëüçîâàòåëè èç ãðóïïû UUCP
grep uucp /etc/group
uucp:x:14:uucp,into,íó è îñòàëüíûå ÷åðåç çàïÿòóþ
Ïðàâà äîñòóïà ê ôàéëàì è óñòðîéñòâàì ñëåäóþùèå:
-rwxr-xr-x 1 root root 211 ... /etc/ppp/callback-client
-rwxr-x--- 1 root uucp 586 ... /etc/ppp/chat-cbcp
-rw-r--r-- 1 root root 103 ... /etc/ppp/options.cbcp
-rwxr-x--- 1 root uucp 116 ... /etc/ppp/ppp-on-dialer
-rw------- 1 root root 26 ... /etc/ppp/pap-secrets
lrwxrwxrwx 1 root root 10 ... /dev/modem -> /dev/ttyS1
crw-rw---- 1 root uucp 4, 65 ... /dev/ttyS1
-rws--x--- 1 root uucp 218904 ... /usr/sbin/pppd
Ïîñëå ýòîãî íà ðàáî÷åì ñòîëå ïîëüçîâàòåëÿ ìîæíî ñîçäàòü ññûëêó íà ôàéë
/etc/ppp/ppp-on-dialer è çàïóñêàòü ñîåäèíåíèå îäíèì ùåë÷êîì. Äëÿ
èíäèêàöèè ðàáîòû ppp ìåíÿ âïîëíå óñòðàèâàåò àïïëåò â gkrelm.
2. Íåñêîëüêî ó÷åòíûõ çàïèñåé.
 ìîåì êîíêðåòíîì ñëó÷àå èñïîëüçóþòñÿ èíòåðíåò-êàðòû ñ îïðåäåëåííûì
áàëàíñîì, ïî èñòå÷åíèè êîòîðîãî ó÷åòíàÿ çàïèñü (ëîãèí) àííóëèðóåòñÿ. Äëÿ
äàëüíåéøåé ðàáîòû â ñåòè íåîáõîäèìî èçìåíèòü èìÿ ïîëüçîâàòåëÿ â
/etc/ppp/options.cbcp à òàêæå ëîãèí è ïàðîëü â /etc/ppp/pap-secrets
Îäèí ðàç â ìåñÿö ýòî íå íàïðÿãàåò :-) À êàê áûòü åñëè â ðàçíîå âðåìÿ
ñóòîê èñïîëüçóþòñÿ ðàçíûå àêêàóíòû ñ ðàçëè÷íûìè ïðèíöèïàìè òàðèôèêàöèè?
Ðóêàìè ìåíÿòü íàäîåñò, îñîáåííî åñëè îäèí ðàáîòàåò äíåì, à âòîðîé íî÷üþ
:-)
Âñå î÷åíü ïðîñòî. Èìÿ ïîëüçîâàòåëÿ (â òîì ÷èñëå è äëÿ ïîñëåäóþùåé PAP
àóòåíòèôèêàöèè) ñîäåðæèò â ñåáå ôàéë /etc/ppp/options.cbcp
Òàê è ñîçäàäèì åìó áðàòà-áëèçíåöà ñî âòîðûì àêêàóíòîì, äîïóñòèì
/etc/ppp/options.cbcp2 à òàêæå ñäåëàåì âòîðîé ñêðèïò äîçâîíà
/etc/ppp/ppp-on-dialer2 êîòîðîãî ïîïðîñèì â êà÷åñòâå ôàéëà îïöèé äëÿ
pppd èñïîëüçîâàòü íàø /etc/ppp/options.cbcp2
/etc/ppp/ppp-on-dialer2
===================================
#!/bin/sh
#
#Try to Connect Farlep CallBack
/usr/sbin/pppd /dev/modem 115200 file /etc/ppp/options.cbcp2
===================================
Òàêæå íåîáõîäèìî â /etc/ppp/pap-secrets âòîðîé (òðåòüåé, ÷åòâåðòîé è
ò.ä.) óêàçàòü ïàðîëü ñâîåãî âòîðîãî àêêàóíòà.
Âàø_ëîãèí2 Èìÿ_ïðîâàéäåðà Ïàðîëü_ó_ïðîâàéäåðà2
Ó ìåíÿ òàêèì îáðàçîì ðàáîòàåò äíåì îäíà êàðòà ñ ïî÷àñîâîé îïëàòîé, à
íî÷üþ - âòîðàÿ, áåç îãðàíè÷åíèÿ ïî âðåìåíè, íî îãðàíè÷åíà â äîñòóïå ïî
âðåìåíè ñóòîê.
3. Çâîíèì è êà÷àåì ïî ðàñïèñàíèþ.
Òàê âîò, ïî íî÷àì ÿ, êàê è âñå íîðìàëüíûå ëþäè, îáû÷íî ñïëþ :-) Íî
ïî÷åìó áû êîìïüþòåðó íå ïîðàáîòàòü?
Äëÿ ýòîãî íàì íåîáõîäèì ïàêåò crontabs, vixie-cron è çàïóùåííûé ñåðâèñ
crond.
×òîáû íå ìåøàòü ñâîèìè çàêà÷êàìè, äîçâîíàìè êðîíó âûïîëíÿòü ñâîè
îñíîâíûå ôóíêöèè
1. Ñîçäàäèì ñâîé êàòàëîã /etc/cron.night â êîòîðîì ðàçìåñòèì ñèìëèíê íà
/etc/ppp/ppp-on-dialer2
2. Íåìíîãî ìîäèôèöèðóåì /etc/ppp/options.cbcp2 äîáàâèâ â íåì ñòðîêó:
linkname NIGHT
(! ýòà îïöèÿ òðåáóåò, ÷òîáû pppd çàïóñêàëñÿ îò èìåíè root ÷òîáû ïîëó÷èòü
äîñòóï â êàòàëîã /var/run) Áëàãîäàðÿ ýòîé îïöèè áóäåò ñîçäàâàòüñÿ
ïåðñîíàëüíûé PID ôàéë ïðè äîçâîíå íàøèì êîíêðåòíûì "íî÷íûì" ñêðèïòîì.
3. Óêàæåì êðîíó, êîãäà ìû õîòèì çâîíèòü, äîïèñàâ â /etc/crontab ñòðîêó
(ñì. /etc/crontab.temlate äëÿ ïðèìåðà)
05 2 * * * root run-parts /etc/cron.night
Òàêèì îáðàçîì êàæäûé äåíü â 2:05 êðîí áóäåò âûïîëíÿòü âñå ïðîãðàììû,
ñêðèïòû, êîòîðûå Âû ïîìåñòèòå â /etc/cron.night (è âûïîëíÿòü áóäåò îò
èìåíè root, ÷òî íàì è íåîáõîäèìî)
Òåïåðü íåîáõîäèìî íàó÷èòü ñèñòåìó ïðàâèëüíî ðåàãèðîâàòü íà äîçâîí
êîíêðåòíûì ñêðèïòîì. Ñîçäàåì (åñëè åãî åùå íåò) /etc/ppp/ip-up.local
(ÿ ïðîñòî ñêîïèðîâàë ip-up -> ip-up.local äàáû ïîòîì íå çàìîðà÷èâàòüñÿ
âñÿêèìè chmod :-)
/etc/ppp/ip-up.local
====================================
#!/bin/sh
if [ -e /var/run/ppp-NIGHT.pid ]; then
wget -c -P /êóäà/ïîëîæèòü -i ñïèñîê_àäðåñîâ.txt &
fi
exit 0
=====================================
Âñå. Ìîæíî ñïàòü ñïîêîéíî :-)
PS. Íà îñíîâå ýòîãî ìîæíî íàïëîäèòü ñöåíàðèåâ äîçâîíà ñ ðàçëè÷íûìè
ïàðàìåòðàìè linkname è âàðèàíòîâ ðåàêöèé íà ýòè äîçâîíû â
/etc/ppp/ip-up.local
íàïð. ïîçâîíèë, ïðîâåðèë ïî÷òó è îòâàëèëñÿ (ýòî ñàìîå ïðîñòîå, ÷òî
ïðèøëî â ãîëîâó :-) Îñòàëüíîå çà Âàøåé ôàíòàçèåé è ïîòðåáíîñòüþ.
next prev parent reply other threads:[~2005-02-19 14:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-17 10:59 [Comm] " Dolgov OV
2005-02-17 14:09 ` Dolgov OV
2005-02-17 14:40 ` Dolgov OV
2005-02-17 15:09 ` Dmytro O. Redchuk
2005-02-17 16:35 ` Dolgov OV
2005-02-17 16:44 ` Dmytro O. Redchuk
2005-02-17 16:00 ` Afanasov Dmitry
2005-02-17 16:53 ` Dolgov OV
2005-02-18 12:55 ` Dolgov OV
2005-02-19 14:33 ` Dolgov OV [this message]
2005-02-20 19:45 ` [Comm] [SUMMARY] " gnostik
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=20050219163339.56db09d7@localhost.localdomain \
--to=dov@media-link.info \
--cc=community@altlinux.ru \
--cc=mike@osdn.org.ua \
/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