Wiki - Freifunk Pinneberg

Freies WLAN im Kreis Pinneberg

Benutzer-Werkzeuge

Webseiten-Werkzeuge


fastd

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
Letzte ÜberarbeitungBeide Seiten der Revision
fastd [20.01.2016 16:39] havelockfastd [21.11.2016 18:16] havelock
Zeile 1: Zeile 1:
 ====== fastd ====== ====== fastd ======
  
-In Bearbeitung!+TODO In Bearbeitung!
  
-Dokumentation: http://fastd.readthedocs.org/en/v17/. +Dokumentation: http://fastd.readthedocs.org/en/v18/. 
  
 Bei der manuellen Übersetzung von fastd müssen das Init-Script und die manpages Bei der manuellen Übersetzung von fastd müssen das Init-Script und die manpages
Zeile 9: Zeile 9:
  
 Vorarbeiten  Vorarbeiten 
- 
-  aptitude install build-essential pkg-config cmake doxygen 
- 
-Voraussetzung ist ''libuecc'', dieses muß vorab gebaut und installiert werden. 
- 
-Zertifikatswarnung für folgenden Download ignorieren: --no-check-certificate 
 <code> <code>
-cd /usr/src +aptitude install build-essential pkg-config cmake doxygen bison libsodium-dev libjson-c-dev libcap-dev
-wget --no-check-certificate https://projects.universe-factory.net/attachments/download/83/libuecc-6.tar.xz +
-tar xJf libuecc-6.tar.xz +
-cd libuecc-6 +
-cmake . +
-make +
-make install +
-ldconfig+
 </code> </code>
  
-Compilieren von fastd +Voraussetzung ist [[libuecc]], dieses muß vorab gebaut und installiert werden.
-  aptitude install bison doxygen libsodium-dev libjson-c-dev libcap-dev+
  
 +Compilieren von fastd
 <code> <code>
 +cd /usr/local/src
 git clone git://git.universe-factory.net/fastd git clone git://git.universe-factory.net/fastd
 cd fastd cd fastd
-git checkout v17+git checkout v18
 cd .. cd ..
 mkdir fastd-build mkdir fastd-build
Zeile 51: Zeile 39:
 AUTOSTART="all" AUTOSTART="all"
 </file> </file>
 +
 +Hinweis: Wenn fastd selbst kompiliert wurde, ist die Installation normalerweise
 +nach ''/usr/local'' erfolgt. Das folgende Init-Script muß dann entsprechend 
 +angepaßt werden (''DAEMON=/usr/local/bin/$NAME'').
 +
 +Hinweis: Das Script ist auch Bestandteil der [[FFPI-Tools]].
  
 ++++ Init-Script für fastd | ++++ Init-Script für fastd |
-<file sh /etc/init.d/fastd>+<file bash /etc/init.d/fastd>
 #!/bin/sh -e #!/bin/sh -e
  
Zeile 65: Zeile 59:
 # Default-Stop:      0 1 6 # Default-Stop:      0 1 6
 # Short-Description: Fast and Secure Tunneling Daemon # Short-Description: Fast and Secure Tunneling Daemon
-# Description: This script will start fastd tunnels as specified +# Description:       This script will start fastd tunnels as specified 
-             in /etc/default/fastd and /etc/fastd/*/fastd.conf+                   in /etc/default/fastd and /etc/fastd/*/fastd.conf
 ### END INIT INFO ### END INIT INFO
  
Zeile 75: Zeile 69:
 # Modified for restarting / starting / stopping single tunnels by Richard Mueller <mueller@teamix.net> # Modified for restarting / starting / stopping single tunnels by Richard Mueller <mueller@teamix.net>
 # Modified for fastd by Nils Schneider <nils@nilsschneider.net> # Modified for fastd by Nils Schneider <nils@nilsschneider.net>
 +# Beautified by Thomas Hooge <pirat@hoogi.de>
  
 . /lib/lsb/init-functions . /lib/lsb/init-functions
Zeile 80: Zeile 75:
 test $DEBIAN_SCRIPT_DEBUG && set -v -x test $DEBIAN_SCRIPT_DEBUG && set -v -x
  
-DAEMON=/usr/bin/fastd 
 DESC="Fast and Secure Tunneling Daemon" DESC="Fast and Secure Tunneling Daemon"
 +NAME=fastd
 +DAEMON=/usr/bin/$NAME
 CONFIG_DIR=/etc/fastd CONFIG_DIR=/etc/fastd
-test -x $DAEMON || exit 0 +SCRIPTNAME=/etc/init.d/$NAME 
-test -d $CONFIG_DIR || exit 0+ 
 +# Exit if the package is not installed 
 +-x "$DAEMON" ] || exit 0 
 + 
 +# Exit if the configuration directory is not existent 
 +-d $CONFIG_DIR || exit 0
  
 # Source defaults file; edit that file to configure this script. # Source defaults file; edit that file to configure this script.
 AUTOSTART="all" AUTOSTART="all"
-if test -e /etc/default/fastd ; then +if test -e /etc/default/$NAME ; then 
-  . /etc/default/fastd+ . /etc/default/$NAME 
 +fi 
 + 
 +if [ ! -d /var/run/fastd ]; then 
 + mkdir /var/run/fastd/ 
 + chown fastd. /var/run/fastd
 fi fi
  
 start_vpn () { start_vpn () {
-    STATUS=0 + STATUS=0   
-    start-stop-daemon --start --quiet --oknodo \ + start-stop-daemon --start --quiet --oknodo \ 
-        --pidfile /var/run/fastd/$NAME.pid \ + --pidfile /var/run/fastd/$INSTANCE.pid \ 
- --make-pidfile \ + --make-pidfile \ 
- --background \ + --background \ 
-        --exec $DAEMON -- \ + --exec $DAEMON -- \ 
-          --syslog-level info \ + --syslog-level info \ 
-          --config $CONFIG_DIR/$NAME/fastd.conf \ + --config $CONFIG_DIR/$INSTANCE/fastd.conf \ 
-        || STATUS=1+ || STATUS=1
 } }
  
 stop_vpn () { stop_vpn () {
-  kill `cat $PIDFILE` || true + kill `cat $PIDFILE` || true 
-  rm -f $PIDFILE + rm -f $PIDFILE 
-  log_end_msg 0+ log_end_msg 0 
 } }
  
-case "$1" in +case "$1" in  
-start) +  start)   
-  log_action_begin_msg "Starting $DESC"+ log_action_begin_msg "Starting $DESC"
  
-  # autostart fastds + # autostart fastds 
-  if test -z "$2" ; then + if test -z "$2" ; then 
-    # check if automatic startup is disabled by AUTOSTART=none + # check if automatic startup is disabled by AUTOSTART=none 
-    if test "x$AUTOSTART" = "xnone" -o -z "$AUTOSTART" ; then + if test "x$AUTOSTART" = "xnone" -o -z "$AUTOSTART" ; then 
-      log_warning_msg "  Autostart disabled, no fastd will be started." + log_warning_msg "  Autostart disabled, no $NAME will be started." 
-      exit 0 + exit 0 
-    fi + fi 
-    if test -z "$AUTOSTART" -o "x$AUTOSTART" = "xall" ; then + if test -z "$AUTOSTART" -o "x$AUTOSTART" = "xall" ; then 
-      # all fastds shall be started automatically + # all fastds shall be started automatically 
-      for CONFIG in `cd $CONFIG_DIR; ls */fastd.conf 2> /dev/null`; do + for CONFIG in `cd $CONFIG_DIR; ls */fastd.conf 2> /dev/null`; do 
-        NAME=${CONFIG%%/fastd.conf} + INSTANCE=${CONFIG%%/fastd.conf} 
-        log_daemon_msg "  Autostarting fastd '$NAME'" + log_daemon_msg "  Autostarting $NAME '$INSTANCE'" 
-        start_vpn + start_vpn 
-      done + done 
-    else + else 
-      # start only specified fastds + # start only specified fastds 
-      for NAME in $AUTOSTART ; do + for INSTANCE in $AUTOSTART ; do 
-        if test -e $CONFIG_DIR/$NAME/fastd.conf ; then + if test -e $CONFIG_DIR/$INSTANCE/fastd.conf ; then  
-          log_daemon_msg "  Autostarting fastd '$NAME'" + log_daemon_msg "  Autostarting $NAME '$INSTANCE'" 
-          start_vpn + start_vpn 
-        else + else 
-          log_failure_msg "  Autostarting fastd '$NAME': missing $CONFIG_DIR/$NAME/fastd.conf file !" + log_failure_msg "  Autostarting $NAME '$INSTANCE': missing $CONFIG_DIR/$INSTANCE/fastd.conf file!" 
-          STATUS=1 + STATUS=1 
-        fi + fi 
-      done + done 
-    fi + fi 
-  #start fastds from command line + #start fastds from command line 
-  else + else 
-    while shift ; do + while shift ; do 
-      [ -z "$1" ] && break + [ -z "$1" ] && break 
-      NAME=$1 + INSTANCE=$1 
-      if test -e $CONFIG_DIR/$NAME/fastd.conf ; then + if test -e $CONFIG_DIR/$INSTANCE/fastd.conf ; then 
-        log_daemon_msg "  Starting fastd '$NAME'" + log_daemon_msg "  Starting $NAME '$INSTANCE'"    
-        start_vpn + start_vpn 
-      else + else 
-        log_failure_msg "  Starting fastd '$NAME': missing $CONFIG_DIR/$NAME/fastd.conf file !" + log_failure_msg "  Starting $NAME '$INSTANCE': missing $CONFIG_DIR/$INSTANCE/fastd.conf file!" 
-       STATUS=1 + STATUS=1 
-      fi + fi 
-    done + done 
-  fi + fi 
-  log_end_msg ${STATUS:-0} + log_end_msg ${STATUS:-0} 
-  ;; + ;; 
-stop) +  stop) 
-  log_action_begin_msg "Stopping $DESC" + log_action_begin_msg "Stopping $DESC" 
-  if test -z "$2" ; then + if test -z "$2" ; then 
-    PIDFILE= + PIDFILE= 
-    for PIDFILE in `ls /var/run/fastd/*.pid 2> /dev/null`; do + for PIDFILE in `ls /var/run/fastd/*.pid 2> /dev/null`; do 
-      NAME=`echo $PIDFILE | cut -c16-` + INSTANCE=`echo $PIDFILE | cut -c16-` 
-      NAME=${NAME%%.pid} + INSTANCE=${INSTANCE%%.pid} 
-      log_daemon_msg "  Stopping fastd '$NAME'" + log_daemon_msg "  Stopping $NAME '$INSTANCE'" 
-      stop_vpn + stop_vpn 
-    done + done 
-    if test -z "$PIDFILE" ; then + if test -z "$PIDFILE" ; then 
-      log_warning_msg "  No fastd is running." + log_warning_msg "  No $NAME is running." 
-    fi + fi 
-  else + else 
-    while shift ; do + while shift ; do 
-      [ -z "$1" ] && break + [ -z "$1" ] && break 
-      if test -e /var/run/fastd/$1.pid ; then + if test -e /var/run/fastd/$1.pid ; then 
-        log_daemon_msg "  Stopping fastd '$1'" + log_daemon_msg "  Stopping $NAME '$1'" 
-        PIDFILE=`ls /var/run/fastd/$1.pid 2> /dev/null` + PIDFILE=`ls /var/run/fastd/$1.pid 2> /dev/null` 
-        NAME=`echo $PIDFILE | cut -c16-` + INSTANCE=`echo $PIDFILE | cut -c16-` 
-        NAME=${NAME%%.pid} + INSTANCE=${INSTANCE%%.pid} 
-        stop_vpn + stop_vpn 
-      else + else 
-        log_failure_msg "  Stopping fastd '$1': No such fastd is running." + log_failure_msg "  Stopping $NAME '$1': No such $NAME is running." 
-      fi + fi 
-    done + done 
-  fi + fi 
-  ;; + ;; 
-restart) +  restart) 
-  shift + shift  
-  $0 stop ${@} + $0 stop ${@} 
-  sleep 1 + sleep 1 
-  $0 start ${@} + $0 start ${@} 
-  ;; + ;; 
-status) +  status) 
-  GLOBAL_STATUS=0 + GLOBAL_STATUS=0 
-  if test -z "$2" ; then + if test -z "$2" ; then 
-    # We want status for all defined fastd. + # We want status for all defined fastd. 
-    # Returns success if all autostarted fastds are defined and running + # Returns success if all autostarted fastds are defined and running 
-    if test "x$AUTOSTART" = "xnone" ; then + if test "x$AUTOSTART" = "xnone" ; then 
-      # Consider it a failure if AUTOSTART=none + # Consider it a failure if AUTOSTART=none 
-      log_warning_msg "No fastds autostarted" + log_warning_msg "No fastds autostarted" 
-      GLOBAL_STATUS=1 + GLOBAL_STATUS=1 
-    else + else 
-      if ! test -z "$AUTOSTART" -o "x$AUTOSTART" = "xall" ; then + if ! test -z "$AUTOSTART" -o "x$AUTOSTART" = "xall" ; then 
-        # Consider it a failure if one of the autostarted fastd is not defined + # Consider it a failure if one of the autostarted fastd is not defined 
-        for VPN in $AUTOSTART ; do + for VPN in $AUTOSTART ; do 
-          if ! test -f $CONFIG_DIR/$VPN/fastd.conf ; then + if ! test -f $CONFIG_DIR/$VPN/fastd.conf ; then 
-            log_warning_msg "fastd '$VPN' is in AUTOSTART but is not defined" + log_warning_msg "fastd '$VPN' is in AUTOSTART but is not defined" 
-            GLOBAL_STATUS=1 + GLOBAL_STATUS=1 
-          fi + fi 
-        done + done 
-      fi + fi 
-    fi + fi 
-    for CONFIG in `cd $CONFIG_DIR; ls */fastd.conf 2> /dev/null`; do + for CONFIG in `cd $CONFIG_DIR; ls */fastd.conf 2> /dev/null`; do 
-      NAME=${CONFIG%%/fastd.conf} + INSTANCE=${CONFIG%%/fastd.conf} 
-      # Is it an autostarted fastd? + # Is it an autostarted fastd? 
-      if test -z "$AUTOSTART" -o "x$AUTOSTART" = "xall" ; then + if test -z "$AUTOSTART" -o "x$AUTOSTART" = "xall" ; then 
-        AUTOVPN=1 + AUTOVPN=1 
-      else + else 
-        if test "x$AUTOSTART" = "xnone" ; then + if test "x$AUTOSTART" = "xnone" ; then 
-          AUTOVPN=0 + AUTOVPN=0 
-        else + else 
-          AUTOVPN=0 + AUTOVPN=0 
-          for VPN in $AUTOSTART; do + for VPN in $AUTOSTART; do 
-            if test "x$VPN" = "x$NAME" ; then + if test "x$VPN" = "x$NAME" ; then 
-              AUTOVPN=1 + AUTOVPN=1 
-            fi + fi 
-          done + done 
-        fi + fi 
-      fi + fi   
-      if test "x$AUTOVPN" = "x1" ; then + if test "x$AUTOVPN" = "x1" ; then 
-        # If it is autostarted, then it contributes to global status + # If it is autostarted, then it contributes to global status 
-        status_of_proc -p /var/run/fastd/${NAME}.pid fastd "fastd '${NAME}'" || GLOBAL_STATUS=1 + status_of_proc -p /var/run/fastd/${INSTANCE}.pid $NAME "$NAME '${INSTANCE}'" || GLOBAL_STATUS=1 
-      else + else 
-        status_of_proc -p /var/run/fastd/${NAME}.pid fastd "fastd '${NAME}' (non autostarted)" || true + status_of_proc -p /var/run/fastd/${INSTANCE}.pid $NAME "$NAME '${INSTANCE}' (non autostarted)" || true 
-      fi + fi 
-    done + done 
-  else + else 
-    # We just want status for specified fastd. + # We just want status for specified fastd. 
-    # Returns success if all specified fastds are defined and running + # Returns success if all specified fastds are defined and running 
-    while shift ; do + while shift ; do 
-      [ -z "$1" ] && break + [ -z "$1" ] && break 
-      NAME=$1 + INSTANCE=$1 
-      if test -e $CONFIG_DIR/$NAME.conf ; then + if test -e $CONFIG_DIR/$INSTANCE/fastd.conf ; then 
-        # Config exists + # Config exists 
-        status_of_proc -p /var/run/fastd/${NAME}.pid fastd "fastd '${NAME}'" || GLOBAL_STATUS=1 + status_of_proc -p /var/run/fastd/${INSTANCE}.pid $NAME "$NAME '${INSTANCE}'" || GLOBAL_STATUS=1 
-      else + else 
-        # Config does not exist + # Config does not exist 
-        log_warning_msg "fastd '$NAME': missing $CONFIG_DIR/$NAME.conf file !" + log_warning_msg "$NAME '$INSTANCE': missing $CONFIG_DIR/$INSTANCE/fastd.conf file!" 
-        GLOBAL_STATUS=1 + GLOBAL_STATUS=1 
-      fi + fi 
-    done + done 
-  fi + fi 
-  exit $GLOBAL_STATUS + exit $GLOBAL_STATUS 
-  ;; + ;; 
-*) +  *) 
-  echo "Usage: ${start|stop|reload|restart|force-reload|cond-restart|soft-restart|status}" >&+ echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&
-  exit 1 + exit 1 
-  ;;+ ;;
 esac esac
  
 exit 0 exit 0
- 
-# vim:set ai sts=2 sw=2 tw=0: 
  
 </file> </file>
 ++++ ++++
fastd.txt · Zuletzt geändert: 16.07.2017 19:32 von havelock