| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #!/bin/bash
- # info: deletes temp database user
- # options: USER DATABASE DBUSER [TYPE] [HOST]
- #
- # example: v-delete-database-temp-user user wordress hestia_sso_user mysql
- #
- # Revokes "temp user" access to a database and removes the user
- # To be used in combination with v-add-database-temp-user
- #----------------------------------------------------------#
- # Variables & Functions #
- #----------------------------------------------------------#
- # Argument definition
- user=$1
- database=$2
- dbuser=$3
- type=${4-mysql}
- host=$5
- # Includes
- # shellcheck source=/etc/hestiacp/hestia.conf
- source /etc/hestiacp/hestia.conf
- # shellcheck source=/usr/local/hestia/func/main.sh
- source $HESTIA/func/main.sh
- # shellcheck source=/usr/local/hestia/func/db.sh
- source $HESTIA/func/db.sh
- # load config file
- source_conf "$HESTIA/conf/hestia.conf"
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- check_args '3' "$#" 'USER DATABASE DBUSER [TYPE] [HOST]'
- is_format_valid 'user' 'database' 'dbuser'
- is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
- is_object_valid 'user' 'USER' "$user"
- is_object_unsuspended 'user' 'USER' "$user"
- is_object_valid 'db' 'DB' "$database"
- is_object_unsuspended 'db' 'DB' "$database"
- get_next_dbhost
- if [[ $dbuser != *"hestia_sso"* ]]; then
- echo "DBUSER is invalid SSO user"
- exit "$E_INVALID"
- fi
- # Perform verification if read-only mode is enabled
- check_hestia_demo_mode
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Get database values
- get_database_values
- delete_mysql_database_temp_user
- #----------------------------------------------------------#
- # Hestia #
- #----------------------------------------------------------#
- # Logging
- $BIN/v-log-action "$user" "Info" "Database" "Revoked user access (Database: $database, User: $dbuser)."
- log_event "$OK" "$ARGUMENTS"
- exit
|