~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to support-files/mysql.server-sys5.sh

  • Committer: Stewart Smith
  • Date: 2008-07-09 01:40:54 UTC
  • mfrom: (105 drizzle)
  • mto: This revision was merged to the branch mainline in revision 111.
  • Revision ID: stewart@flamingspork.com-20080709014054-xfgfzirbhqzrzkkj
mergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
# This is an example SysV-init-script by Winfried Truemper that you can use
4
 
# and modify to your liking
5
 
#
6
 
 
7
 
PATH="$PATH:@prefix@"
8
 
export PATH
9
 
MY_CFG="@prefix@/mysql.cfg"
10
 
 
11
 
read_mysql_config() {
12
 
    # this routine requires a sed, which reads even the last line of input
13
 
 
14
 
    MY_CONFIG_FILE="$1"    # file to read setting from
15
 
    MY_CONFIG_SECTION="$2" # section inside the file
16
 
    MY_CONFIG_TAG="$3"     # name of the setting inside the section
17
 
    TAB=`printf "\t" ""`   # makes the code cut&paste safe
18
 
 
19
 
    sed -n -f - "$MY_CONFIG_FILE" <<EOF
20
 
1,/^\[$MY_CONFIG_SECTION\]/ d
21
 
/^\[[a-z]/ q
22
 
/^$MY_CONFIG_TAG/ {
23
 
s/^$MY_CONFIG_TAG[ $TAB]*=[ $TAB]*\([^ $TAB]*\)/\1/
24
 
p
25
 
q
26
 
}
27
 
EOF
28
 
}
29
 
 
30
 
 
31
 
 
32
 
do_start() {
33
 
    nohup ./bin/mysqld --defaults-file="$MY_CFG" &
34
 
}
35
 
 
36
 
do_stop() {
37
 
    ./bin/mysqladmin --defaults-file="$MY_CFG" shutdown
38
 
}
39
 
 
40
 
do_kill_all() {
41
 
    PIDS=`ps -efo pid,args | grep mysql | sed -e "s,  *.*,," | sort | uniq`
42
 
    kill $PIDS
43
 
    sleep 5
44
 
    kill -9 $PIDS
45
 
}
46
 
 
47
 
do_kill() {
48
 
    MY_PIDFILE=`read_mysql_config "$MY_CFG" "mysqld" "pidfile" `
49
 
    read MY_PID < "$MY_PIDFILE"
50
 
    kill "$MY_PID"
51
 
    sleep 2
52
 
    kill -KILL "$MY_PID"
53
 
}
54
 
 
55
 
# z.B. mysql.sh admin "ping"
56
 
do_admin() {
57
 
    shift
58
 
    ./bin/mysqladmin --defaults-file="$MY_CFG" $@
59
 
    exit
60
 
}
61
 
 
62
 
do_repair() {
63
 
    MY_DATADIR=`read_mysql_config "$MY_CFG" "mysqld" "datadir" `
64
 
    ./bin/isamchk --defaults-file="$MY_CFG" --repair "$MY_DATADIR/$1"
65
 
    shift
66
 
}
67
 
 
68
 
 
69
 
do_repair_all() {
70
 
    MY_DATADIR=`read_mysql_config "$MY_CFG" "mysqld" "datadir" `
71
 
    for i in `find "$MY_DATADIR" -name "*.ISM"`
72
 
    do
73
 
        ./bin/isamchk --defaults-file="$MY_CFG" --repair "$MY_DATADIR/$i"
74
 
    done
75
 
}
76
 
 
77
 
 
78
 
 
79
 
MY_BASEDIR=`read_mysql_config "$MY_CFG" "mysqld" "basedir"`
80
 
cd "$MY_BASEDIR" || exit 1
81
 
while test $# -gt 0
82
 
do
83
 
    MY_ARG="$1"
84
 
    do_$MY_ARG $@
85
 
    shift
86
 
done