Results 1 to 14 of 14

Thread: BusyBox HTTPd WebServer per CronJob Watchdog überwachen

  1. #1
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    423

    BusyBox HTTPd WebServer per CronJob Watchdog überwachen

    Hi,

    ich möchte meinen BusyBox WebServer per Watchdog überwachen lassen, so das er immer läuft, falls er mal abstürzt. Das Ganze ist nur notwendig, wenn der busybox-httpd öfter abstürzt (was eigentlich gar nicht passieren sollte!!!).

    Die Optionen und Pfandangaben müsst ihr natürlich nach euren Bedürfnissen und Gegebenheisten anpassen, die hier benutzten Angaben sind NICHT allgemeingültig!

    Ich verwende die Oleg-Firmware Firmware Release: 1.9.2.7-9.
    Die letzte Oleg-Firmware für die WL-HDD müsste die 1.9.2.7-9.1.12 sein.

    Jetzt will ich mal das zusammentragen was dafür nötig ist (Bei Fehlern und Unvollständigkeiten bitte anmerken!).

    HowTo - BusyBox HTTPd WebServer per CronJob Watchdog überwachen

    1.) Cron-Paket Installieren + Cron Startskript erstellen, füllen + Rechte setzten
    Als erstes solltet ihr Punkt 8 "8. CRON" aus Wengis HowTo durchführen.

    Anmerkende Betrachtungen (Anfang):
    Vor der Installation von cron findet:
    PHP Code:
    [admin@WL-HDD /]$ find grep cron
    ./usr/bin/crontab
    ./usr/sbin/crond
    ./proc/7/fdNo such file or directory 
    Scheinbar hat in der letzten Oleg-Firmware der BusyBox schon einen cron mit an Bord. Kann das jemand bestätigen?
    Anmerkende Betrachtungen (Ende):


    Installation von cron starten:
    PHP Code:
    ipkg install cron 
    Ergebniss der Installation:
    PHP Code:
    [admin@WL-HDD /]$ ipkg install cron
    Installing cron 
    (4.1-7to /opt/...
    Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/cron_4.1-7_mipsel.ipk
    Configuring cron
    Remember that the system crontab file is 
    "/opt/etc/crontab".
    Successfully terminated
    Anmerkende Betrachtungen (Anfang):
    Nach der Installation von cron findet:
    PHP Code:
    [admin@WL-HDD /]$ find grep cron
    ./opt/etc/init.d/S10cron
    ./opt/etc/crontab
    ./opt/etc/cron.d
    ./opt/lib/ipkg/info/cron.prerm
    ./opt/lib/ipkg/info/cron.control
    ./opt/lib/ipkg/info/cron.conffiles
    ./opt/lib/ipkg/info/cron.postinst
    ./opt/lib/ipkg/info/cron.list
    ./
    opt/bin/crontab
    ./opt/sbin/cron
    ./opt/var/cron
    ./opt/var/cron/crontabs
    ./opt/var/run/cron.pid
    ./opt/man/man1/crontab.1
    ./opt/man/man5/crontab.5
    ./opt/man/man8/cron.8
    ./usr/bin/crontab
    ./usr/sbin/crond
    ./proc/7/fdNo such file or directory 
    PHP Code:
    [admin@WL-HDD /]$ cat /opt/etc/init.d/S10cron
    #!/bin/sh
    #
    # Startup script for cron
    #
    # Stop myself if running
    PIDFILE=/opt/var/run/cron.pid
    [ -${PIDFILE} ] && kill `cat ${PIDFILE}`
    /
    opt/sbin/cron 
    Nach der Installation von cron scheint dieses auch sofort gestartet zu sein, was ein ps zeigt:
    PHP Code:
    [admin@WL-HDD /]$ ps
      PID  Uid     VmSize Stat Command
    ...
      
    258 admin       380 S   /opt/sbin/cron 
    Anmerkende Betrachtungen (Ende):







    2.) Datei crontab bearbeiten
    (die Datei leigt unter /opt/etc/crontab und wurde automatisch bei der Installation von cron angelegt, nach der Installation sollte die Datei unbearbeitet so aussehen
    PHP Code:
    SHELL=/bin/sh
    PATH
    =/sbin:/bin:/usr/sbin:/usr/bin:/opt/sbin:/opt/bin
    MAILTO
    =""
    HOME=/
    # ---------- ---------- Default is Empty ---------- ---------- # 
    (alles was unter /opt/ liegt ist, müsste auf der HDD der WL-HDD oder der USB-HDD bei den Routern liegen)


    Inhalt von Datei: /opt/etc/crontab so wie ihr es abändern sollt:
    PHP Code:
    SHELL=/bin/sh
    PATH
    =/sbin:/bin:/usr/sbin:/usr/bin:/opt/sbin:/opt/bin
    MAILTO
    =""
    HOME=/
    # ---------- ---------- Default is Empty ---------- ---------- #
    * * * * * admin /tmp/local/sbin/startprocess 
    Wichtig ist das diese Zeile da drin steht:
    PHP Code:
    * * * * * admin /tmp/local/sbin/startprocess 

    3.) Rechte von Datei crontab prüfen / bearbeiten
    PHP Code:
    chmod +/opt/etc/crontab 

    4.) Datei startprocess anlegen und bearbeiten
    - Die Datei legt ihr unter /tmp/local/sbin/startprocess an.
    - Füllt Sie mit folgendem Inhalt:

    Inhalt von Datei: /tmp/local/sbin/startprocess
    PHP Code:
    #!/bin/sh
    #feel free to copy and/or modify 

    Processname=busybox_httpd
    if [ ! -"`pidof $Processname`" ] ; then  #when Processname is not in pid list (running)
        
    echo -n Starting$Processname
        date
        exec busybox_httpd 
    -p 81 -r WL-HDD -/tmp/harddisk/www-busybox-httpd
    fi 
    Diese Werte hier müsst ihr an Eure Gegebeneheiten eventeull noch anpassen.
    busybox_httpd -p 81 -r WL-HDD -h /tmp/harddisk/www-busybox-httpd
    -p 81 ... Port: 81
    -r WL-HDD ... Servername: WL-HDD
    -h /tmp/harddisk/www-busybox-httpd ... Pfad zum Webordern

    Wenn ihr wollt das bei einem eventeullen Neustart des BusyBox HTTPd Webservers ihr das später nachvollziehen könnt, dann könnt ihr folgende Zeile mit in den unter Zweig ein binden:
    PHP Code:
    logger -t MyWatchDog "Process started by my Watchdog: $processname
    Das ganze sollte dann mit der ergänzten Zeile so aussehen:
    PHP Code:
    #!/bin/sh
    #feel free to copy and/or modify 

    Processname=busybox_httpd
    if [ ! -"`pidof $Processname`" ] ; then  #when Processname is not in pid list (running)
        
    echo -n Starting$Processname
        date
        exec busybox_httpd 
    -p 81 -r WL-HDD -/tmp/harddisk/www-busybox-httpd
        logger 
    -t MyWatchDog "Process started by my Watchdog: $processname"
    fi 
    Wenn ich mich nicht irre müsste das Systemloggen aber auf alle Fälle irgendwo erst noch eingeschaltet werden. Oder?

    So damit das ganze auch wirklich gespeichert wird müsst ihr noch in der Konsole (Putty) folgenden Befehl ausführen. Euer Router startet dabei neu und die Daten werden dauerhaft in den Flash geschrieben.
    PHP Code:
    flashfs save && flashfs commit && flashfs enable && reboot 

    5.) Rechte von Datei startprocess prüfen / bearbeiten
    PHP Code:
    chmod +/tmp/local/sbin/startprocess 
    Gruß WLAN-Fan.
    Last edited by WLAN-Fan; 01-07-2008 at 13:59.

  2. #2
    reicht es nicht ein shell script zu schreiben, dass in einer endlosschleife den webserver ausführt?

    solange er dann noch läuft blockiert das skript und wenn er abraucht ist es beendet, das skript geht weiter und er wird wieder gestartet.

    ...nur eine fixe idee von mir so grade...

    aber mir ist der noch nie abgestürzt, deswegen versteh ich den sinn noch nicht so ganz

  3. #3
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336
    @Wlanfan

    Wengi liegt ja voellig richtig.......

    1.) der Standard http Daemon wird von der Watchdog ueberwacht, d.h. ein 'killall httpd' beweist es dir - gleich danach findest du den httpd wieder in der Processliste. Das ist notwendig, weil das Webif immer erreichbar sein muss.

    2.) Wenn du irgnd einen anderen Webserver oder sonst einen Process ueberwachen willst gibt es einen einfachen, aber sicheren Weg mit Cron.
    In die Crontab: * * * * * admin /tmp/local/sbin/startprocess
    (Also alle Minuten)

    und in /tmp/local/sbin/startprocess mit vi anlegen:

    Code:
    #!/bin/sh
    #feel free to copy and/or modify 
    
    Processname=asterisk
    if [ ! -n "`pidof $Processname`" ] ; then  #when Processname is not in pid list (running)
        echo -n Starting: $Processname
        date
        exec $Processname
    fi
    naja, jetzt nur noch das uebliche:
    Code:
    chmod 755 /tmp/local/sbin/startprocess
    und natuerlich:
    Code:
    flashfs save && flashfs commit && flashfs enable && reboot
    ach ja, den prozessnamen musst du natuerlich anpassen, ich habe asterisk drinnen stehen. Weiters kannst Du natuerlich die Processlist beliebig erweitern, einfach alles immer wieder kopieren und eben mehrere Prozesse nacheinander eintragen.

    Ahhh haette ich fast vergessen - den script startprocess kannst natuerlich auch irgendwo in /opt schreiben, du musst nur aufpassen, dass sowohl der Aufruf vom Script als auch der Pfad (path) immer eindeutig sind, notfalls vollstaendig angeben!
    Weiters kannst Du beim Start von einem Process selbstverstaendlich auch ev. notwendige Parameter angeben.........
    Falls dir eine Minute zu lan ist, fuegst Du einfach z.Bspl. ein sleep 29 am Ende vom Scipt ein und kopierst den ganzen "schmafu" nochmals nach sleep 29, dann wird eben 2x pro Minute kontrolliert. Nur bitte aufpassen, dass die Laufzeit vom Script nicht laenger als ein Minute sein kann, ansonsten gibts mehrere Prozesse (Instanzen) mit der gleichen Funktion.
    have fun....

    Edit: und natuerlich kannst Du die echo Ausgabe mit >> auf deinen logfile umleiten (hat zumindest irgend wann einmal wengi vorgeschlagen).

    NACHTRAG: Es koennte sein, dass Du mehrere Instanzen von einem Prozess brauchst, z. Bspl. httpd muessen ja 2 Prozesse laufen, deshalb der Nachtrag. Wenn Du mehrere httpds brauchst, lege den Aufruf der Crontab auf /opt/sbin/startprocess und starte vi /opt/sbin/startprocess
    dann:
    Code:
    #!/bin/sh
    #Script to check how many instances of a process are running
    #written by newbiefan (asusforum)
    #published under gnu gpl2 or any later version
    #When more as minprocess tasks are running, nothing happens.
    #As example: you want to start 2 busybox httpd's, then set minprocess to 1
    # when the second httpd process is not running, the script starts your second httpd
    
    
    processname=asterisk
    minprocess=1  #a minimum of x process(es) are running, if not start one more
    howmanyproc=`ps -def | grep $processname | grep -v grep | wc -l`
    if [ $howmanyproc -gt $minprocess ] ; then    # when more as minprocess instance(s) is running
      echo There are $howmanyproc instances of $processname running
     else # just one instance is running, start the second
      exec $processname
    fi
    Viel Spass
    Last edited by newbiefan; 18-06-2008 at 22:29.

  4. #4
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Moin,

    und wenn Du an der richtigen Stelle noch ein logger einfügst:
    Code:
    #!/bin/sh
    #Script to check how many instances of a process are running
    #written by newbiefan (asusforum)
    #published under gnu gpl2 or any later version
    #When more as minprocess tasks are running, nothing happens.
    #As example: you want to start 2 busybox httpd's, then set minprocess to 1
    # when the second httpd process is not running, the script starts your second httpd
    
    
    processname=asterisk
    minprocess=1  #a minimum of x process(es) are running, if not start one more
    howmanyproc=`ps -def | grep $processname | grep -v grep | wc -l`
    if [ $howmanyproc -gt $minprocess ] ; then    # when more as minprocess instance(s) is running
      echo There are $howmanyproc instances of $processname running
     else # just one instance is running, start the second
      exec $processname
      logger -t MyWatchDog "Process started by my Watchdog: $processname"
    fi
    kannst Du im syslog sogar sehen, wann ein Prozess neu gesteartet wurde.
    wengi
    Übersicht aller HowTos --- HowTo Overview (mostly german)
    WL-HDD mit diesem Setup. --- WL-HDD with this setup.
    Kein Support per PM - Frage im jeweiligen Thread! --- No support via pm - ask in the according thread!
    Eine wirklich gute Idee erkennt man daran, dass ihre Verwirklichung von vorne herein ausgeschlossen erscheint. (Albert Einstein)

  5. #5
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336
    Quote Originally Posted by wengi View Post
    Moin,

    und wenn Du an der richtigen Stelle noch ein logger einfügst:
    Code:
    XXXX.......
    kannst Du im syslog sogar sehen, wann ein Prozess neu gestartet wurde.
    wengi
    Super teamwork Wengi!!

    Tja WLAN_Fan und jetzt koenntest Du noch ein Schleife drueber legen und damit ganz einfach eine Prozessliste abarbeiten....oder verschiedene Prozesse samt Start-Parameter aus einem File holen........
    for processname in.......do usw.

  6. #6
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    423

  7. #7
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Nö. Bei mir stürzen die Dienste nicht ab....

    wengi
    Übersicht aller HowTos --- HowTo Overview (mostly german)
    WL-HDD mit diesem Setup. --- WL-HDD with this setup.
    Kein Support per PM - Frage im jeweiligen Thread! --- No support via pm - ask in the according thread!
    Eine wirklich gute Idee erkennt man daran, dass ihre Verwirklichung von vorne herein ausgeschlossen erscheint. (Albert Einstein)

  8. #8
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336
    ja der Script mit pidof laeuft bei mir, da mein Hama ATA (Allnet 7902) noch einige Fehler bei der Anmeldung am Asterisk Server (Wl500gP) produziert und dann alle Asterisk Prozesse aus der Prozessliste verschwinden. Muss mir aber erst die Logfiles ansehen. Auch meine (ebay erworbene) Fritzbox! Fon macht noch Probleme und bringt Asterisk zum Absturz, deshalb brauche ich den Script. So richtig stabil wirds wohl erst am Wochenende werden, wenn ich etwas mehr Zeit habe. Aber vorher muss ich noch die Fritzbox Fon patchen und auf den neuesten FW Stand bringen. Habe noch keine Ahnung, wie ich meine ISDN Anlage an die Fon haenge = noch viel lesen.....
    Jedenfalls funzen beide Scripte einwandfrei = mehrfach getestet.
    Der erste startet dir nur einen Prozess und der zweite eben mehrere.
    LG

  9. #9
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    423

    Startup Script for Cron Step by Step erklären bitte

    Aus [How To] Firmware und Software installieren. Step-by-Step Punkt 8. CRON

    PHP Code:
    #!/bin/sh
    #
    # Startup script for cron

    PIDFILE=/opt/var/run/cron.pid

    case $1 in
     start
    )
       /
    opt/sbin/cron
       
    ;;
     
    stop)
       [ -
    ${PIDFILE} ] && kill `cat ${PIDFILE}`  ;;
       *)
       echo 
    "usage: $0 (start|stop)"
       
    exit 1
    esac 
    Kann das mal bitte einer Step by Step erklären was hier gemacht wird?
    Was steht in $1 drin?
    Wo holt es das her?
    Warum sind da zwei ;; hintereinander?
    Kann es sein das das Script anders formatiert wesentlich leichter zu verstehen wäre?

    Danke.

  10. #10
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Hi,

    - in $1 steht das drin, was Du beim Aufruf mitgibst, wobei 1 für den ersten Parameter steht. Erwartet wird hier start oder stop.
    - Die ;; kommen von der Definition des case Befehls: http://cip.physik.uni-freiburg.de/ma...os/sh.php#case
    - Nein, eine andere Formatierung macht es nicht übersichtlicher, weil es meiner Meinung nach schon optimal ist:

    Wenn start: starte /opt/sbin/cron
    Wenn stop: beende cron über die PID
    Bei allem Anderen: Zeige usage.

    wengi
    Übersicht aller HowTos --- HowTo Overview (mostly german)
    WL-HDD mit diesem Setup. --- WL-HDD with this setup.
    Kein Support per PM - Frage im jeweiligen Thread! --- No support via pm - ask in the according thread!
    Eine wirklich gute Idee erkennt man daran, dass ihre Verwirklichung von vorne herein ausgeschlossen erscheint. (Albert Einstein)

  11. #11
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    423
    Inhalt von Datei: /opt/etc/crontab
    PHP Code:
    SHELL=/bin/sh
    PATH
    =/sbin:/bin:/usr/sbin:/usr/bin:/opt/sbin:/opt/bin
    MAILTO
    =""
    HOME=/
    # ---------- ---------- Default is Empty ---------- ---------- #
    * * * * * admin /tmp/local/sbin/startprocess
    * * * * * admin /tmp/mnt/disc0_3/tep/programm-start.sh 
    Inhalt von Datei: /tmp/local/sbin/startprocess
    PHP Code:
    #!/bin/sh
    #feel free to copy and/or modify 

    Processname=busybox_httpd -p 80 -r WL-HDD -/tmp/harddisk/www-busybox-httpd
    if [ ! -"`pidof $Processname`" ] ; then  #when Processname is not in pid list (running)
        
    echo -n Starting$Processname
        date
        exec $Processname
    fi 
    So sieht das bei mir aus.
    * * * * * admin /tmp/mnt/disc0_3/tep/programm-start.sh FUNKTIONIERT

    * * * * * admin /tmp/local/sbin/startprocess FUNKTIONIERT NICHT
    Warum?

    Liegt es daran das ich das:
    busybox_httpd -p 80 -r WL-HDD -h /tmp/harddisk/www-busybox-httpd
    anstatt nur das:
    busybox_httpd
    hingeschrieben habe?

    Sollte ich den Aufruf:
    busybox_httpd -p 80 -r WL-HDD -h /tmp/harddisk/www-busybox-httpd
    in eine busybox-start.sh schreiben und das
    busybox-start.sh
    dann mit cron starten?

    Wenn ich diesen cron Watchdog habe muß ich dann das hier auch machen oder wäre das doppeltgemoppelt?
    How to run two Webservers
    Quote Originally Posted by sesamebike View Post
    First you need to start the webserver. Add the following line to /usr/local/init/post-boot:

    Code:
    busybox_httpd -c /mnt/usbfs/etc/httpd.conf -p 8080 -r "My dungeon" -h /mnt/usbfs/web
    Und wenn doch gebraucht, dann sollte ich den busybox http Start lieger in der /usr/local/init/post-boot
    oder lieber so:?

    http://wl500g.info/newreply.php?do=newreply&p=96256
    Quote Originally Posted by wengi View Post
    Hi,

    wenn Du Dir die rc.unslung mal genau ansiehst wirst Du feststellen, dass nur Dateien gestartet werden , die mit einem großen S anfangen. daher wird mein busybox_httpd im Moment nicht gestartet.
    Code:
    [admin@blechbuechse root]$ ls -la /opt/etc/init.d/
    total 32
    drwxr-xr-x 2 admin root 4096 May  8 08:44 .
    drwxr-xr-x 8 admin root 4096 May  8 08:41 ..
    -rwxr-xr-x 1 admin root  908 May  5 15:50 S05syslogd
    -rwxr-xr-x 1 admin root  224 Apr 10 11:55 S10cron
    -rwxr-xr-x 1 admin root 1446 Apr 26 11:01 S10xinetd
    -rwxr-xr-x 1 admin root  809 Apr  3 08:47 S80lighttpd
    -rwxr-xr-x 1 admin root 3127 May  3 22:28 _S80busybox_httpd
    -rwxr-xr-x 1 admin root  822 Apr 10 10:46 rc.unslung
    Hier der Inhalt:
    Code:
    [admin@blechbuechse root]$ cat /opt/etc/init.d/_S80busybox_httpd
    #!/bin/sh
    
    PATH=/sbin:/bin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin
    
    # Uncomment path to busybox httpd to enable startup
    BUSYBOX_HTTPD=/usr/sbin/busybox_httpd
    
    HTTPD_CONFIG=/opt/etc/httpd.conf
    LISTENING_PORT=8008
    INDEX=/opt/share/www/index.html
    
    check_config(){
      if [ ! -r ${HTTPD_CONFIG} ]; then
      echo "Creating default ${HTTPD_CONFIG}"
      cat > ${HTTPD_CONFIG} << __EOF__
    # httpd.conf has the following format:
    #
    # A:172.20.         # Allow address from 172.20.0.0/16
    # A:10.0.0.0/25     # Allow any address from 10.0.0.0-10.0.0.127
    # A:10.0.0.0/255.255.255.128  # Allow any address that previous set
    # A:127.0.0.1       # Allow local loopback connections
    # D:*               # Deny from other IP connections
    # /cgi-bin:foo:bar  # Require user foo, pwd bar on urls starting with /cgi-bin/
    # /adm:admin:setup  # Require user admin, pwd setup on urls starting with /adm/
    # /adm:toor:PaSsWd  # or user toor, pwd PaSsWd on urls starting with /adm/
    # .au:audio/basic   # additional mime type for audio.au files
    #
    # A/D may be as a/d or allow/deny - first char case insensitive
    # Deny IP rules take precedence over allow rules.
    #
    #
    # The Deny/Allow IP logic:
    #
    #  - Default is to allow all.  No addresses are denied unless
    #         denied with a D: rule.
    #  - Order of Deny/Allow rules is significant
    #  - Deny rules take precedence over allow rules.
    #  - If a deny all rule (D:*) is used it acts as a catch-all for unmatched
    #       addresses.
    #  - Specification of Allow all (A:*) is a no-op
    #
    # Example:
    #   1. Allow only specified addresses
    #     A:172.20          # Allow any address that begins with 172.20.
    #     A:10.10.          # Allow any address that begins with 10.10.
    #     A:127.0.0.1       # Allow local loopback connections
    #     D:*               # Deny from other IP connections
    #
    #   2. Only deny specified addresses
    #   2. Only deny specified addresses
    #     D:1.2.3.        # deny from 1.2.3.0 - 1.2.3.255
    #     D:2.3.4.        # deny from 2.3.4.0 - 2.3.4.255
    #     A:*             # (optional line added for clarity)
    #
    # If a sub directory contains a config file it is parsed and merged with
    # any existing settings as if it was appended to the original configuration.
    #
    # subdir paths are relative to the containing subdir and thus cannot
    # affect the parent rules.
    #
    # Note that since the sub dir is parsed in the forked thread servicing the
    # subdir http request, any merge is discarded when the process exits.  As a
    # result, the subdir settings only have a lifetime of a single request.
    #
    A:*
    #/cgi-bin:${USER}:password
    .au:audio/basic
    .asp:text/html
    __EOF__
      fi
    }
    
    start() {
      if [ ! -x "${BUSYBOX_HTTPD}" ]; then
            echo "busybox httpd ${BUSYBOX_HTTPD} not started."
            exit 2
      fi
      check_config
      echo -n "Starting busybox httpd at port ${LISTENING_PORT} ... "
      ${BUSYBOX_HTTPD} -c ${HTTPD_CONFIG} -p ${LISTENING_PORT} -h /opt/share/www
      echo "done"
    }
    
    stop() {
            echo -n "Shutting down busybox httpd... "
            killall busybox_httpd
            echo "done"
    }
    
    case "$1" in
            start)
                    start
                    ;;
            stop)
                    stop
                    ;;
            restart)
                    stop
                    sleep 1
                    start
                    ;;
            *)
                    echo "Usage: $0 (start|stop|restart)"
                    exit 1
                    ;;
    esac
    wengi
    Gruß.
    Last edited by WLAN-Fan; 26-06-2008 at 09:02.

  12. #12
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Probier das mal:
    Code:
    #!/bin/sh
    #feel free to copy and/or modify 
    
    Processname=busybox_httpd
    if [ ! -n "`pidof $Processname`" ] ; then  #when Processname is not in pid list (running)
        echo -n Starting: $Processname
        date
        exec busybox_httpd -p 80 -r WL-HDD -h /tmp/harddisk/www-busybox-httpd
    fi
    Der processname ist immer nur das executable.
    Die Optionen erst beim exec angeben. Es könnte sein, dass die noch in "" müssen. Ich habs nicht getestet.

    Wenn Du zwei busybox_httpd mit verschiedenen Optionen laufen hast musst Du über ps und grep zunächst feststellen, welcher abgeraucht ist und dann diesen neu starten.

    wengi
    Last edited by wengi; 26-06-2008 at 07:24.
    Übersicht aller HowTos --- HowTo Overview (mostly german)
    WL-HDD mit diesem Setup. --- WL-HDD with this setup.
    Kein Support per PM - Frage im jeweiligen Thread! --- No support via pm - ask in the according thread!
    Eine wirklich gute Idee erkennt man daran, dass ihre Verwirklichung von vorne herein ausgeschlossen erscheint. (Albert Einstein)

  13. #13
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    erledigt...

    wengi
    Last edited by wengi; 26-06-2008 at 14:54.
    Übersicht aller HowTos --- HowTo Overview (mostly german)
    WL-HDD mit diesem Setup. --- WL-HDD with this setup.
    Kein Support per PM - Frage im jeweiligen Thread! --- No support via pm - ask in the according thread!
    Eine wirklich gute Idee erkennt man daran, dass ihre Verwirklichung von vorne herein ausgeschlossen erscheint. (Albert Einstein)

  14. #14
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    423
    Teil 2: (Bitte von einem Admin des Forums mal nach oben an Position zwei der Threads scheiben, danke)

    X.) Informationen
    - Was sind Pids?
    => Loged euch mal mit Putty auf einem Router ein und tipt ps ein:
    PHP Code:
    [admin@WL-HDD /]$ ps
      PID  Uid     VmSize Stat Command
        1 admin       544 S   
    /sbin/init
        2 admin           SW  
    [keventd]
        
    3 admin           SWN [ksoftirqd_CPU0]
    ... 
    Ihr seht im Tabelkopf PID stehen und darunter Zahlen die immer größer werden (wie groß und ob dann von vorn anfängt oder die Box abschmiert ist ein gute Frage!) diese Zahlen sind die Pids die überprüft werden in dem Watchdogscript.



    Y.) BusyBox HTTPd Webser beim Router-Start mitstarten - Datei /opt/etc/init.d/S80busybox_httpd

    - Da wir diesen cron Watchdog haben, dann bräuchten wir eigentlich nichts weiter, da spätestens nach einer Minute nach Router-Start der cron-Watchdog den HTTPd Webserver prüft und einschaltet.

    Dennoch kann es bstimmt nix schaden es ein zubauen:
    http://wl500g.info/newreply.php?do=newreply&p=96256
    Quote Originally Posted by wengi View Post
    wenn Du Dir die rc.unslung mal genau ansiehst wirst Du feststellen, dass nur Dateien gestartet werden , die mit einem großen S anfangen. daher wird mein busybox_httpd im Moment nicht gestartet.
    PHP Code:
    [admin@blechbuechse root]$ ls -la /opt/etc/init.d/
    total 32
    drwxr
    -xr-x 2 admin root 4096 May  8 08:44 .
    drwxr-xr-x 8 admin root 4096 May  8 08:41 ..
    -
    rwxr-xr-x 1 admin root  908 May  5 15:50 S05syslogd
    -rwxr-xr-x 1 admin root  224 Apr 10 11:55 S10cron
    -rwxr-xr-x 1 admin root 1446 Apr 26 11:01 S10xinetd
    -rwxr-xr-x 1 admin root  809 Apr  3 08:47 S80lighttpd
    -rwxr-xr-x 1 admin root 3127 May  3 22:28 _S80busybox_httpd
    -rwxr-xr-x 1 admin root  822 Apr 10 10:46 rc.unslung 
    Hier der Inhalt:
    PHP Code:
    [admin@blechbuechse root]$ cat /opt/etc/init.d/_S80busybox_httpd
    #!/bin/sh

    PATH=/sbin:/bin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin

    # Uncomment path to busybox httpd to enable startup
    BUSYBOX_HTTPD=/usr/sbin/busybox_httpd

    HTTPD_CONFIG
    =/opt/etc/httpd.conf
    LISTENING_PORT
    =8008
    INDEX
    =/opt/share/www/index.html

    check_config
    (){
      if [ ! -
    ${HTTPD_CONFIG} ]; then
      
    echo "Creating default ${HTTPD_CONFIG}"
      
    cat > ${HTTPD_CONFIG} << __EOF__
    # httpd.conf has the following format:
    #
    # A:172.20.         # Allow address from 172.20.0.0/16
    # A:10.0.0.0/25     # Allow any address from 10.0.0.0-10.0.0.127
    # A:10.0.0.0/255.255.255.128  # Allow any address that previous set
    # A:127.0.0.1       # Allow local loopback connections
    # D:*               # Deny from other IP connections
    # /cgi-bin:foo:bar  # Require user foo, pwd bar on urls starting with /cgi-bin/
    # /adm:admin:setup  # Require user admin, pwd setup on urls starting with /adm/
    # /adm:toor:PaSsWd  # or user toor, pwd PaSsWd on urls starting with /adm/
    # .au:audio/basic   # additional mime type for audio.au files
    #
    # A/D may be as a/d or allow/deny - first char case insensitive
    # Deny IP rules take precedence over allow rules.
    #
    #
    # The Deny/Allow IP logic:
    #
    #  - Default is to allow all.  No addresses are denied unless
    #         denied with a D: rule.
    #  - Order of Deny/Allow rules is significant
    #  - Deny rules take precedence over allow rules.
    #  - If a deny all rule (D:*) is used it acts as a catch-all for unmatched
    #       addresses.
    #  - Specification of Allow all (A:*) is a no-op
    #
    # Example:
    #   1. Allow only specified addresses
    #     A:172.20          # Allow any address that begins with 172.20.
    #     A:10.10.          # Allow any address that begins with 10.10.
    #     A:127.0.0.1       # Allow local loopback connections
    #     D:*               # Deny from other IP connections
    #
    #   2. Only deny specified addresses
    #   2. Only deny specified addresses
    #     D:1.2.3.        # deny from 1.2.3.0 - 1.2.3.255
    #     D:2.3.4.        # deny from 2.3.4.0 - 2.3.4.255
    #     A:*             # (optional line added for clarity)
    #
    # If a sub directory contains a config file it is parsed and merged with
    # any existing settings as if it was appended to the original configuration.
    #
    # subdir paths are relative to the containing subdir and thus cannot
    # affect the parent rules.
    #
    # Note that since the sub dir is parsed in the forked thread servicing the
    # subdir http request, any merge is discarded when the process exits.  As a
    # result, the subdir settings only have a lifetime of a single request.
    #
    A:*
    #/cgi-bin:${USER}:password
    .au:audio/basic
    .asp:text/html
    __EOF__
      fi
    }

    start() {
      if [ ! -
    "${BUSYBOX_HTTPD}]; then
            
    echo "busybox httpd ${BUSYBOX_HTTPD} not started."
            
    exit 2
      fi
      check_config
      
    echo -"Starting busybox httpd at port ${LISTENING_PORT} ... "
      
    ${BUSYBOX_HTTPD} -${HTTPD_CONFIG} -${LISTENING_PORT} -/opt/share/www
      
    echo "done"
    }

    stop() {
            echo -
    "Shutting down busybox httpd... "
            
    killall busybox_httpd
            
    echo "done"
    }

    case 
    "$1" in
            start
    )
                    
    start
                    
    ;;
            
    stop)
                    
    stop
                    
    ;;
            
    restart)
                    
    stop
                    sleep 1
                    start
                    
    ;;
            *)
                    echo 
    "Usage: $0 (start|stop|restart)"
                    
    exit 1
                    
    ;;
    esac 
    wengi
    Gruß WLAN-Fan.

Similar Threads

  1. Ïîäñêàæèòå, ÷òî ýòîò ëîã çíà÷èò? (syslog)
    By VadimVB in forum Russian Discussion - РУССКИЙ (RU)
    Replies: 479
    Last Post: 23-05-2013, 07:47
  2. Replies: 83
    Last Post: 26-04-2009, 05:53
  3. How to set busybox httpd
    By bermneon in forum WL-700g Firmware Discussion
    Replies: 0
    Last Post: 24-04-2007, 03:56
  4. HTTPD questions...
    By jlangston in forum WL-HDD Q&A
    Replies: 1
    Last Post: 17-08-2006, 16:37
  5. WL-500gx with openwrt pre-rc5 howto webserver?
    By ye_old in forum WL-500g Custom Development
    Replies: 1
    Last Post: 22-03-2006, 12:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •