Repository 32bit  Forum
Repository 64bit  Wiki

Gnubox su slackware/rc.blue: differenze tra le versioni

Da Slacky.eu.
 
 
(Una revisione intermedia di un utente non mostrate)
Riga 1: Riga 1:
Script in rifacimento appena finito sara' disponibile nella sua nuova versione
+
Copiate il seguente file di testo rinomimandolo rc.blue quindi potete inserirlo nel rc.local per farlo partire al boot, lo script inoltre può rivelarsi utile per far partire i demoni che gestiscono il bluetooth
  +
<pre>#!/bin/sh
  +
# Versione 0.1.2
  +
# Scritto da l1q1d
  +
# l1q1d[at]yahoo[dot]it
[[Utente:L1q1d|L1q1d]] 09:29, 20 Nov 2006 (CET)
+
LOGFILE=/var/log/blue-log
  +
  +
## Variabili di sistema
  +
## da personalizzare a seconda delle esigenze
  +
  +
IPTABLES=/usr/sbin/iptables
  +
DEPMOD=/sbin/depmod
  +
MODPROBE=/sbin/modprobe
  +
DUND=/usr/bin/dund
  +
HCID=/usr/sbin/hcid
  +
SDPD=/usr/sbin/sdpd
  +
SU=/bin/su
  +
  +
IP=10.0.0.1
  +
IPBLUE=10.0.0.2
  +
SER=29.253.128.10
  +
CHANNEL=3
  +
SPEED=460800
  +
#SPEED=115200
  +
  +
# Attiva servizi
  +
upserv () {
  +
prog=`basename $1`
  +
lock=(`ps --no-headers -C $prog`)
  +
if ! [ $lock ]
  +
then
  +
$SU root -c "$1 2>>$LOGFILE"
  +
fi
  +
}
  +
  +
  +
blue_services (){
  +
  +
$DEPMOD -a
  +
if `uname -r | grep 2.4 > /dev/null`
  +
then
  +
$MODPROBE bluez
  +
else
  +
$MODPROBE bluetooth
  +
fi
  +
$MODPROBE rfcomm
  +
$MODPROBE l2cap
  +
$MODPROBE hci_usb
  +
  +
# Controllo servizi attivi
  +
upserv $HCID
  +
upserv $SDPD
  +
  +
}
  +
  +
  +
start(){
  +
  +
blue_services
  +
  +
# Moduli per il masquering
  +
  +
$MODPROBE ip_tables
  +
$MODPROBE ip_conntrack
  +
$MODPROBE ip_conntrack_ftp
  +
$MODPROBE ip_conntrack_irc
  +
$MODPROBE iptable_nat
  +
$MODPROBE ip_nat_ftp
  +
  +
# Attivazione dei servizi di gateway
  +
  +
echo "1" > /proc/sys/net/ipv4/ip_forward
  +
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
  +
  +
$IPTABLES -t nat -A POSTROUTING -d ! 10.0.0.0/24 -j MASQUERADE
  +
$IPTABLES -A FORWARD -s 10.0.0.0/24 -j ACCEPT
  +
$IPTABLES -A FORWARD -d 10.0.0.0/24 -j ACCEPT
  +
$IPTABLES -A FORWARD -j DROP
  +
  +
#In attesa di connessione
  +
$SU root -c "$DUND --listen --channel $CHANNEL --msdun noauth $IP:$IPBLUE \
  +
crtscts $SPEED ms-dns $SER lock 2>>$LOGFILE" &
  +
}
  +
  +
stop(){
  +
ps ax > /tmp/blue-pid.$$
  +
pp=(`cat /tmp/blue-pid.$$ | grep pppd | grep rfcomm`)
  +
if [ ${pp[0]} ]
  +
then
  +
kill ${pp[0]}
  +
if [ $? ]
  +
then
  +
echo "pppd killed"
  +
else
  +
echo "Error pppd not killed"
  +
fi
  +
else
  +
echo "Pppd-dund not running"
  +
fi
  +
dun=(`cat /tmp/blue-pid.$$ | grep dund`)
  +
if [ ${dun[0]} ]
  +
then
  +
kill ${dun[0]}
  +
if [ $? ]
  +
then
  +
echo "Dund killed"
  +
else
  +
echo "Error dund not killed"
  +
fi
  +
else
  +
echo "Dund not running"
  +
fi
  +
rm -f /tmp/blue-pid.$$
  +
}
  +
  +
restart(){
  +
stop dund
  +
start
  +
}
  +
  +
## main
  +
  +
case $1 in
  +
start) ps ax > /tmp/blue-pid.$$
  +
dun=(`cat /tmp/blue-pid.$$ | grep dund`)
  +
if ! [ ${dun[0]} ]
  +
then
  +
start
  +
else
  +
echo "Non dund alredy running"
  +
fi
  +
rm -f /tmp/blue-pid.$$;;
  +
stop) stop;;
  +
restart) restart;;
  +
service) blue_services;;
  +
*) echo "Uso: start|stop|restart|service";;
  +
esac
  +
</pre>

Versione attuale delle 09:50, 9 dic 2006

Copiate il seguente file di testo rinomimandolo rc.blue quindi potete inserirlo nel rc.local per farlo partire al boot, lo script inoltre può rivelarsi utile per far partire i demoni che gestiscono il bluetooth

#!/bin/sh
# Versione 0.1.2
# Scritto da l1q1d
# l1q1d[at]yahoo[dot]it

LOGFILE=/var/log/blue-log

## Variabili di sistema
## da personalizzare a seconda delle esigenze

IPTABLES=/usr/sbin/iptables
DEPMOD=/sbin/depmod
MODPROBE=/sbin/modprobe
DUND=/usr/bin/dund
HCID=/usr/sbin/hcid
SDPD=/usr/sbin/sdpd
SU=/bin/su

IP=10.0.0.1
IPBLUE=10.0.0.2
SER=29.253.128.10
CHANNEL=3
SPEED=460800
#SPEED=115200

# Attiva servizi
upserv () {
prog=`basename $1`
lock=(`ps --no-headers -C $prog`)
if ! [ $lock ]
then
        $SU root -c "$1 2>>$LOGFILE"
fi
}


blue_services (){

$DEPMOD -a
if `uname -r | grep 2.4 > /dev/null`
  then
        $MODPROBE bluez
  else
        $MODPROBE bluetooth
fi
$MODPROBE rfcomm
$MODPROBE l2cap
$MODPROBE hci_usb

# Controllo servizi attivi
upserv $HCID
upserv $SDPD

}


start(){

blue_services

# Moduli per il masquering

$MODPROBE ip_tables
$MODPROBE ip_conntrack
$MODPROBE ip_conntrack_ftp
$MODPROBE ip_conntrack_irc
$MODPROBE iptable_nat
$MODPROBE ip_nat_ftp

# Attivazione dei servizi di gateway

echo "1" > /proc/sys/net/ipv4/ip_forward
echo "1" > /proc/sys/net/ipv4/ip_dynaddr

$IPTABLES -t nat -A POSTROUTING -d ! 10.0.0.0/24 -j MASQUERADE
$IPTABLES -A FORWARD -s 10.0.0.0/24 -j ACCEPT
$IPTABLES -A FORWARD -d 10.0.0.0/24 -j ACCEPT
$IPTABLES -A FORWARD -j DROP

#In attesa di connessione
$SU root -c "$DUND --listen  --channel $CHANNEL --msdun noauth $IP:$IPBLUE \
crtscts $SPEED  ms-dns $SER lock 2>>$LOGFILE" &
}

stop(){
        ps ax > /tmp/blue-pid.$$
        pp=(`cat /tmp/blue-pid.$$ | grep pppd | grep rfcomm`)
        if [ ${pp[0]} ]
                then
                        kill ${pp[0]}
                        if [ $? ]
                                then
                                        echo "pppd killed"
                                else
                                        echo "Error pppd not killed"
                        fi
                else
                        echo "Pppd-dund not running"
        fi
        dun=(`cat /tmp/blue-pid.$$ | grep dund`)
        if [ ${dun[0]} ]
                        then
                        kill ${dun[0]}
                        if [ $? ]
                                then
                                        echo "Dund killed"
                                else
                                        echo "Error dund not killed"
                        fi
                        else
                        echo "Dund not running"
        fi
        rm -f /tmp/blue-pid.$$
}

restart(){
        stop dund
        start
}

## main

case $1 in
        start) ps ax > /tmp/blue-pid.$$
        dun=(`cat /tmp/blue-pid.$$ | grep dund`)
        if ! [ ${dun[0]} ]
                        then
                                start
                        else
                        echo "Non dund alredy running"
        fi
        rm -f /tmp/blue-pid.$$;;
        stop) stop;;
        restart) restart;;
        service) blue_services;;
        *) echo "Uso: start|stop|restart|service";;
esac
Strumenti personali
Namespace

Varianti