-
Notifications
You must be signed in to change notification settings - Fork 1
/
qt-mysql-secure-vpopmail
executable file
·44 lines (36 loc) · 1.24 KB
/
qt-mysql-secure-vpopmail
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
#!/bin/sh
#
# Copyright (C) 2013 - Eric Shubert <[email protected]>
# Secure mysql and install vpopmail database for QMailToaster
########################################################################
# Change Log
# 12/05/13 shubes - created
########################################################################
me=${0##*/}
myver=v1.0
echo "$me $myver"
chkconfig mysqld on
service mysqld status >/dev/null 2>&1
rc=$?
if [ "$rc" == "3" ]; then
service mysqld start >/dev/null 2>&1
fi
mysql_secure_installation
if [ $? -ne 0 ]; then
echo "$me - unsuccessful mysql_secure_installation - terminating"
exit 1
fi
# Create vpopmail database
read -s -p "Please enter the MySQL Root Password you just created: " mysql_root_pw
# TODO: only create the database if it doesn't exist. Offer to drop it.
mysqladmin create vpopmail -uroot -p$mysql_root_pw
mysqladmin -uroot -p$mysql_root_pw reload
mysqladmin -uroot -p$mysql_root_pw refresh
# Grant access to the vpopmail user on from localhost
vpopmail_local_pw="SsEeCcRrEeTt"
echo "GRANT ALL PRIVILEGES ON vpopmail.* \
TO vpopmail@localhost IDENTIFIED BY '$vpopmail_local_pw'" \
| mysql -uroot -p$mysql_root_pw
mysqladmin -uroot -p$mysql_root_pw reload
mysqladmin -uroot -p$mysql_root_pw refresh
exit 0