@@ -55,8 +55,6 @@ function install_mysql() {
55
55
# https://imsavva.com/silent-installation-mysql-5-7-on-ubuntu/
56
56
# http://www.microhowto.info/howto/perform_an_unattended_installation_of_a_debian_package.html
57
57
echo mysql-apt-config mysql-apt-config/enable-repo select mysql-8.0 | sudo debconf-set-selections
58
- echo mysql-community-server mysql-community-server/root-pass password " root" | sudo debconf-set-selections
59
- echo mysql-community-server mysql-community-server/re-root-pass password " root" | sudo debconf-set-selections
60
58
echo mysql-community-server mysql-server/default-auth-override select "Use Strong Password Encryption (RECOMMENDED)" | sudo debconf-set-selections
61
59
62
60
if [ " $OS_NAME " == " DEBIAN" ]; then
@@ -77,6 +75,21 @@ function install_mysql() {
77
75
echo -e " \x 1b[1; 34m[* ] Starting MySQL\x 1b[0m"
78
76
}
79
77
78
+ function start_mysql() {
79
+ sudo systemctl start mysql.service || true # will fail in a docker image
80
+
81
+ # Add the default empire user to the mysql database
82
+ mysql -u root -e " CREATE USER IF NOT EXISTS ' empire_user' @' localhost' IDENTIFIED BY ' empire_password' ; " || true
83
+ mysql -u root -e " GRANT ALL PRIVILEGES ON * .* TO ' empire_user' @' localhost' WITH GRANT OPTION; " || true
84
+ mysql -u root -e " FLUSH PRIVILEGES; " || true
85
+
86
+ # Some OS have a root password set by default. We could probably
87
+ # be more smart about this, but we just try both.
88
+ mysql -u root -proot -e " CREATE USER IF NOT EXISTS ' empire_user' @' localhost' IDENTIFIED BY ' empire_password' ; " || true
89
+ mysql -u root -proot -e " GRANT ALL PRIVILEGES ON * .* TO ' empire_user' @' localhost' WITH GRANT OPTION; " || true
90
+ mysql -u root -proot -e " FLUSH PRIVILEGES; " || true
91
+ }
92
+
80
93
function install_xar() {
81
94
# xar-1.6.1 has an incompatibility with libssl 1.1.x that is patched here
82
95
wget https://github.com/BC-SECURITY/xar/archive/xar-1.6.1-patch.tar.gz
@@ -148,8 +161,8 @@ install_powershell
148
161
if ! command_exists mysql; then
149
162
install_mysql
150
163
fi
151
- sudo systemctl start mysql.service || true # will fail in a docker image
152
- mysql -u root -e " SET PASSWORD FOR ' root ' @ ' localhost ' = PASSWORD( ' root ' ) ; " || true # Set root password to root if its blank
164
+
165
+ start_mysql
153
166
154
167
if [ " $ASSUME_YES " == " 1" ] ;then
155
168
answer=" Y"
0 commit comments