Merge lp:~ignacio-nin/percona-server/5.5-debian-init-script into lp:percona-server/5.5
- 5.5-debian-init-script
- Merge into 5.5
Status: | Work in progress |
---|---|
Proposed branch: | lp:~ignacio-nin/percona-server/5.5-debian-init-script |
Merge into: | lp:percona-server/5.5 |
Diff against target: |
652 lines (+16/-193) 4 files modified
build/debian/percona-server-server-5.5.mysql.init (+0/-184) build/debian/percona-server-server-5.5.postinst (+1/-1) build/debian/percona-server-server-5.5.postrm (+7/-3) build/debian/percona-server-server-5.5.preinst (+8/-5) |
To merge this branch: | bzr merge lp:~ignacio-nin/percona-server/5.5-debian-init-script |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexey Kopytov (community) | Needs Information | ||
Ignacio Nin (community) | Needs Resubmitting | ||
Review via email: mp+186948@code.launchpad.net |
Commit message
Description of the change
New debian init script from the upstream package
Ignacio Nin (ignacio-nin) wrote : | # |
> - Comment for rev. 559 says file-id changes have been null-merged to 5.5, but
> I see that build/debian/
> file-id. Is that intentional?
Yes, the file-id for this file is created new in 560, since it's a completely new file. 559 is indeed a null-merge.
>
> - are there any specific bugs that this change is supposed to solve? If so,
> they should be referenced in comments/--fixes.
Resubmitting with the same comments as for the 5.1 branch
>
> - the following change smells like a charset conversion issue:
>
> 658 - cp /usr/share/
> sed 's°/°_°g'` $file
> 659 + cp /usr/share/
> sed 's�/�_�g'` $file
Fix't-
Alexey Kopytov (akopytov) wrote : | # |
Same question as in the 5.1 MP.
Raghavendra D Prabhu (raghavendra-prabhu) wrote : | # |
The init script seems to be same as mysql.server.sh of centos.
Doesn't this require porting of some debian init script features?
For instance,
following is different in debian and centos:
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
Unmerged revisions
- 560. By Ignacio Nin
-
Replace the debian init script with the script provided by source
The debian init script had some issues when it came to detecting the
server had been started -- it had a hardcoded 15 seconds wait (although
this could be overridden by my.cnf) and in order to detect a running
server it tried to login to it.This came with issues when a) the startup time exceeded 15 seconds, which
is something that can easily happen with datasets of hundreds of gigs,
and b) if there was no user available for the init script to use, or the
user had been misconfigured somehow. Of course, these two possibilites
were true too often.Replace the script with the one provided by MySQL, which uses a PID-file
based detection mechanism to check whether the server has been started or
stopped.Given that the two init scripts share no common history (the previous one
came from the debian distribution), bzr rm and bzr add it to avoid
pointless conflicts. Merge this with the same fix for 5.1, and share the
file id with the corresponding file in that branch. - 559. By Ignacio Nin
-
Unify the file-id's from the pre and post scripts for dpkg.
Null merge of this change in 5.1. Also introduce some local changes for
help with the merges.
Preview Diff
1 | === added file 'build/debian/percona-server-server-5.5.mysql.init' | |||
2 | --- build/debian/percona-server-server-5.5.mysql.init 1970-01-01 00:00:00 +0000 | |||
3 | +++ build/debian/percona-server-server-5.5.mysql.init 2013-09-30 21:14:02 +0000 | |||
4 | @@ -0,0 +1,390 @@ | |||
5 | 1 | #!/bin/sh | ||
6 | 2 | # Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB | ||
7 | 3 | # This file is public domain and comes with NO WARRANTY of any kind | ||
8 | 4 | |||
9 | 5 | # MySQL (Percona Server) daemon start/stop script. | ||
10 | 6 | |||
11 | 7 | # Usually this is put in /etc/init.d (at least on machines SYSV R4 based | ||
12 | 8 | # systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. | ||
13 | 9 | # When this is done the mysql server will be started when the machine is | ||
14 | 10 | # started and shut down when the systems goes down. | ||
15 | 11 | |||
16 | 12 | # Comments to support chkconfig on RedHat Linux | ||
17 | 13 | # chkconfig: 2345 64 36 | ||
18 | 14 | # description: A very fast and reliable SQL database engine. | ||
19 | 15 | |||
20 | 16 | # Comments to support LSB init script conventions | ||
21 | 17 | ### BEGIN INIT INFO | ||
22 | 18 | # Provides: mysql | ||
23 | 19 | # Required-Start: $local_fs $network $remote_fs | ||
24 | 20 | # Should-Start: ypbind nscd ldap ntpd xntpd | ||
25 | 21 | # Required-Stop: $local_fs $network $remote_fs | ||
26 | 22 | # Default-Start: 2 3 4 5 | ||
27 | 23 | # Default-Stop: 0 1 6 | ||
28 | 24 | # Short-Description: start and stop MySQL (Percona Server) | ||
29 | 25 | # Description: Percona-Server is a SQL database engine with focus on high performance. | ||
30 | 26 | ### END INIT INFO | ||
31 | 27 | |||
32 | 28 | # If you install MySQL on some other places than /usr, then you | ||
33 | 29 | # have to do one of the following things for this script to work: | ||
34 | 30 | # | ||
35 | 31 | # - Run this script from within the MySQL installation directory | ||
36 | 32 | # - Create a /etc/my.cnf file with the following information: | ||
37 | 33 | # [mysqld] | ||
38 | 34 | # basedir=<path-to-mysql-installation-directory> | ||
39 | 35 | # - Add the above to any other configuration file (for example ~/.my.ini) | ||
40 | 36 | # and copy my_print_defaults to /usr/bin | ||
41 | 37 | # - Add the path to the mysql-installation-directory to the basedir variable | ||
42 | 38 | # below. | ||
43 | 39 | # | ||
44 | 40 | # If you want to affect other MySQL variables, you should make your changes | ||
45 | 41 | # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. | ||
46 | 42 | |||
47 | 43 | # If you change base dir, you must also change datadir. These may get | ||
48 | 44 | # overwritten by settings in the MySQL configuration files. | ||
49 | 45 | |||
50 | 46 | basedir= | ||
51 | 47 | datadir= | ||
52 | 48 | |||
53 | 49 | # Default value, in seconds, afterwhich the script should timeout waiting | ||
54 | 50 | # for server start. | ||
55 | 51 | # Value here is overriden by value in my.cnf. | ||
56 | 52 | # 0 means don't wait at all | ||
57 | 53 | # Negative numbers mean to wait indefinitely | ||
58 | 54 | service_startup_timeout=900 | ||
59 | 55 | |||
60 | 56 | # Lock directory for RedHat / SuSE. | ||
61 | 57 | lockdir='/var/lock/subsys' | ||
62 | 58 | lock_file_path="$lockdir/mysql" | ||
63 | 59 | |||
64 | 60 | # The following variables are only set for letting mysql.server find things. | ||
65 | 61 | |||
66 | 62 | # Set some defaults | ||
67 | 63 | mysqld_pid_file_path= | ||
68 | 64 | if test -z "$basedir" | ||
69 | 65 | then | ||
70 | 66 | basedir=/usr | ||
71 | 67 | bindir=/usr/bin | ||
72 | 68 | if test -z "$datadir" | ||
73 | 69 | then | ||
74 | 70 | datadir=/var/lib/mysql | ||
75 | 71 | fi | ||
76 | 72 | sbindir=/usr/sbin | ||
77 | 73 | libexecdir=/usr/sbin | ||
78 | 74 | else | ||
79 | 75 | bindir="$basedir/bin" | ||
80 | 76 | if test -z "$datadir" | ||
81 | 77 | then | ||
82 | 78 | datadir="$basedir/data" | ||
83 | 79 | fi | ||
84 | 80 | sbindir="$basedir/sbin" | ||
85 | 81 | libexecdir="$basedir/libexec" | ||
86 | 82 | fi | ||
87 | 83 | |||
88 | 84 | # datadir_set is used to determine if datadir was set (and so should be | ||
89 | 85 | # *not* set inside of the --basedir= handler.) | ||
90 | 86 | datadir_set= | ||
91 | 87 | |||
92 | 88 | # | ||
93 | 89 | # Use LSB init script functions for printing messages, if possible | ||
94 | 90 | # | ||
95 | 91 | lsb_functions="/lib/lsb/init-functions" | ||
96 | 92 | if test -f $lsb_functions ; then | ||
97 | 93 | . $lsb_functions | ||
98 | 94 | else | ||
99 | 95 | log_success_msg() | ||
100 | 96 | { | ||
101 | 97 | echo " SUCCESS! $@" | ||
102 | 98 | } | ||
103 | 99 | log_failure_msg() | ||
104 | 100 | { | ||
105 | 101 | echo " ERROR! $@" | ||
106 | 102 | } | ||
107 | 103 | fi | ||
108 | 104 | |||
109 | 105 | PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" | ||
110 | 106 | export PATH | ||
111 | 107 | |||
112 | 108 | mode=$1 # start or stop | ||
113 | 109 | |||
114 | 110 | [ $# -ge 1 ] && shift | ||
115 | 111 | |||
116 | 112 | |||
117 | 113 | other_args="$*" # uncommon, but needed when called from an RPM upgrade action | ||
118 | 114 | # Expected: "--skip-networking --skip-grant-tables" | ||
119 | 115 | # They are not checked here, intentionally, as it is the resposibility | ||
120 | 116 | # of the "spec" file author to give correct arguments only. | ||
121 | 117 | |||
122 | 118 | case `echo "testing\c"`,`echo -n testing` in | ||
123 | 119 | *c*,-n*) echo_n= echo_c= ;; | ||
124 | 120 | *c*,*) echo_n=-n echo_c= ;; | ||
125 | 121 | *) echo_n= echo_c='\c' ;; | ||
126 | 122 | esac | ||
127 | 123 | |||
128 | 124 | parse_server_arguments() { | ||
129 | 125 | for arg do | ||
130 | 126 | case "$arg" in | ||
131 | 127 | --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` | ||
132 | 128 | bindir="$basedir/bin" | ||
133 | 129 | if test -z "$datadir_set"; then | ||
134 | 130 | datadir="$basedir/data" | ||
135 | 131 | fi | ||
136 | 132 | sbindir="$basedir/sbin" | ||
137 | 133 | libexecdir="$basedir/libexec" | ||
138 | 134 | ;; | ||
139 | 135 | --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` | ||
140 | 136 | datadir_set=1 | ||
141 | 137 | ;; | ||
142 | 138 | --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; | ||
143 | 139 | --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; | ||
144 | 140 | esac | ||
145 | 141 | done | ||
146 | 142 | } | ||
147 | 143 | |||
148 | 144 | wait_for_pid () { | ||
149 | 145 | verb="$1" # created | removed | ||
150 | 146 | pid="$2" # process ID of the program operating on the pid-file | ||
151 | 147 | pid_file_path="$3" # path to the PID file. | ||
152 | 148 | |||
153 | 149 | i=0 | ||
154 | 150 | avoid_race_condition="by checking again" | ||
155 | 151 | |||
156 | 152 | while test $i -ne $service_startup_timeout ; do | ||
157 | 153 | |||
158 | 154 | case "$verb" in | ||
159 | 155 | 'created') | ||
160 | 156 | # wait for a PID-file to pop into existence. | ||
161 | 157 | test -s "$pid_file_path" && i='' && break | ||
162 | 158 | ;; | ||
163 | 159 | 'removed') | ||
164 | 160 | # wait for this PID-file to disappear | ||
165 | 161 | test ! -s "$pid_file_path" && i='' && break | ||
166 | 162 | ;; | ||
167 | 163 | *) | ||
168 | 164 | echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path" | ||
169 | 165 | exit 1 | ||
170 | 166 | ;; | ||
171 | 167 | esac | ||
172 | 168 | |||
173 | 169 | # if server isn't running, then pid-file will never be updated | ||
174 | 170 | if test -n "$pid"; then | ||
175 | 171 | if kill -0 "$pid" 2>/dev/null; then | ||
176 | 172 | : # the server still runs | ||
177 | 173 | else | ||
178 | 174 | # The server may have exited between the last pid-file check and now. | ||
179 | 175 | if test -n "$avoid_race_condition"; then | ||
180 | 176 | avoid_race_condition="" | ||
181 | 177 | continue # Check again. | ||
182 | 178 | fi | ||
183 | 179 | |||
184 | 180 | # there's nothing that will affect the file. | ||
185 | 181 | log_failure_msg "The server quit without updating PID file ($pid_file_path)." | ||
186 | 182 | return 1 # not waiting any more. | ||
187 | 183 | fi | ||
188 | 184 | fi | ||
189 | 185 | |||
190 | 186 | echo $echo_n ".$echo_c" | ||
191 | 187 | i=`expr $i + 1` | ||
192 | 188 | sleep 1 | ||
193 | 189 | |||
194 | 190 | done | ||
195 | 191 | |||
196 | 192 | if test -z "$i" ; then | ||
197 | 193 | log_success_msg | ||
198 | 194 | return 0 | ||
199 | 195 | else | ||
200 | 196 | log_failure_msg | ||
201 | 197 | return 1 | ||
202 | 198 | fi | ||
203 | 199 | } | ||
204 | 200 | |||
205 | 201 | # Get arguments from the my.cnf file, | ||
206 | 202 | # the only group, which is read from now on is [mysqld] | ||
207 | 203 | if test -x ./bin/my_print_defaults | ||
208 | 204 | then | ||
209 | 205 | print_defaults="./bin/my_print_defaults" | ||
210 | 206 | elif test -x $bindir/my_print_defaults | ||
211 | 207 | then | ||
212 | 208 | print_defaults="$bindir/my_print_defaults" | ||
213 | 209 | elif test -x $bindir/mysql_print_defaults | ||
214 | 210 | then | ||
215 | 211 | print_defaults="$bindir/mysql_print_defaults" | ||
216 | 212 | else | ||
217 | 213 | # Try to find basedir in /etc/my.cnf | ||
218 | 214 | conf=/etc/my.cnf | ||
219 | 215 | print_defaults= | ||
220 | 216 | if test -r $conf | ||
221 | 217 | then | ||
222 | 218 | subpat='^[^=]*basedir[^=]*=\(.*\)$' | ||
223 | 219 | dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` | ||
224 | 220 | for d in $dirs | ||
225 | 221 | do | ||
226 | 222 | d=`echo $d | sed -e 's/[ ]//g'` | ||
227 | 223 | if test -x "$d/bin/my_print_defaults" | ||
228 | 224 | then | ||
229 | 225 | print_defaults="$d/bin/my_print_defaults" | ||
230 | 226 | break | ||
231 | 227 | fi | ||
232 | 228 | if test -x "$d/bin/mysql_print_defaults" | ||
233 | 229 | then | ||
234 | 230 | print_defaults="$d/bin/mysql_print_defaults" | ||
235 | 231 | break | ||
236 | 232 | fi | ||
237 | 233 | done | ||
238 | 234 | fi | ||
239 | 235 | |||
240 | 236 | # Hope it's in the PATH ... but I doubt it | ||
241 | 237 | test -z "$print_defaults" && print_defaults="my_print_defaults" | ||
242 | 238 | fi | ||
243 | 239 | |||
244 | 240 | # | ||
245 | 241 | # Read defaults file from 'basedir'. If there is no defaults file there | ||
246 | 242 | # check if it's in the old (depricated) place (datadir) and read it from there | ||
247 | 243 | # | ||
248 | 244 | |||
249 | 245 | extra_args="" | ||
250 | 246 | if test -r "$basedir/my.cnf" | ||
251 | 247 | then | ||
252 | 248 | extra_args="-e $basedir/my.cnf" | ||
253 | 249 | else | ||
254 | 250 | if test -r "$datadir/my.cnf" | ||
255 | 251 | then | ||
256 | 252 | extra_args="-e $datadir/my.cnf" | ||
257 | 253 | fi | ||
258 | 254 | fi | ||
259 | 255 | |||
260 | 256 | parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` | ||
261 | 257 | |||
262 | 258 | # | ||
263 | 259 | # Set pid file if not given | ||
264 | 260 | # | ||
265 | 261 | if test -z "$mysqld_pid_file_path" | ||
266 | 262 | then | ||
267 | 263 | mysqld_pid_file_path=$datadir/`hostname`.pid | ||
268 | 264 | else | ||
269 | 265 | case "$mysqld_pid_file_path" in | ||
270 | 266 | /* ) ;; | ||
271 | 267 | * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; | ||
272 | 268 | esac | ||
273 | 269 | fi | ||
274 | 270 | |||
275 | 271 | case "$mode" in | ||
276 | 272 | 'start') | ||
277 | 273 | # Start daemon | ||
278 | 274 | |||
279 | 275 | # Safeguard (relative paths, core dumps..) | ||
280 | 276 | cd $basedir | ||
281 | 277 | |||
282 | 278 | echo $echo_n "Starting MySQL (Percona Server)" | ||
283 | 279 | if test -x $bindir/mysqld_safe | ||
284 | 280 | then | ||
285 | 281 | # Give extra arguments to mysqld with the my.cnf file. This script | ||
286 | 282 | # may be overwritten at next upgrade. | ||
287 | 283 | $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 & | ||
288 | 284 | wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? | ||
289 | 285 | |||
290 | 286 | # Make lock for RedHat / SuSE | ||
291 | 287 | if test -w "$lockdir" | ||
292 | 288 | then | ||
293 | 289 | touch "$lock_file_path" | ||
294 | 290 | fi | ||
295 | 291 | |||
296 | 292 | exit $return_value | ||
297 | 293 | else | ||
298 | 294 | log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" | ||
299 | 295 | fi | ||
300 | 296 | ;; | ||
301 | 297 | |||
302 | 298 | 'stop') | ||
303 | 299 | # Stop daemon. We use a signal here to avoid having to know the | ||
304 | 300 | # root password. | ||
305 | 301 | |||
306 | 302 | if test -s "$mysqld_pid_file_path" | ||
307 | 303 | then | ||
308 | 304 | mysqld_pid=`cat "$mysqld_pid_file_path"` | ||
309 | 305 | |||
310 | 306 | if (kill -0 $mysqld_pid 2>/dev/null) | ||
311 | 307 | then | ||
312 | 308 | echo $echo_n "Shutting down MySQL (Percona Server)" | ||
313 | 309 | kill $mysqld_pid | ||
314 | 310 | # mysqld should remove the pid file when it exits, so wait for it. | ||
315 | 311 | wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$? | ||
316 | 312 | else | ||
317 | 313 | log_failure_msg "MySQL (Percona Server) server process #$mysqld_pid is not running!" | ||
318 | 314 | rm "$mysqld_pid_file_path" | ||
319 | 315 | fi | ||
320 | 316 | |||
321 | 317 | # Delete lock for RedHat / SuSE | ||
322 | 318 | if test -f "$lock_file_path" | ||
323 | 319 | then | ||
324 | 320 | rm -f "$lock_file_path" | ||
325 | 321 | fi | ||
326 | 322 | exit $return_value | ||
327 | 323 | else | ||
328 | 324 | log_failure_msg "MySQL (Percona Server) PID file could not be found!" | ||
329 | 325 | fi | ||
330 | 326 | ;; | ||
331 | 327 | |||
332 | 328 | 'restart') | ||
333 | 329 | # Stop the service and regardless of whether it was | ||
334 | 330 | # running or not, start it again. | ||
335 | 331 | if $0 stop $other_args; then | ||
336 | 332 | $0 start $other_args | ||
337 | 333 | else | ||
338 | 334 | log_failure_msg "Failed to stop running server, so refusing to try to start." | ||
339 | 335 | exit 1 | ||
340 | 336 | fi | ||
341 | 337 | ;; | ||
342 | 338 | |||
343 | 339 | 'reload'|'force-reload') | ||
344 | 340 | if test -s "$mysqld_pid_file_path" ; then | ||
345 | 341 | read mysqld_pid < "$mysqld_pid_file_path" | ||
346 | 342 | kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL (Percona Server)" | ||
347 | 343 | touch "$mysqld_pid_file_path" | ||
348 | 344 | else | ||
349 | 345 | log_failure_msg "MySQL (Percona Server) PID file could not be found!" | ||
350 | 346 | exit 1 | ||
351 | 347 | fi | ||
352 | 348 | ;; | ||
353 | 349 | 'status') | ||
354 | 350 | # First, check to see if pid file exists | ||
355 | 351 | if test -s "$mysqld_pid_file_path" ; then | ||
356 | 352 | read mysqld_pid < "$mysqld_pid_file_path" | ||
357 | 353 | if kill -0 $mysqld_pid 2>/dev/null ; then | ||
358 | 354 | log_success_msg "MySQL (Percona Server) running ($mysqld_pid)" | ||
359 | 355 | exit 0 | ||
360 | 356 | else | ||
361 | 357 | log_failure_msg "MySQL (Percona Server) is not running, but PID file exists" | ||
362 | 358 | exit 1 | ||
363 | 359 | fi | ||
364 | 360 | else | ||
365 | 361 | # Try to find appropriate mysqld process | ||
366 | 362 | mysqld_pid=`pidof $libexecdir/mysqld` | ||
367 | 363 | |||
368 | 364 | # test if multiple pids exist | ||
369 | 365 | pid_count=`echo $mysqld_pid | wc -w` | ||
370 | 366 | if test $pid_count -gt 1 ; then | ||
371 | 367 | log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" | ||
372 | 368 | exit 5 | ||
373 | 369 | elif test -z $mysqld_pid ; then | ||
374 | 370 | if test -f "$lock_file_path" ; then | ||
375 | 371 | log_failure_msg "MySQL (Percona Server) is not running, but lock file ($lock_file_path) exists" | ||
376 | 372 | exit 2 | ||
377 | 373 | fi | ||
378 | 374 | log_failure_msg "MySQL (Percona Server) is not running" | ||
379 | 375 | exit 3 | ||
380 | 376 | else | ||
381 | 377 | log_failure_msg "MySQL (Percona Server) is running but PID file could not be found" | ||
382 | 378 | exit 4 | ||
383 | 379 | fi | ||
384 | 380 | fi | ||
385 | 381 | ;; | ||
386 | 382 | *) | ||
387 | 383 | # usage | ||
388 | 384 | basename=`basename "$0"` | ||
389 | 385 | echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL (Percona Server) options ]" | ||
390 | 386 | exit 1 | ||
391 | 387 | ;; | ||
392 | 388 | esac | ||
393 | 389 | |||
394 | 390 | exit 0 | ||
395 | 0 | 391 | ||
396 | === removed file 'build/debian/percona-server-server-5.5.mysql.init' | |||
397 | --- build/debian/percona-server-server-5.5.mysql.init 2012-09-18 04:57:16 +0000 | |||
398 | +++ build/debian/percona-server-server-5.5.mysql.init 1970-01-01 00:00:00 +0000 | |||
399 | @@ -1,184 +0,0 @@ | |||
400 | 1 | #!/bin/bash | ||
401 | 2 | # | ||
402 | 3 | ### BEGIN INIT INFO | ||
403 | 4 | # Provides: mysql | ||
404 | 5 | # Required-Start: $remote_fs $syslog | ||
405 | 6 | # Required-Stop: $remote_fs $syslog | ||
406 | 7 | # Should-Start: $network $named $time | ||
407 | 8 | # Should-Stop: $network $named $time | ||
408 | 9 | # Default-Start: 2 3 4 5 | ||
409 | 10 | # Default-Stop: 0 1 6 | ||
410 | 11 | # Short-Description: Start and stop the mysql (Percona Server) daemon | ||
411 | 12 | # Description: Controls the main MySQL (Percona Server) daemon "mysqld" | ||
412 | 13 | # and its wrapper script "mysqld_safe". | ||
413 | 14 | ### END INIT INFO | ||
414 | 15 | # | ||
415 | 16 | set -e | ||
416 | 17 | set -u | ||
417 | 18 | ${DEBIAN_SCRIPT_DEBUG:+ set -v -x} | ||
418 | 19 | PERCONA_PREFIX=/usr | ||
419 | 20 | |||
420 | 21 | test -x "${PERCONA_PREFIX}"/sbin/mysqld || exit 0 | ||
421 | 22 | |||
422 | 23 | . /lib/lsb/init-functions | ||
423 | 24 | |||
424 | 25 | SELF=$(cd $(dirname $0); pwd -P)/$(basename $0) | ||
425 | 26 | CONF=/etc/mysql/my.cnf | ||
426 | 27 | MYADMIN="${PERCONA_PREFIX}/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" | ||
427 | 28 | |||
428 | 29 | # priority can be overriden and "-s" adds output to stderr | ||
429 | 30 | ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i" | ||
430 | 31 | |||
431 | 32 | # Safeguard (relative paths, core dumps..) | ||
432 | 33 | cd / | ||
433 | 34 | umask 077 | ||
434 | 35 | |||
435 | 36 | # mysqladmin likes to read /root/.my.cnf. This is usually not what I want | ||
436 | 37 | # as many admins e.g. only store a password without a username there and | ||
437 | 38 | # so break my scripts. | ||
438 | 39 | export HOME=/etc/mysql/ | ||
439 | 40 | |||
440 | 41 | ## Fetch a particular option from mysql's invocation. | ||
441 | 42 | # | ||
442 | 43 | # Usage: void mysqld_get_param option | ||
443 | 44 | mysqld_get_param() { | ||
444 | 45 | "${PERCONA_PREFIX}"/sbin/mysqld --print-defaults \ | ||
445 | 46 | | tr " " "\n" \ | ||
446 | 47 | | grep -- "--$1" \ | ||
447 | 48 | | tail -n 1 \ | ||
448 | 49 | | cut -d= -f2 | ||
449 | 50 | } | ||
450 | 51 | |||
451 | 52 | ## Do some sanity checks before even trying to start mysqld. | ||
452 | 53 | sanity_checks() { | ||
453 | 54 | # check for config file | ||
454 | 55 | # DISABLED: We do not install my.cnf | ||
455 | 56 | #if [ ! -r /etc/mysql/my.cnf ]; then | ||
456 | 57 | # log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | ||
457 | 58 | # echo "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER | ||
458 | 59 | #fi | ||
459 | 60 | |||
460 | 61 | # check for diskspace shortage | ||
461 | 62 | datadir=`mysqld_get_param datadir` | ||
462 | 63 | if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then | ||
463 | 64 | log_failure_msg "$0: ERROR: The partition with $datadir is too full!" | ||
464 | 65 | echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER | ||
465 | 66 | exit 1 | ||
466 | 67 | fi | ||
467 | 68 | } | ||
468 | 69 | |||
469 | 70 | ## Checks if there is a server running and if so if it is accessible. | ||
470 | 71 | # | ||
471 | 72 | # check_alive insists on a pingable server | ||
472 | 73 | # check_dead also fails if there is a lost mysqld in the process list | ||
473 | 74 | # | ||
474 | 75 | # Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn] | ||
475 | 76 | mysqld_status () { | ||
476 | 77 | ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? )) | ||
477 | 78 | |||
478 | 79 | ps_alive=0 | ||
479 | 80 | pidfile=`mysqld_get_param pid-file` | ||
480 | 81 | if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi | ||
481 | 82 | |||
482 | 83 | if [ "$1" = "check_alive" -a $ping_alive = 1 ] || | ||
483 | 84 | [ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then | ||
484 | 85 | return 0 # EXIT_SUCCESS | ||
485 | 86 | else | ||
486 | 87 | if [ "$2" = "warn" ]; then | ||
487 | 88 | echo -e "$ps_alive processes alive and '$MYADMIN ping' resulted in\n$ping_output\n" | $ERR_LOGGER -p daemon.debug | ||
488 | 89 | fi | ||
489 | 90 | return 1 # EXIT_FAILURE | ||
490 | 91 | fi | ||
491 | 92 | } | ||
492 | 93 | |||
493 | 94 | # | ||
494 | 95 | # main() | ||
495 | 96 | # | ||
496 | 97 | |||
497 | 98 | case "${1:-''}" in | ||
498 | 99 | 'start') | ||
499 | 100 | sanity_checks; | ||
500 | 101 | # Start daemon | ||
501 | 102 | log_daemon_msg "Starting MySQL (Percona Server) database server" "mysqld" | ||
502 | 103 | if mysqld_status check_alive nowarn; then | ||
503 | 104 | log_progress_msg "already running" | ||
504 | 105 | log_end_msg 0 | ||
505 | 106 | else | ||
506 | 107 | "${PERCONA_PREFIX}"/bin/mysqld_safe > /dev/null 2>&1 & | ||
507 | 108 | # 6s was reported in #352070 to be too few when using ndbcluster | ||
508 | 109 | for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do | ||
509 | 110 | sleep 1 | ||
510 | 111 | if mysqld_status check_alive nowarn ; then break; fi | ||
511 | 112 | log_progress_msg "." | ||
512 | 113 | done | ||
513 | 114 | if mysqld_status check_alive warn; then | ||
514 | 115 | log_end_msg 0 | ||
515 | 116 | # Now start mysqlcheck or whatever the admin wants. | ||
516 | 117 | output=$(/etc/mysql/debian-start) | ||
517 | 118 | [ -n "$output" ] && log_action_msg "$output" | ||
518 | 119 | else | ||
519 | 120 | log_end_msg 1 | ||
520 | 121 | log_failure_msg "Please take a look at the syslog" | ||
521 | 122 | fi | ||
522 | 123 | fi | ||
523 | 124 | ;; | ||
524 | 125 | |||
525 | 126 | 'stop') | ||
526 | 127 | # * As a passwordless mysqladmin (e.g. via ~/.my.cnf) must be possible | ||
527 | 128 | # at least for cron, we can rely on it here, too. (although we have | ||
528 | 129 | # to specify it explicit as e.g. sudo environments points to the normal | ||
529 | 130 | # users home and not /root) | ||
530 | 131 | log_daemon_msg "Stopping MySQL (Percona Server)" "mysqld" | ||
531 | 132 | if ! mysqld_status check_dead nowarn; then | ||
532 | 133 | set +e | ||
533 | 134 | shutdown_out=`$MYADMIN shutdown 2>&1`; r=$? | ||
534 | 135 | set -e | ||
535 | 136 | if [ "$r" -ne 0 ]; then | ||
536 | 137 | log_end_msg 1 | ||
537 | 138 | [ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out" | ||
538 | 139 | log_daemon_msg "Killing MySQL (Percona Server) by signal" "mysqld" | ||
539 | 140 | killall -15 mysqld | ||
540 | 141 | server_down= | ||
541 | 142 | for i in 1 2 3 4 5 6 7 8 9 10; do | ||
542 | 143 | sleep 1 | ||
543 | 144 | if mysqld_status check_dead nowarn; then server_down=1; break; fi | ||
544 | 145 | done | ||
545 | 146 | if test -z "$server_down"; then killall -9 mysqld; fi | ||
546 | 147 | fi | ||
547 | 148 | fi | ||
548 | 149 | |||
549 | 150 | if ! mysqld_status check_dead warn; then | ||
550 | 151 | log_end_msg 1 | ||
551 | 152 | log_failure_msg "Please stop MySQL (Percona Server) manually and read /usr/share/doc/percona-server-server-5.5/README.Debian.gz!" | ||
552 | 153 | exit -1 | ||
553 | 154 | else | ||
554 | 155 | log_end_msg 0 | ||
555 | 156 | fi | ||
556 | 157 | ;; | ||
557 | 158 | |||
558 | 159 | 'restart') | ||
559 | 160 | set +e; $SELF stop; set -e | ||
560 | 161 | $SELF start | ||
561 | 162 | ;; | ||
562 | 163 | |||
563 | 164 | 'reload'|'force-reload') | ||
564 | 165 | log_daemon_msg "Reloading MySQL (Percona Server)" "mysqld" | ||
565 | 166 | $MYADMIN reload | ||
566 | 167 | log_end_msg 0 | ||
567 | 168 | ;; | ||
568 | 169 | |||
569 | 170 | 'status') | ||
570 | 171 | if mysqld_status check_alive nowarn; then | ||
571 | 172 | log_action_msg "$($MYADMIN version)" | ||
572 | 173 | else | ||
573 | 174 | log_action_msg "MySQL (Percona Server) is stopped." | ||
574 | 175 | exit 3 | ||
575 | 176 | fi | ||
576 | 177 | ;; | ||
577 | 178 | |||
578 | 179 | *) | ||
579 | 180 | echo "Usage: $SELF start|stop|restart|reload|force-reload|status" | ||
580 | 181 | exit 1 | ||
581 | 182 | ;; | ||
582 | 183 | esac | ||
583 | 184 | |||
584 | 185 | 0 | ||
585 | === modified file 'build/debian/percona-server-server-5.5.postinst' | |||
586 | --- build/debian/percona-server-server-5.5.postinst 2013-02-19 07:01:26 +0000 | |||
587 | +++ build/debian/percona-server-server-5.5.postinst 2013-09-30 21:14:02 +0000 | |||
588 | @@ -58,7 +58,7 @@ | |||
589 | 58 | # and because changed configuration options should take effect immediately. | 58 | # and because changed configuration options should take effect immediately. |
590 | 59 | # In case the server wasn't running at all it should be ok if the stop | 59 | # In case the server wasn't running at all it should be ok if the stop |
591 | 60 | # script fails. I can't tell at this point because of the cleaned /var/run. | 60 | # script fails. I can't tell at this point because of the cleaned /var/run. |
593 | 61 | set +e; invoke stop; set -e | 61 | set +e; invoke stop > /dev/null 2>&1; set -e |
594 | 62 | 62 | ||
595 | 63 | case "$1" in | 63 | case "$1" in |
596 | 64 | configure) | 64 | configure) |
597 | 65 | 65 | ||
598 | === modified file 'build/debian/percona-server-server-5.5.postrm' | |||
599 | --- build/debian/percona-server-server-5.5.postrm 2012-09-18 04:57:16 +0000 | |||
600 | +++ build/debian/percona-server-server-5.5.postrm 2013-09-30 21:14:02 +0000 | |||
601 | @@ -19,9 +19,13 @@ | |||
602 | 19 | stop_server() { | 19 | stop_server() { |
603 | 20 | set +e | 20 | set +e |
604 | 21 | if [ -x /usr/sbin/invoke-rc.d ]; then | 21 | if [ -x /usr/sbin/invoke-rc.d ]; then |
606 | 22 | invoke-rc.d percona-server stop | 22 | cmd="invoke-rc.d mysql" |
607 | 23 | else | 23 | else |
609 | 24 | /etc/init.d/percona-server stop | 24 | cmd="/etc/init.d/mysql" |
610 | 25 | fi | ||
611 | 26 | if $cmd status > /dev/null 2>&1 | ||
612 | 27 | then | ||
613 | 28 | $cmd stop | ||
614 | 25 | fi | 29 | fi |
615 | 26 | errno=$? | 30 | errno=$? |
616 | 27 | set -e | 31 | set -e |
617 | @@ -69,7 +73,7 @@ | |||
618 | 69 | 73 | ||
619 | 70 | # (normally) Automatically added by dh_installinit | 74 | # (normally) Automatically added by dh_installinit |
620 | 71 | if [ "$1" = "purge" ] ; then | 75 | if [ "$1" = "purge" ] ; then |
622 | 72 | update-rc.d percona-server remove >/dev/null || exit 0 | 76 | update-rc.d mysql remove >/dev/null || exit 0 |
623 | 73 | fi | 77 | fi |
624 | 74 | # (normally) End automatically added section | 78 | # (normally) End automatically added section |
625 | 75 | fi | 79 | fi |
626 | 76 | 80 | ||
627 | === modified file 'build/debian/percona-server-server-5.5.preinst' | |||
628 | --- build/debian/percona-server-server-5.5.preinst 2012-09-18 04:57:16 +0000 | |||
629 | +++ build/debian/percona-server-server-5.5.preinst 2013-09-30 21:14:02 +0000 | |||
630 | @@ -24,15 +24,18 @@ | |||
631 | 24 | # do it himself. No database directories should be removed while the server | 24 | # do it himself. No database directories should be removed while the server |
632 | 25 | # is running! Another mysqld in e.g. a different chroot is fine for us. | 25 | # is running! Another mysqld in e.g. a different chroot is fine for us. |
633 | 26 | stop_server() { | 26 | stop_server() { |
635 | 27 | if [ ! -x /etc/init.d/percona-server ]; then return; fi | 27 | if [ ! -x /etc/init.d/mysql ]; then return; fi |
636 | 28 | 28 | ||
637 | 29 | set +e | 29 | set +e |
638 | 30 | if [ -x /usr/sbin/invoke-rc.d ]; then | 30 | if [ -x /usr/sbin/invoke-rc.d ]; then |
640 | 31 | cmd="invoke-rc.d percona-server stop" | 31 | cmd="invoke-rc.d mysql" |
641 | 32 | else | 32 | else |
645 | 33 | cmd="/etc/init.d/percona-server stop" | 33 | cmd="/etc/init.d/mysql" |
646 | 34 | fi | 34 | fi |
647 | 35 | $cmd | 35 | if $cmd status > /dev/null 2>&1 |
648 | 36 | then | ||
649 | 37 | $cmd stop | ||
650 | 38 | fi | ||
651 | 36 | errno=$? | 39 | errno=$? |
652 | 37 | set -e | 40 | set -e |
653 | 38 | 41 |
- Comment for rev. 559 says file-id changes have been null-merged to 5.5, but I see that build/debian/ percona- server- server- 5.5.mysql. init still changes its file-id. Is that intentional?
- are there any specific bugs that this change is supposed to solve? If so, they should be referenced in comments/--fixes.
- the following change smells like a charset conversion issue:
658 - cp /usr/share/ percona- server- common/ internal- use-only/ `echo $file | sed 's°/°_°g'` $file percona- server- common/ internal- use-only/ `echo $file | sed 's�/�_�g'` $file
659 + cp /usr/share/