source: trunk/SH/arb_panic

Last change on this file was 12687, checked in by epruesse, 11 years ago

merge log:branches/stable@12685 to trunk

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
RevLine 
[2]1#!/bin/sh
2
[5695]3umask 066 # user read/write
4
[6141]5separator() {
[5715]6    echo "*************************************** $*"
[5695]7}
8
[2]9err () {
[6141]10    separator ERROR 1>&2
[5715]11    echo "`basename $0`: $@" 1>&2
12    exit 1
[2]13}
14
[11815]15TMPDIR=~/.arb_tmp/tmp
16mkdir -p $TMPDIR
17chooser="$TMPDIR/arb_pids_${USER}_*"
[2]18
[6141]19separator PANIC
[5613]20echo "  This Module tries to save a running database"
21echo "  There may be more than one database server (ARB_NT):"
22echo "          --------------------------------"
[2]23
24for i in $chooser ; do
[12687]25    if [ ! -L "$i" ] ; then
26        /bin/echo "             - >" `ls $i` "<";
27    fi
[2]28done
[5613]29echo "          --------------------------------"
[2]30
[6141]31separator
[2]32echo "Please choose one line and enter the rightmost number"
33
34read ARB_PID
[11815]35if [ ! -f $TMPDIR/arb_pids_${USER}_${ARB_PID} ]; then
[5715]36    err "Incorrect Choice"
[2]37fi
38
[6141]39separator
[5695]40echo "Please enter full path (to save DB):"
[2]41read FILE
42
[11815]43panicfile="$TMPDIR/arb_panic_${USER}_${ARB_PID}"
[2]44rm -f $panicfile
45echo "$FILE" >$panicfile
46ok=false
[11815]47for i in `cat $TMPDIR/arb_pids_${USER}_${ARB_PID}`; do
[5715]48    echo "[Sending SIGHUP to pid $i]"
49    if kill -HUP $i 2>/dev/null; then
50        ok=true
51        echo "[Process $i accepted HUP]"
52        break
53    fi
[2]54done
[5695]55
[2]56if [ "$ok" = "false" ]; then
[5715]57    err "Sorry could not find a running server"
[2]58fi
[6141]59separator
[5695]60echo "Wait until database is saved (or press <ctrl-c> to abort)"
[2]61while [ -f $panicfile ]; do
[5695]62    echo "[waiting]"
63    sleep 1
64    if [ -f $panicfile] ; then
[5613]65        sleep 1
[5695]66        if [ -f $panicfile] ; then
67            sleep 1
68            if [ -f $panicfile] ; then
69                sleep 1
70                if [ -f $panicfile] ; then
71                    sleep 1       
72                fi
73            fi
74        fi
75    fi
[2]76done
77
[6141]78separator
[5695]79echo "enter 'kill'    if you want to kill the server and its clients"
80echo "enter 'killall' if you want to kill ALL servers and clients"
81
[2]82read ki
[5695]83
[2]84if [ "$ki" = "kill" ] ; then
[5695]85    echo "[Sending SIGTERM to pid $i]"
86    kill -TERM $i
87fi
88if [ "$ki" = "killall" ] ; then
[10680]89    arb_clean killall
[2]90fi
Note: See TracBrowser for help on using the repository browser.