lintian izmjene, plus zastarjele opcije
[mysql-cn.git] / debian / postinst
1 #!/bin/sh
2
3 set -e
4
5 [ "$1" = "configure" ] || exit 0
6 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
7
8 PKG="mysql-cn"
9
10 # Load CARNet Tools
11 . /usr/share/carnet-tools/functions.sh
12
13 if [ -f /etc/mysql/my.cnf ]; then
14   # iskljuci zastarjelu opciju
15   cp_check_and_sed '^skip-networking' \
16                    's/^skip-networking$/#skip-networking/' \
17                    /etc/mysql/my.cnf && restart=yes || true
18
19   # ukljuci podrsku za innodb, istinabog neznam zasto, al neka :-)
20   cp_check_and_sed '^skip-innodb$' \
21                    's/^skip-innodb$/#skip-innodb/' \
22                    /etc/mysql/my.cnf && restart=yes || true
23
24   # izgasi logiranje zbog prelude logova
25   cp_check_and_sed '^log.*mysql.log' \
26                    "s,^\([\t ]*log[\t ]*=\),#\1," \
27                    /etc/mysql/my.cnf && restart=yes || true
28
29   # iskljuci zastarjeli skip-bdb
30   cp_check_and_sed '^skip-bdb' \
31                    's/^skip-bdb$/#skip-bdb/' \
32                    /etc/mysql/my.cnf && restart=yes || true
33 fi
34
35 # pristup samo sa lokalne mreze, preko tcp-wrappera...
36 DOMAIN=`hostname -d`
37 if ! grep -q '^mysqld' /etc/hosts.deny; then
38         echo "mysqld: ALL" >> /etc/hosts.deny
39 fi
40 if ! grep -q '^mysqld' /etc/hosts.allow; then
41         echo "mysqld: .$DOMAIN 127.0.0.1" >> /etc/hosts.allow
42 fi
43
44 # ako nije setiran admin pass, setiraj
45 [ -f ~root/.my.cnf ] && grep -q "password.*=" ~root/.my.cnf && rootmycnf=1
46 if [ -z "$rootmycnf" ]; then
47   if ! grep -q "password.*=" /etc/mysql/my.cnf; then
48     if echo | mysql mysql 2> /dev/null; then
49       mypwd="`makepasswd`"
50       mysqladmin password $mypwd
51       cp_echo "CN: Password for MySQL administrator (root@localhost) is: $mypwd"
52       cp_mail $PKG
53     fi
54   fi
55 fi
56
57 if su - nobody -c '[ -r ~root/.my.cnf ]' 2>&1 > /dev/null; then
58   if grep -q "password.*=" ~root/.my.cnf; then
59     echo "CN: WARNING: ~root/.my.cnf is world readable."
60   fi
61 fi
62
63 [ "$restart" = "yes" ] || exit 0
64 # restart mysql-a
65 if [ -x /usr/sbin/invoke-rc.d ]; then
66   [ -x /etc/init.d/mysql ] && invoke-rc.d mysql restart
67 else
68   [ -x /etc/init.d/mysql ] && /etc/init.d/mysql restart
69 fi
70
71 #DEBHELPER#