source: tags/arb-6.0/SH/arb_panic

Last change on this file was 11815, checked in by westram, 10 years ago
  • 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    /bin/echo "             - >" `ls $i` "<";
26done
27echo "          --------------------------------"
28
29separator
30echo "Please choose one line and enter the rightmost number"
31
32read ARB_PID
33if [ ! -f $TMPDIR/arb_pids_${USER}_${ARB_PID} ]; then
34    err "Incorrect Choice"
35fi
36
37separator
38echo "Please enter full path (to save DB):"
39read FILE
40
41panicfile="$TMPDIR/arb_panic_${USER}_${ARB_PID}"
42rm -f $panicfile
43echo "$FILE" >$panicfile
44ok=false
45for i in `cat $TMPDIR/arb_pids_${USER}_${ARB_PID}`; do
46    echo "[Sending SIGHUP to pid $i]"
47    if kill -HUP $i 2>/dev/null; then
48        ok=true
49        echo "[Process $i accepted HUP]"
50        break
51    fi
52done
53
54if [ "$ok" = "false" ]; then
55    err "Sorry could not find a running server"
56fi
57separator
58echo "Wait until database is saved (or press <ctrl-c> to abort)"
59while [ -f $panicfile ]; do
60    echo "[waiting]"
61    sleep 1
62    if [ -f $panicfile] ; then
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                fi
71            fi
72        fi
73    fi
74done
75
76separator
77echo "enter 'kill'    if you want to kill the server and its clients"
78echo "enter 'killall' if you want to kill ALL servers and clients"
79
80read ki
81
82if [ "$ki" = "kill" ] ; then
83    echo "[Sending SIGTERM to pid $i]"
84    kill -TERM $i
85fi
86if [ "$ki" = "killall" ] ; then
87    arb_clean killall
88fi
Note: See TracBrowser for help on using the repository browser.