928f2b4e653c3af5327ec79f4b56f6bbefb0e59f
[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   # ukljuci networking, da mysql visi na portu 3306
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   # ukljuci podrsku za hrvatsko znakovlje
30   # ne radi na Etch-u
31   #if ! grep -q default-character-set /etc/mysql/my.cnf; then
32   #  awk '/^\[mysqld\]/{print "[mysqld]"; print "default-character-set=croat"; getline}{print $0}' \
33   #    /etc/mysql/my.cnf > /etc/mysql/mysql-cn.$$
34   #  cp_mv /etc/mysql/mysql-cn.$$ /etc/mysql/my.cnf
35   #  restart=yes
36   #fi
37 fi
38
39 # pristup samo sa lokalne mreze, preko tcp-wrappera...
40 DOMAIN=`hostname -d`
41 if ! grep -q '^mysqld' /etc/hosts.deny; then
42         echo "mysqld: ALL" >> /etc/hosts.deny
43 fi
44 if ! grep -q '^mysqld' /etc/hosts.allow; then
45         echo "mysqld: .$DOMAIN 127.0.0.1" >> /etc/hosts.allow
46 fi
47
48 # ako nije setiran admin pass, setiraj
49 [ -f ~root/.my.cnf ] && grep -q "password.*=" ~root/.my.cnf && rootmycnf=1
50 if [ -z "$rootmycnf" ]; then
51   if ! grep -q "password.*=" /etc/mysql/my.cnf; then
52     if echo | mysql mysql 2> /dev/null; then
53       mypwd="`makepasswd`"
54       mysqladmin password $mypwd
55       cp_echo "CN: Password for MySQL administrator (root@localhost) is: $mypwd"
56       cp_mail $PKG
57     fi
58   fi
59 fi
60
61 if su - nobody -c '[ -r ~root/.my.cnf ]' 2>&1 > /dev/null; then
62   if grep -q "password.*=" ~root/.my.cnf; then
63     echo "CN: WARNING: ~root/.my.cnf is world readable."
64   fi
65 fi
66
67 [ "$restart" = "yes" ] || exit 0
68 # restart mysql-a
69 if [ -x /usr/sbin/invoke-rc.d ]; then
70   [ -x /etc/init.d/mysql ] && invoke-rc.d mysql restart
71 else
72   [ -x /etc/init.d/mysql ] && /etc/init.d/mysql restart
73 fi