evoadmin-web/scripts/my-edit.sh
Romain Dessort 623f281628 Add new features in web-add.sh script (related to 483482a):
- Unix quota management
  - support for multiple versions of PHP running in LXC containers with FPM
  - don't include MySQL information in summary email if no database is created
  - possibility to set custom MySQL connection parameters
  - fix op_listvhost() function since config file now ended with .conf
    and include useful additional informations (PHP version, used disk
    size, vhost enabled).
  - add scripts to manage/report MySQL databases and users (used by
    evoadmin dbadmin.php page)
2017-08-22 17:29:51 -04:00

48 lines
1.1 KiB
Bash

#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 passwd <login>"
echo "Usage: $0 adddb <login>"
echo "Usage: $0 dropdb <login>"
exit 1
fi
if [ "$1" = "passwd" ]; then
login="$2"
read -s -p "New password for ${login}: " password1
echo
read -s -p "New password for $login (confirm): " password2
if [ -z "$password1" ] || [ "$password1" != "$password2" ]; then
echo "Incorrect password."
exit 1
fi
mysql -e "SET PASSWORD FOR '${login}'@'%' = PASSWORD('${password1}');"
fi
if [ "$1" = "adddb" ]; then
login="$2"
read -p "New database name for ${login}: " database
if [ -z "$database" ]; then
echo "Database name cannot be empty."
exit 1
fi
mysql -e "CREATE DATABASE ${database};"
mysql -e "GRANT ALL ON ${database}.* TO '${login}'@'%';"
fi
if [ "$1" = "dropdb" ]; then
login="$2"
read -p "Drop database name for ${login}: " database
if [ -z "$database" ]; then
echo "Database name cannot be empty."
exit 1
fi
mysql -e "DROP DATABASE ${database};"
mysql -e "REVOKE ALL PRIVILEGES ON ${database}.* FROM '${login}'@'%';"
fi