# slmodemd and wvdial init scripts :-D

## rusty

Hey folks,

Here is something that might be useful to those of you who use slmodem on your systems.

I love automation, and Gentoo has perfect tools for that. However, there is still no slmodem-2.9.x ebuild. I am sure no one minds that, because slmodem is farely easy to build with hands. However, having to run `slmodemd` every time I want to connect to internet is a bit of pain in the neck. So I wrote this init script  :Very Happy: . 

/etc/init.d/slmodemd :

```

#!/sbin/runscript

#/etc/init.d/slmodemd

 

opts="start stop"

 

start() {

    ebegin "Starting slmodemd"

 

    # The default values

    : ${COUNTRY:=USA}

    : ${DEVICE:=/dev/slamr0}

    : ${ALSA:=no}

 

    case "$ALSA" in

    yes) start-stop-daemon --start --quiet --background \

         --exec /usr/sbin/slmodemd -- --country="$COUNTRY" --alsa "$DEVICE"

         eend $?

         ;;

    no)  start-stop-daemon --start --quiet --background \

         --exec /usr/sbin/slmodemd -- --country="$COUNTRY" "$DEVICE"

         eend $?

         ;;

    *)   eerror "Script error! Exiting..."

         eend 1

         exit 1

         ;;

    esac

 

}

 

stop() {

    ebegin "Stopping slmodemd"

    start-stop-daemon --stop --quiet --exec /usr/sbin/slmodemd

    eend $?

}

```

This file can be configured through /etc/conf.d/slmodemd :

```

#/etc/conf.d/slmodemd

 

#

# Uncommment the entry with your country

# Default USA is used if none are uncommented.

#

# COUNTRY="ALGERIA"

# COUNTRY="ARGENTINA"

# COUNTRY="AUSTRALIA"

# COUNTRY="AUSTRIA"

# COUNTRY="BAHREIN"

# COUNTRY="BELGIUM"

# COUNTRY="BRAZIL"

# COUNTRY="BRUNEI"

# COUNTRY="BULGARIA"

# COUNTRY="CANADA"

# COUNTRY="CHILE"

# COUNTRY="CHINA"

# COUNTRY="CTR21EUROPE"

# COUNTRY="CYPRUS"

# COUNTRY="CZECH_REPUBLIC/SLOVAKIA"

# COUNTRY="DENMARK"

# COUNTRY="EGYPT"

# COUNTRY="ESTONIA"

# COUNTRY="FINLAND"

# COUNTRY="FRANCE"

# COUNTRY="GERMANY"

# COUNTRY="GREECE"

# COUNTRY="HONG_KONG"

# COUNTRY="HUNGARY"

# COUNTRY="ICELAND"

# COUNTRY="INDIA"

# COUNTRY="INDONESIA"

# COUNTRY="IRELAND"

# COUNTRY="ISRAEL"

# COUNTRY="ITALY"

# COUNTRY="JAPAN"

# COUNTRY="JORDAN"

# COUNTRY="KOREA"

# COUNTRY="KUWAIT"

# COUNTRY="LATVIA"

# COUNTRY="LEBANON"

# COUNTRY="LITHUANIA"

# COUNTRY="LUXEMBOURG"

# COUNTRY="MALAYSIA"

# COUNTRY="MALTA"

# COUNTRY="MEXICO"

# COUNTRY="MOROCCO"

# COUNTRY="NETHERLANDS"

# COUNTRY="NEW_ZEALAND"

# COUNTRY="NORWAY"

# COUNTRY="OMAN"

# COUNTRY="PAKISTAN"

# COUNTRY="PERU"

# COUNTRY="PHILIPPINES"

# COUNTRY="POLAND"

# COUNTRY="PORTUGAL"

# COUNTRY="ROMANIA"

# COUNTRY="RUSSIA"

# COUNTRY="SAUDIARABIA"

# COUNTRY="SINGAPORE"

# COUNTRY="SLOVAKIA"

# COUNTRY="SLOVENIA"

# COUNTRY="SOUTHAFRICA"

# COUNTRY="SOUTHKOREA"

# COUNTRY="SPAIN"

# COUNTRY="SRILANKA"

# COUNTRY="SWEDEN"

# COUNTRY="SWITZERLAND"

# COUNTRY="TAIWAN"

# COUNTRY="THAILAND"

# COUNTRY="TUNISIA"

# COUNTRY="TURKEY"

# COUNTRY="UAE"

# COUNTRY="UK"

# COUNTRY="URUGUAY"

# COUNTRY="USA"

# COUNTRY="VIETNAM"

 

#

# Use slmodemd in ALSA mode. If it is set to "yes",

# then DEVICE must be set to "hw:x", where x is the number of your card

# as mentioned in `dmesg`.

# Default "no" is used if the value is not set here.

#

# ALSA="no"

 

#

# Character device node to use slmodemd with.

# Default /dev/slamr0 is used if none is set.

#

# DEVICE="/dev/slamr0"

```

Then I add this to the deafault runlevel, and make sure that slamr is loaded at boot. This makes my life MUCH easier. 

I also use wvdial to establish PPP connection(net.ppp0 just does not do it for me). I know that typing `wvdial` is really easy, but wvdial has a nasty habbit of not going into the background. Also, I thought that it would be nice to have wvdial start up at boot. So here is short wvdial init script  :Very Happy: 

/etc/init.d/net.wvdial :

```

#!/sbin/runscript

#/etc/init.d/net.wvdial

 

opts="start stop"

 

depend() {

    need slmodemd

}

 

start() {

    ebegin "Starting wvdial"

    start-stop-daemon --start --quiet --background --exec /usr/bin/wvdial \

      -- "$OPTIONS"

    eend $?

}

 

stop() {

    ebegin "Stopping wvdial"

    start-stop-daemon --stop --quiet --exec /usr/bin/wvdial

    eend $?

}

```

This script can be configured with /etc/conf.d/net.wvdial :

```

#/etc/conf.d/net.wvdial

# 

# Options to pass to wvdial.

# Default is no options.

#

# OPTIONS="phone2"

```

I hope this comes in handy to someone.

Have fun with it!  :Wink: 

-------------------------

PS: Some people (including me) had issues with slmodem driver. With the new version of it out (2.9.7), all my glitches are gone. Download it  at ftp://ftp.smlink.com/linux/unsupported/.

----------

## federico

Thanks for this, I found it very useful !

----------

## Mr.Evolution

Thank you very much! My english isn't very good but I hope you understand me becose you save me and my laptop modem....

----------

## Rukicc

Hi, 

Something is missing ....

```
chmod 755 net.wvdial

rc-update add net.wvdial default
```

Without 

```
chmod 755
```

 you get 

```
 net.wvdial not executable; skipping
```

----------

