Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
Signed-off-by: Teddysun <i@teddysun.com>
  • Loading branch information
teddysun committed Dec 11, 2024
1 parent a254171 commit 0afbb0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
21 changes: 11 additions & 10 deletions conf/lamp
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,18 @@ del_vhost() {
}

make_temp_mycnf() {
cat >/root/.my.cnf<<EOF
cat >/tmp/.my.cnf<<EOF
[client]
user=root
password='$1'
host = localhost
user = root
password = '$1'
EOF
chmod 600 /root/.my.cnf
chmod 600 /tmp/.my.cnf
}

clean_temp_mycnf() {
if [ -s "/root/.my.cnf" ]; then
rm -f /root/.my.cnf
if [ -s "/tmp/.my.cnf" ]; then
rm -f /tmp/.my.cnf
fi
if [ -s "/tmp/.mysql.tmp" ]; then
rm -f /tmp/.mysql.tmp
Expand All @@ -487,7 +488,7 @@ clean_temp_mycnf() {
do_query() {
echo "$1" >/tmp/.mysql.tmp
chmod 600 /tmp/.mysql.tmp
/usr/bin/mariadb --defaults-file="/root/.my.cnf" </tmp/.mysql.tmp
/usr/bin/mariadb --defaults-file="/tmp/.my.cnf" </tmp/.mysql.tmp
return $?
}

Expand Down Expand Up @@ -536,7 +537,7 @@ GRANT ALL PRIVILEGES ON \`${database_name}\`.* TO '${database_name}'@'localhost'
GRANT ALL PRIVILEGES ON \`${database_name}\`.* TO '${database_name}'@'127.0.0.1';
FLUSH PRIVILEGES;
EOF
if /usr/bin/mariadb --defaults-file="/root/.my.cnf" </tmp/.add_mysql.sql >/dev/null 2>&1; then
if /usr/bin/mariadb --defaults-file="/tmp/.my.cnf" </tmp/.add_mysql.sql >/dev/null 2>&1; then
_info "Add database $(_green "${database_name}") sucessfully."
else
_info "Add database $(_red "${database_name}") failed."
Expand All @@ -545,7 +546,7 @@ EOF
}

list_database() {
if /usr/bin/mariadb --defaults-file="/root/.my.cnf" -e "SHOW DATABASES;"; then
if /usr/bin/mariadb --defaults-file="/tmp/.my.cnf" -e "SHOW DATABASES;"; then
_info "List all databases sucessfully."
else
_info "List all databases failed."
Expand All @@ -567,7 +568,7 @@ DROP USER '${database_name}'@'localhost';
DROP DATABASE \`${database_name}\`;
FLUSH PRIVILEGES;
EOF
if /usr/bin/mariadb --defaults-file="/root/.my.cnf" </tmp/.del.mysql.sql; then
if /usr/bin/mariadb --defaults-file="/tmp/.my.cnf" </tmp/.del.mysql.sql; then
_info "Delete database $(_green "${database_name}") sucessfully."
else
_info "Delete database $(_red "${database_name}") failed."
Expand Down
15 changes: 11 additions & 4 deletions lamp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,17 @@ _error_detect "systemctl restart ${php_fpm}"
sleep 1
_error_detect "systemctl restart apache2"
sleep 1
if [ -f "/etc/mysql/debian-start" ]; then
cat >/etc/mysql/debian-start <<EOF
#!/bin/bash
exit 0
if [ -f "/etc/mysql/debian.cnf" ]; then
cp -p /etc/mysql/debian.cnf /etc/mysql/debian.cnf.bak
cat >/etc/mysql/debian.cnf <<EOF
[client]
host = localhost
user = root
password = '${db_pass}'
[mysql_upgrade]
host = localhost
user = root
password = '${db_pass}'
EOF
fi
_error_detect "systemctl restart mariadb"
Expand Down

0 comments on commit 0afbb0c

Please sign in to comment.