wok annotate mariadb/stuff/etc/init.d/mysql @ rev 24891
lynx: use ncursesw (tanks ceel)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Apr 07 07:20:18 2022 +0000 (2022-04-07) |
parents | 0d8a1a3edc72 |
children |
rev | line source |
---|---|
erjo@13054 | 1 #!/bin/sh |
al@19159 | 2 # /etc/init.d/mysql : Start, stop and restart MySQL server on SliTaz, at |
erjo@13054 | 3 # boot time or with the command line. |
erjo@13054 | 4 # |
erjo@13054 | 5 # To start MySQL server at boot time, just put mysql in the $RUN_DAEMONS |
erjo@13054 | 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf |
erjo@13054 | 7 # |
erjo@13054 | 8 . /etc/init.d/rc.functions |
erjo@13054 | 9 . /etc/daemons.conf |
erjo@13054 | 10 |
erjo@13054 | 11 NAME=Mysql |
al@19159 | 12 DESC="$(_ '%s server' MySQL)" |
erjo@13054 | 13 DAEMON=/usr/bin/mysqld_safe |
erjo@13054 | 14 OPTIONS=$MYSQL_OPTIONS |
erjo@13054 | 15 PIDFILE=/var/run/mysqld/mysql.pid |
erjo@13054 | 16 [ -n "$OPTIONS" ] || OPTIONS="--pid-file=$PIDFILE --datadir=/var/lib/mysql --user=mysql --socket=/var/run/mysqld/mysqld.sock" |
erjo@13054 | 17 |
pascal@16681 | 18 if [ ! -d /var/lib/mysql ]; then |
pascal@16681 | 19 mkdir -p /var/lib/mysql |
pascal@16681 | 20 chown mysql.mysql /var/lib/mysql |
pascal@16681 | 21 fi |
erjo@13054 | 22 case "$1" in |
erjo@13054 | 23 start) |
erjo@13054 | 24 if active_pidfile $PIDFILE mysqld ; then |
al@19159 | 25 _ '%s is already running.' $NAME |
erjo@13054 | 26 exit 1 |
erjo@13054 | 27 fi |
erjo@13054 | 28 if [ ! -d /var/lib/mysql/mysql ]; then |
al@19159 | 29 action 'Initializing %s...' "$DESC" |
al@19159 | 30 rm -rf /var/lib/mysql/* 2>/dev/null |
erjo@13054 | 31 mysql_install_db --user=mysql --datadir=/var/lib/mysql |
al@19159 | 32 status |
erjo@13054 | 33 fi |
al@19159 | 34 action 'Starting %s: %s...' "$DESC" $NAME |
al@19159 | 35 $DAEMON $OPTIONS >/dev/null & |
erjo@13054 | 36 status |
erjo@13054 | 37 sleep 2 |
erjo@13054 | 38 for i in /etc/mysql.d/* ; do |
al@19159 | 39 [ -x $i ] || continue |
al@19159 | 40 action 'Running %s...' $i |
al@19159 | 41 $i |
al@19159 | 42 status |
erjo@13054 | 43 done |
erjo@13054 | 44 ;; |
erjo@13054 | 45 stop) |
erjo@13054 | 46 if ! active_pidfile $PIDFILE mysqld ; then |
al@19159 | 47 _ '%s is not running.' $NAME |
erjo@13054 | 48 exit 1 |
erjo@13054 | 49 fi |
al@19159 | 50 action 'Stopping %s: %s...' "$DESC" $NAME |
al@19159 | 51 kill $(cat $PIDFILE) >/dev/null |
erjo@13054 | 52 status |
erjo@13054 | 53 sleep 2 |
erjo@13054 | 54 ;; |
erjo@13054 | 55 restart) |
erjo@13054 | 56 if ! active_pidfile $PIDFILE mysqld ; then |
al@19159 | 57 _ '%s is not running.' $NAME |
erjo@13054 | 58 exit 1 |
erjo@13054 | 59 fi |
al@19159 | 60 action 'Restarting %s: %s...' "$DESC" $NAME |
al@19159 | 61 kill $(cat $PIDFILE) |
erjo@13054 | 62 sleep 2 |
erjo@13054 | 63 $DAEMON $OPTIONS & |
erjo@13054 | 64 status |
erjo@13054 | 65 sleep 2 |
erjo@13054 | 66 ;; |
erjo@13054 | 67 *) |
al@19159 | 68 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]" |
al@19159 | 69 newline |
erjo@13054 | 70 exit 1 |
erjo@13054 | 71 ;; |
erjo@13054 | 72 esac |
erjo@13054 | 73 |
erjo@13054 | 74 exit 0 |