| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #!/bin/bash
- # info: change phpmyadmin/phppgadmin alias url
- # options: TYPE ALIAS
- # labels: hestia
- #
- # example: v-change-sys-db-alias pma phpmyadmin
- # # Sets phpMyAdmin alias to phpmyadmin
- #
- # example: v-change-sys-db-alias pga phppgadmin
- # # Sets phpPgAdmin alias to phppgadmin
- #
- # This function changes the database editor url in
- # apache2 or nginx configuration.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument definition
- type=$1
- alias=$2
- # 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
- # load config file
- source_conf "$HESTIA/conf/hestia.conf"
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- check_args '2' "$#" 'type alias'
- is_common_format_valid "$alias" "Alias"
- # Perform verification if read-only mode is enabled
- check_hestia_demo_mode
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Detect common allowed entries for phpMyAdmin
- if [ "$type" = "pma" ] || [ "$type" = "PMA" ] || [ "$type" = "phpmyadmin" ]; then
- # Set database editor friendly name
- db_editor="phpMyAdmin"
- # Set new alias value
- $BIN/v-change-sys-config-value 'DB_PMA_ALIAS' "$alias"
- # Replace old configuration files and update alias
- if [ -e "/etc/apache2/conf.d/phpmyadmin.inc" ]; then
- rm -f /etc/apache2/conf.d/phpmyadmin.inc
- cp -f $HESTIA_INSTALL_DIR/pma/apache.conf /etc/apache2/conf.d/phpmyadmin.inc
- sed -i "s|%pma_alias%|$alias|g" /etc/apache2/conf.d/phpmyadmin.inc
-
- # Restart services
- $HESTIA/bin/v-restart-service apache2
- fi
- if [ -e "/etc/nginx/conf.d/phpmyadmin.inc" ]; then
- rm -f /etc/nginx/conf.d/phpmyadmin.inc
- cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/phpmyadmin.inc
- sed -i "s|%pma_alias%|$alias|g" /etc/nginx/conf.d/phpmyadmin.inc
-
- # Restart services
- $HESTIA/bin/v-restart-service nginx
- fi
- fi
- # Detect common allowed entries for phpPgAdmin
- if [ "$type" = "pga" ] || [ "$type" = "PGA" ] || [ "$type" = "phppgadmin" ]; then
- # Set database editor friendly name
- db_editor="phpPgAdmin"
- # Set new alias value
- $BIN/v-change-sys-config-value 'DB_PGA_ALIAS' "$alias"
- # Replace old configuration files and update alias
- if [ -e "/etc/apache2/conf.d/phppgadmin.inc" ]; then
- rm -f /etc/apache2/conf.d/phppgadmin.inc
- cp -f $HESTIA_INSTALL_DIR/pga/phppgadmin.conf /etc/apache2/conf.d/phppgadmin.inc
- sed -i "s|%pga_alias%|$alias|g" /etc/apache2/conf.d/phppgadmin.inc
-
- # Restart services
- $HESTIA/bin/v-restart-service apache2
- fi
- if [ -e "/etc/nginx/conf.d/phppgadmin.inc" ]; then
- rm -f /etc/nginx/conf.d/phppgadmin.inc
- cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/phppgadmin.inc
- sed -i "s|%pga_alias%|$alias|g" /etc/nginx/conf.d/phppgadmin.inc
-
- # Restart services
- $HESTIA/bin/v-restart-service nginx
- fi
- fi
- #----------------------------------------------------------#
- # Hestia #
- #----------------------------------------------------------#
- # Logging
- $BIN/v-log-action "system" "Info" "System" "System access alias changed (Tool: $db_editor, Alias: $alias)."
- log_event "$OK" "$ARGUMENTS"
- exit
|