Группа :: Система/Серверы
Пакет: miredo
Главная Изменения Спек Патчи Исходники Загрузить Gear Bugs and FR Repocop
#! /bin/sh
# miredo Teredo IPv6 tunneling through NATs
#
# chkconfig: - 46 69
# description: Miredo daemon for tunneling of IPv6 through NAT \
# within UDP/IPv4, as specified by the Teredo mechanism.
# processname: miredo
# config: /etc/miredo/miredo.conf
# pidfile: /var/run/miredo.pid
#
### BEGIN INIT INFO
# Provides: miredo
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $syslog
# Should-Start: $time $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Teredo IPv6 tunnel
# Description: Miredo daemon for tunneling of IPv6 through NAT
# within UDP/IPv4, as specified by the Teredo mechanism.
### END INIT INFO
PATH=/usr/sbin:/usr/bin:/sbin:/bin
NAME=miredo
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS=""
DAEMON_USER="_miredo"
PIDFILE=/var/run/$NAME.pid
LOCKFILE=/var/lock/subsys/$NAME
CHECKCONF="${DAEMON}-checkconf"
[ -x "$DAEMON" ] || exit 0
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
# Source defaults.
SourceIfExists /etc/sysconfig/$NAME
# Ensure configuration is readable.
[ -r /etc/miredo/$NAME.conf ] || exit 0
check_start() {
if [ "x$START_MIREDO" != "xtrue" ]; then
echo "START_MIREDO is set to false in /etc/sysconfig/$NAME."
echo "$DAEMON not starting."
exit 0
fi
if [ `uname -s` = Linux ]; then
if [ -e /proc/sys/kernel/modprobe ]; then
`cat /proc/sys/kernel/modprobe` tun 2>/dev/null
`cat /proc/sys/kernel/modprobe` ipv6 2>/dev/null
fi
sleep 1s
if [ ! -e /dev/net/tun ]; then
echo "/dev/net/tun does not exist."
echo "$DAEMON cannot be started."
exit 0
fi
elif [ `uname -s` = GNU/kFreeBSD ]; then
if ! kldstat | grep if_tun; then
kldload if_tun
fi
fi
}
check_conf_file() {
if ! "$CHECKCONF" $DAEMON_ARGS; then
echo "Cannot reload miredo: fix /etc/miredo/$NAME.conf first."
exit 1
fi
}
start()
{
check_start
start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" \
--expect-user "$DAEMON_USER" -- "$DAEMON" $DAEMON_ARGS
RETVAL=$?
return $RETVAL
}
stop()
{
stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- "$DAEMON"
RETVAL=$?
return $RETVAL
}
restart()
{
check_start # avoid stopping if would not restart
check_conf_file
stop
sleep 1s
start
}
reload()
{
msg_reloading miredo
stop_daemon --pidfile "$PIDFILE" --expect-user "$DAEMON_USER" -HUP -- "$DAEMON"
RETVAL=$?
return $RETVAL
}
# See how we were called.
case "$1" in
start|force-start)
[ "x$1" = "xforce-start" ] && START_MIREDO=true
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" -- "$DAEMON"
RETVAL=$?
;;
*)
msg_usage "${0##*/} {start|force-start|stop|reload|restart|condstop|condrestart|condreload|status}"
RETVAL=1
esac
exit $RETVAL