ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Arioch <the_Arioch@nm.ru>
To: community@altlinux.ru
Cc: week@altlinux.ru
Subject: [Comm] листая /etc/init.d/slmodemd
Date: Sat, 30 Jul 2005 17:27:52 +0400
Message-ID: <42EB8058.6090300@nm.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

slmodemd - это демон многих win-модемов, например одного, встроенного в
мой ноут (MaxSelect.ru M620).

Сижу практически без инета - потому все письма готовлю в офлайне.
Потому же Сизиф у меня примерно месячной давности, там где BootSplash
(или в соотв. с документациейBootSlash - это IMHO правильней) совместно
с initrd от wks 2.6.11 alt 4 не хотят загружаться по хорошему :)
Надеюс в данном случае не за вчерашним днём погнался :D

В багтрэкер не кладусь поскольку в офлайне и поскольку ожидаю вправления
рук или надавания по оным. Когда прочитаю ответы (if any) не знаю, но
как-нибудь случиться же :-)



Во-первых захотелось, чтобы скрипт создавал при возможности /dev/modem;
в память о весенней, кажется, kppp не признававшей устройств "/dev/ttySL?"

Попутно выяснилось, что скрипт забывает стереть PIDFILE

Покореженный скрипт в аттаче.

PS: интересно, что у нас с gnome-ppp? Он, в отличие от kppp гвоздями
прибит к группе netadm и ни в жисть не позволит простому юзеру поднять
соединение? К kppp у меня теперь идиосинкразия ;)

PPS: зато на сам модем права имеют только root и uucp
Кто по идеологии Альта должен иметь права на /dev/modem ?

PPPS: дай бог мне этот модем настроить, когда в HOWTO описан
несуществующий у меня usernetctl зато напрочь отсутствует etcnet :(
И да сумеет модем дозвoниться до одного номера (если да - значит
старокривые дрова в винде. Если нет - значит вообще нет :( )









[-- Attachment #2: slmodemd --]
[-- Type: text/plain, Size: 4041 bytes --]

#!/bin/sh
# $Id: template,v 1.3 2003/05/21 17:47:00 ldv Exp $
### the_Arioch@nm.ru - i wanna /dev/modem symlink be automagic
#
# slmodemd		Smartlink softmodem driver daemon
#
# chkconfig: 345 90 10
# description:	slmodemd is SmartLink softmodem drivers daemon
#		
#		
# processname: slmodemd

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

PIDFILE=/var/run/slmodemd.pid
LOCKFILE=/var/lock/subsys/slmodemd
RETVAL=0

#Arioch - since slmodem now features SysFS interface - lets engage it
SYSFS_DRIVERS=/sys/class/{slusb,slamr}
# i do not know what to do with ALSA modems - and how do they show up;
# also i do not have usb modem and hope it will just follow slamr pattern.
# I assume if someone have built-in modem (slamr) and at the same time external
# one (slusb) - he prefers USB one.


#Now, what env-vars respect ls ? can i unexpectedly get verbose output without -l argument?
#Something like LS_COLORS or like DirCmd in DOS/Windows, i need to clear before invoking ls ?


SYSFS_DEVICES=
#in case it was borrowed from parent process
[[ -d /sys ]] && SYSFS_DEVICES=`for fold in /sys/class/{slusb,slamr}; do ls $fold ; done 2>/dev/null`

#i guess, for 2.4 kernels one could have one more list instead of sysfs
#parsing dmesg, or returned by slmodemd --SomeQueryOption, or from /etc/SomeWhere
## End of Arioch (yet)

start()
{
	action "Starting slmodem daemon: " start-stop-daemon --quiet --start -b -m --pidfile $PIDFILE --exec /usr/sbin/slmodemd -- --country=RUSSIA
	RETVAL=$?

  #     Arioch:
  #	1st existing slmodem device i'd like to see symlinked as /dev/modem - if /dev/modem is not occupied already
  #     But let returning value stay the daemon's return code
        if [ $RETVAL -eq 0 ]; then
           if [[ ! -e /dev/modem  ]]; then 
	      for smth in "$SYSFS_DEVICES"; do
                  [[ -e /dev/$smth ]]  && ( ln -s /dev/$smth /dev/modem ; break )
              done;
	   fi 
	fi
	# A rake, i placed here: imagine someday DEVFS or UDEV would move slamr0 to, say,
	#  /dev/modems/slamr0 or to any other subfolder - "[[ -e /dev/$smth ]]" would fail.
	# To avoid stepping upon the rake someday, we maybe can search throughout /dev.
	# /sys/class/(DRIVER)/(DEVICE)/dev contain major and minor and this can be 
	# used to find driver file wherever under /dev - but i don't know any easy way. 
  # End of Arioch (yet)
       
	return $RETVAL
}

stop()
{
	action "Stopping slmodem daemon: " start-stop-daemon --stop --quiet --pidfile $PIDFILE slmodemd
	RETVAL=$?
        
  # Arioch: let's wipe away /dev/modem, if it is our own link
        if [ $RETVAL -eq 0 ]; then
           local TARGET
 	# i'm afraid local is command, thus can affect value of $?
           TARGET=`readlink -e /dev/modem` && [[ -c $TARGET ]] && TARGET=`basename $TARGET`
	# see rooks in start().  
	
	#Now, how should i test is word is contained in list ?
	   [ $? -eq 0 ] && ( echo $SYSFS_DEVICES | grep -G "\<$TARGET\>" >/dev/null 2>/dev/null ) && rm -f /dev/modem


        #Neither slmodemd nor start-stop-daemon don't care about PID :-(
	   rm -f $PIDFILE
        fi
  # End of Arioch (yet)
	
	return $RETVAL
}

restart()
{
	stop
	sleep 1
	start
}

reload()
{
	msg_reloading slmodemd
	start-stop-daemon --stop --pidfile $PIDFILE -s HUP -- slmodemd
	RETVAL=$?
	return $RETVAL
} 

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	condreload)
		if [ -e "$LOCKFILE" ]; then
			reload
		fi
		;;
	status)
		status --pidfile "$PIDFILE" --expect-user root -- slmodemd
		RETVAL=$?
	# Arioch (next line, list of devices):
	        [[ -n "SYSFS_DEVICES" ]] && echo "  Known devices: $SYSFS_DEVICES"
	# End of Arioch. "finishing, closing and going home" 
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL



             reply	other threads:[~2005-07-30 13:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-30 13:27 Arioch [this message]
2005-07-30 15:47 ` Sergey Vlasov
2005-07-30 18:09   ` [Comm] " Arioch

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=42EB8058.6090300@nm.ru \
    --to=the_arioch@nm.ru \
    --cc=community@altlinux.ru \
    --cc=week@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