converted to UNIX format

This commit is contained in:
Maniacikarus
2008-08-26 21:03:26 +02:00
parent 32e19e9c9c
commit 9332dfe1c2

View File

@@ -1,103 +1,103 @@
#!/bin/bash #!/bin/bash
# #
. /etc/sysconfig/rc . /etc/sysconfig/rc
. ${rc_functions} . ${rc_functions}
# Stop if nothing is configured # Stop if nothing is configured
if [ ! -s "/var/ipfire/ppp/settings" ];then if [ ! -s "/var/ipfire/ppp/settings" ];then
exit 0 exit 0
fi fi
eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings) eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings)
MAX=160 MAX=160
ATTEMPTS=0 ATTEMPTS=0
COUNT=0 COUNT=0
if [ ! $HOLDOFF ]; then if [ ! $HOLDOFF ]; then
HOLDOFF=30 HOLDOFF=30
fi fi
if [ "$RECONNECTION" = "dialondemand" ]; then if [ "$RECONNECTION" = "dialondemand" ]; then
exit 0 exit 0
fi fi
msg_log () { msg_log () {
logger -t $(basename $0)[$$] $* logger -t $(basename $0)[$$] $*
} }
msg_log "Connectd ($1) started with PID $$" msg_log "Connectd ($1) started with PID $$"
if [ -s "/var/ipfire/red/keepconnected" ]; then if [ -s "/var/ipfire/red/keepconnected" ]; then
ATTEMPTS=$(cat /var/ipfire/red/keepconnected) ATTEMPTS=$(cat /var/ipfire/red/keepconnected)
else else
echo "0" > /var/ipfire/red/keepconnected echo "0" > /var/ipfire/red/keepconnected
fi fi
case "$1" in case "$1" in
start) start)
boot_mesg "Starting connection daemon..." boot_mesg "Starting connection daemon..."
echo_ok echo_ok
while [ "$COUNT" -lt "$MAX" ]; do while [ "$COUNT" -lt "$MAX" ]; do
if [ ! -e "/var/ipfire/red/keepconnected" ]; then if [ ! -e "/var/ipfire/red/keepconnected" ]; then
# User pressed disconnect in gui # User pressed disconnect in gui
msg_log "Stopping by user request. Exiting." msg_log "Stopping by user request. Exiting."
/etc/rc.d/init.d/network stop red /etc/rc.d/init.d/network stop red
exit 0 exit 0
fi fi
if [ -e "/var/ipfire/red/active" ]; then if [ -e "/var/ipfire/red/active" ]; then
# Successfully connected in time # Successfully connected in time
echo "0" > /var/ipfire/red/keepconnected echo "0" > /var/ipfire/red/keepconnected
msg_log "System is online. Exiting."; exit 0 msg_log "System is online. Exiting."; exit 0
fi fi
if ( ! ps ax | grep -q [p]ppd ); then if ( ! ps ax | grep -q [p]ppd ); then
msg_log "No pppd is running. Trying reconnect." msg_log "No pppd is running. Trying reconnect."
break # because pppd died break # because pppd died
fi fi
sleep 5 sleep 5
(( COUNT+=1 )) (( COUNT+=1 ))
done done
/etc/rc.d/init.d/network stop red /etc/rc.d/init.d/network stop red
(( ATTEMPTS+=1 )) (( ATTEMPTS+=1 ))
msg_log "Reconnecting: Attempt ${ATTEMPTS} of ${MAXRETRIES}" msg_log "Reconnecting: Attempt ${ATTEMPTS} of ${MAXRETRIES}"
if [ "${ATTEMPTS}" -ge "${MAXRETRIES}" ]; then if [ "${ATTEMPTS}" -ge "${MAXRETRIES}" ]; then
echo "0" > /var/ipfire/red/keepconnected echo "0" > /var/ipfire/red/keepconnected
if [ "$BACKUPPROFILE" != '' ]; then if [ "$BACKUPPROFILE" != '' ]; then
rm -f /var/ipfire/ppp/settings rm -f /var/ipfire/ppp/settings
cp "/var/ipfire/ppp/settings-${BACKUPPROFILE}" /var/ipfire/ppp/settings cp "/var/ipfire/ppp/settings-${BACKUPPROFILE}" /var/ipfire/ppp/settings
msg_log "Switched to backup profile ${BACKUPPROFILE}" msg_log "Switched to backup profile ${BACKUPPROFILE}"
# to be shure the right secrets are used # to be shure the right secrets are used
eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings-${BACKUPPROFILE}) eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings-${BACKUPPROFILE})
echo "'$USERNAME' * '$PASSWORD'" > /var/ipfire/ppp/secrets echo "'$USERNAME' * '$PASSWORD'" > /var/ipfire/ppp/secrets
else else
msg_log "No backup profile given. Exiting." msg_log "No backup profile given. Exiting."
exit 0 exit 0
fi fi
else else
echo $ATTEMPTS > /var/ipfire/red/keepconnected echo $ATTEMPTS > /var/ipfire/red/keepconnected
sleep ${HOLDOFF} sleep ${HOLDOFF}
fi fi
/etc/rc.d/init.d/network start red & /etc/rc.d/init.d/network start red &
;; ;;
reconnect) reconnect)
while ( ps ax | grep -q [p]ppd ); do while ( ps ax | grep -q [p]ppd ); do
msg_log "There is a pppd still running. Waiting 2 seconds for exit." msg_log "There is a pppd still running. Waiting 2 seconds for exit."
sleep 2 sleep 2
done done
/etc/rc.d/init.d/network restart red /etc/rc.d/init.d/network restart red
;; ;;
*) *)
echo "Usage: $0 {start|reconnect}" echo "Usage: $0 {start|reconnect}"
exit 1 exit 1
;; ;;
esac esac
msg_log "Exiting gracefully connectd with PID $$." msg_log "Exiting gracefully connectd with PID $$."