File: mysql-localadmpass.get

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 (54 lines) | stat: -rw-r--r-- 1,868 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File:		mysql-localadmpass.get
# Changes:
#	20010430 Ola Lundqvist <opal@debian.org>
#	20011022 Luca De Vitis <luca@debian.org>
#		Allowed reinclusion.
#	20020116 Ola Lundqvist <opal@debian.org>
#		Documented the reinclusion.
#	20020125 Ola Lundqvist <opal@debian.org>
#		Empty passwords will be handled in a lot better way.
#	20020126 Ola Lundqvist <opal@debian.org>
#		Added password string again. Only mysqladmin works that
#		way, not mysql.
#		Removed the dbadmpassfound variable and
#		changed the status variable instead.
#	20020912 <hec@espuny.net>, applied by Ola Lundqvist <opal@debian.org>
#		mysql-localadmpass.get fails to get the user and password for
#		mysql administration if they are not at /etc/mysql/my.cnf
#		The solution is not to relay in the var "status" for stop the
#		search, but in "found"
# Needs:	/etc/mysql/my.cnf
#		/usr/share/wwwconfig-common/mysql.func
# Description:	Gets a user and passphrase (if found) from /etc/mysql/my.cnf
# Sets:		$dbadmpass = a passphrase (if found), will most probably
#			be empty because mysql can get it automaticly.
#		$dbadmin = a username (if found)
#		$status = {error, user, password, userpassword, nothing}
#		$mysql_localadmpass_get=done (to allow reinclusion).
#		$found = {yes, no}

if [ -z "$mysql_localadmpass_get" ] ; then
    . /usr/share/wwwconfig-common/mysql.func
    
    found=no
    status=error
    for A in /etc/mysql/my.cnf /var/lib/mysql/my.cnf ~/.my.cnf ; do
	if [ -f $A -a "$found" = "no" ] ; then
	    status=""
	    getmysqlopt mysqladmin user $A
	    if [ "$found" = "yes" ] ; then
		dbadmin=$getmysqlopt
		status=${status}user
	    fi
	    getmysqlopt mysqladmin password $A
	    if [ "$found" = "yes" ] ; then
		dbadmpass=$getmysqlopt
		status=${status}password
	    fi
	fi
    done
    mysql_localadmpass_get="done"
    if [ -z "$status" ] ; then
	status=nothing
    fi
fi