Skip to content

Commit

Permalink
mysql: Use debconf to capture user input
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewladlow committed Jul 24, 2018
1 parent 412ae90 commit a7a29c8
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
11 changes: 11 additions & 0 deletions mysql/debian/config
@@ -0,0 +1,11 @@
#!/bin/sh -e

. /usr/share/debconf/confmodule

while [ -z "$RET" ] ; do
db_input high symbiosis-mysql/admin_password || true
db_go
db_get symbiosis-mysql/admin_password
done

exit 0
2 changes: 1 addition & 1 deletion mysql/debian/control
Expand Up @@ -8,7 +8,7 @@ Standards-Version: 3.9.6

Package: symbiosis-mysql
Architecture: all
Depends: default-mysql-server (>= 1.0.2), ruby, symbiosis-common (>= 2014:0113), ${misc:Depends}
Depends: default-mysql-server (>= 1.0.2), ruby, symbiosis-common (>= 2014:0113), debconf, ${misc:Depends}
Replaces: bytemark-vhost-mysql, symbiosis-monit (<< 2011:1206)
Provides: bytemark-vhost-mysql
Conflicts: bytemark-vhost-mysql
Expand Down
6 changes: 4 additions & 2 deletions mysql/debian/postinst
Expand Up @@ -2,6 +2,8 @@

set -e

. /usr/share/debconf/confmodule

#
# Skip, if we are not in "configure" state
#
Expand Down Expand Up @@ -49,8 +51,8 @@ if grep -qx 'password = ' /etc/mysql/debian.cnf && [ "$(mysql -u root -se "selec
if [ -e /etc/first-boot.d/.mysql.hash ]; then
mysql -u root -e "grant all privileges on *.* to 'admin'@'localhost' identified by password '*$(cat /etc/first-boot.d/.mysql.hash)' with grant option;"
else
read -p "Enter a password for the admin@localhost MySQL user (To be used with phpMyAdmin): " password
mysql -u root -e "grant all privileges on *.* to 'admin'@'localhost' identified by '$password' with grant option;"
db_get symbiosis-mysql/admin_password
mysql -u root -e "grant all privileges on *.* to 'admin'@'localhost' identified by '$RET' with grant option;"
fi
fi

Expand Down
4 changes: 4 additions & 0 deletions mysql/debian/postrm
@@ -0,0 +1,4 @@
if [ "$1" = "purge" -a -e /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
db_purge
fi
3 changes: 3 additions & 0 deletions mysql/debian/templates
@@ -0,0 +1,3 @@
Template: symbiosis-mysql/admin_password
Type: password
Description: Enter a password for the admin@localhost MySQL user (for phpMyAdmin access).
13 changes: 0 additions & 13 deletions test/internal-test.d/00-create-mysql-hash

This file was deleted.

2 changes: 2 additions & 0 deletions test/internal-test.d/conf-stretch/debconf-preseed
Expand Up @@ -6,6 +6,8 @@ locales locales/locales_to_be_generated multiselect en_GB.UTF-8 UTF-8
mysql-server-5.5 mysql-server/root_password password semiconscious malpractice
# Repeat password for the MySQL "root" user:
mysql-server-5.5 mysql-server/root_password_again password semiconscious malpractice
# Set password for the MySQL "admin" user for phpMyAdmin access:
symbiosis-mysql symbiosis-mysql/admin_password password semiconscious malpractice
# Password of the database's administrative user:
phpmyadmin phpmyadmin/mysql/admin-pass password semiconscious malpractice
# Password of the database's administrative user:
Expand Down

0 comments on commit a7a29c8

Please sign in to comment.