source: tags/ms_r16q3/SH/arb_panic

Last change on this file was 12687, checked in by epruesse, 10 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
Line 
1#!/bin/sh
2
3umask 066 # user read/write
4
5separator() {
6    echo "*************************************** $*"
7}
8
9err () {
10    separator ERROR 1>&2
11    echo "`basename $0`: $@" 1>&2
12    exit 1
13}
14
15TMPDIR=~/.arb_tmp/tmp
16mkdir -p $TMPDIR
17chooser="$TMPDIR/arb_pids_${USER}_*"
18
19separator PANIC
20echo "  This Module tries to save a running database"
21echo "  There may be more than one database server (ARB_NT):"
22echo "          --------------------------------"
23
24for i in $chooser ; do
25    if [ ! -L "$i" ] ; then
26        /bin/echo "             - >" `ls $i` "<";
27    fi
28done
29echo "          --------------------------------"
30
31separator
32echo "Please choose one line and enter the rightmost number"
33
34read ARB_PID
35if [ ! -f $TMPDIR/arb_pids_${USER}_${ARB_PID} ]; then
36    err "Incorrect Choice"
37fi
38
39separator
40echo "Please enter full path (to save DB):"
41read FILE
42
43panicfile="$TMPDIR/arb_panic_${USER}_${ARB_PID}"
44rm -f $panicfile
45echo "$FILE" >$panicfile
46ok=false
47for i in `cat $TMPDIR/arb_pids_${USER}_${ARB_PID}`; do
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
54done
55
56if [ "$ok" = "false" ]; then
57    err "Sorry could not find a running server"
58fi
59separator
60echo "Wait until database is saved (or press <ctrl-c> to abort)"
61while [ -f $panicfile ]; do
62    echo "[waiting]"
63    sleep 1
64    if [ -f $panicfile] ; then
65        sleep 1
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
76done
77
78separator
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
82read ki
83
84if [ "$ki" = "kill" ] ; then
85    echo "[Sending SIGTERM to pid $i]"
86    kill -TERM $i
87fi
88if [ "$ki" = "killall" ] ; then
89    arb_clean killall
90fi
Note: See TracBrowser for help on using the repository browser.