2
###############################################################################
4
# IPFire.org - A linux based firewall #
5
# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
7
# This program is free software: you can redistribute it and/or modify #
8
# it under the terms of the GNU General Public License as published by #
9
# the Free Software Foundation, either version 3 of the License, or #
10
# (at your option) any later version. #
12
# This program is distributed in the hope that it will be useful, #
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15
# GNU General Public License for more details. #
17
# You should have received a copy of the GNU General Public License #
18
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
20
###############################################################################
25
# Stop if nothing is configured
26
if [ ! -s "/var/ipfire/ppp/settings" ];then
30
eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings)
35
if [ ! $HOLDOFF ]; then
39
if [ "$RECONNECTION" = "dialondemand" ]; then
44
logger -t $(basename $0)[$$] $*
47
msg_log "Connectd ($1) started with PID $$"
50
if [ -s "/var/ipfire/red/keepconnected" ]; then
51
ATTEMPTS=$(cat /var/ipfire/red/keepconnected)
53
echo "0" > /var/ipfire/red/keepconnected
58
boot_mesg "Starting connection daemon..."
61
while [ "$COUNT" -lt "$MAX" ]; do
62
if [ ! -e "/var/ipfire/red/keepconnected" ]; then
63
# User pressed disconnect in gui
64
msg_log "Stopping by user request. Exiting."
65
/etc/rc.d/init.d/network stop red
68
if [ -e "/var/ipfire/red/active" ]; then
69
# Successfully connected in time
70
echo "0" > /var/ipfire/red/keepconnected
71
msg_log "System is online. Exiting."; exit 0
73
if ( ! ps ax | grep -q [p]ppd ); then
74
msg_log "No pppd is running. Trying reconnect."
75
break # because pppd died
81
/etc/rc.d/init.d/network stop red
84
msg_log "Reconnecting: Attempt ${ATTEMPTS} of ${MAXRETRIES}"
85
if [ "${ATTEMPTS}" -ge "${MAXRETRIES}" ]; then
86
echo "0" > /var/ipfire/red/keepconnected
87
if [ "$BACKUPPROFILE" != '' ]; then
88
rm -f /var/ipfire/ppp/settings
89
cp "/var/ipfire/ppp/settings-${BACKUPPROFILE}" /var/ipfire/ppp/settings
90
msg_log "Switched to backup profile ${BACKUPPROFILE}"
91
# to be shure the right secrets are used
92
eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings-${BACKUPPROFILE})
93
echo "'$USERNAME' * '$PASSWORD'" > /var/ipfire/ppp/secrets
95
msg_log "No backup profile given. Exiting."
99
echo $ATTEMPTS > /var/ipfire/red/keepconnected
102
/etc/rc.d/init.d/network start red >/dev/tty12 2>&1 </dev/tty12 &
106
while ( ps ax | grep -q [p]ppd ); do
107
msg_log "There is a pppd still running. Waiting 2 seconds for exit."
111
/etc/rc.d/init.d/network restart red
115
echo "Usage: $0 {start|reconnect}"
120
msg_log "Exiting gracefully connectd with PID $$."