~ubuntu-branches/ubuntu/utopic/mariadb-5.5/utopic-security

« back to all changes in this revision

Viewing changes to packaging/rpm-oel/mysql-systemd-start

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen, Otto Kekäläinen, James Page
  • Date: 2014-03-02 01:38:26 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140302013826-z3afnfteqo86pccd
[ Otto Kekäläinen ]
* New upstream release.
* Updated Danish debconf translation (Closes: #739750).
* d/control: Added explicit Conflicts/Replaces for mysql-5.6 packages
  (Closes: #739841).
* d/control: Update for use of virtual-* packages for switching to/from
  MySQL alternatives.

[ James Page ]
* d/control: Drop Nicholas from Uploaders, MIA (Closes: #739360).
* d/control: Add libjemalloc-dev to BD's.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/bash
 
2
#
 
3
# Scripts to run by MySQL systemd service
 
4
 
5
# Needed argument: pre | post
 
6
 
7
# pre mode  :  try to run mysql_install_db and fix perms and SELinux contexts
 
8
# post mode :  ping server until answer is received
 
9
 
10
 
 
11
install_db () {    
 
12
    # Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode)
 
13
    datadir=$(/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p')
 
14
    
 
15
    # Restore log, dir, perms and SELinux contexts
 
16
    [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1
 
17
    log=/var/log/mysqld.log
 
18
    [ -e $log ] || touch $log
 
19
    chmod 0640 $log
 
20
    chown mysql:mysql $log || exit 1
 
21
    if [ -x /usr/sbin/restorecon ]; then
 
22
        /usr/sbin/restorecon "$datadir"
 
23
        /usr/sbin/restorecon $log
 
24
    fi
 
25
 
 
26
    # If special mysql dir is in place, skip db install 
 
27
    [ -d "$datadir/mysql" ] && exit 0
 
28
 
 
29
    # Create initial db
 
30
    /usr/bin/mysql_install_db --rpm --datadir="$datadir" --user=mysql
 
31
    exit 0
 
32
}
 
33
 
 
34
pinger () {
 
35
    # Wait for ping to answer to signal startup completed,
 
36
    # might take a while in case of e.g. crash recovery
 
37
    # MySQL systemd service will timeout script if no answer
 
38
    while /bin/true ; do
 
39
        sleep 1
 
40
        mysqladmin ping >/dev/null 2>&1 && break
 
41
    done
 
42
    exit 0
 
43
}
 
44
 
 
45
# main
 
46
case $1 in
 
47
    "pre") install_db ;;
 
48
    "post") pinger ;;
 
49
esac
 
50
 
 
51
exit 0
 
52