File: mysql.func

package info (click to toggle)
wwwconfig-common 0.3.0
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 488 kB
  • sloc: sh: 952; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 823 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File:		mysql.func
# Changes:
#	20010430 Ola Lundqvist <opal@debian.org>
#	20020125 Ola Lundqvist <opal@debian.org>
#		Fixed multiple $tmpwhat matching lines, #115485.
#	20020126 Ola Lundqvist <opal@debian.org>
#		Added new variable found so that empty passwords will be
#		correctly handled.
# Needs:	/etc/mysql/my.cnf
# Description:	Get a config value from my.cnf
# Usage:	getmysqlopt section option
# Sets:		$getmysqlopt = value

found=no
getmysqlopt() {
    tmpcfgfile="$3"
    tmpwhat="$2"
    tmpsect="$1"

    if grep -v '^#' $tmpcfgfile | grep "\[$tmpsect\]" >/dev/null 2>&1 ; then
	getmysqlopt=$(grep -A 10 "\[$tmpsect\]" $tmpcfgfile | grep "^[[:space:]]*$tmpwhat[[:space:]]*=[[:space:]]*" | head -1 | sed "s|^[[:space:]]*$tmpwhat[[:space:]]*=[[:space:]]*||g; s|[[:space:]][[:space:]]*$||g;")
	found=yes
    fi
}