source: branches/port5/SH/arb_panic

Last change on this file was 5715, checked in by westram, 16 years ago

fix TAB and indentation

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