forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-sys-pma
More file actions
executable file
·84 lines (63 loc) · 2.66 KB
/
v-change-sys-pma
File metadata and controls
executable file
·84 lines (63 loc) · 2.66 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# info: change phpmyadmin alias url
# options: PMA
#
# This function changes the phpmyadmin url in apache2 or nginx configuration.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
PMA=$1
# Includes
source $HESTIA/func/main.sh
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'PMA'
# Check if string has leading /
if [[ ! ${PMA:0:1} == "/" ]]; then
PMA="/$PMA"
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get existing apache2 pma alias
if [ -f /etc/apache2/conf.d/phpmyadmin.conf ]; then
apache_pma=$(cat /etc/apache2/conf.d/phpmyadmin.conf | grep "Alias" | { IFS=' '; read -r -a array; echo "${array[1]}"; })
fi
# Get existing nginx pma alias
if [ -f /etc/nginx/conf.d/phpmyadmin.inc ]; then
nginx_pma=$(cat /etc/nginx/conf.d/phpmyadmin.inc | grep "location" | { IFS=' '; read -r -a array; echo "${array[1]}"; })
fi
# Check if alias is different for apache2
if [ ! -z "$apache_pma" ]; then
if [ ! "$apache_pma" = "$PMA" ]; then
# Replace pma alias in config files.
sed -i "s|Alias $apache_pma|Alias $PMA|" /etc/apache2/conf.d/phpmyadmin.conf
# Replace in Backend UI
sed -i "s|$apache_pma/|$PMA/|" /usr/local/hestia/web/templates/admin/list_db.html
sed -i "s|$apache_pma/|$PMA/|" /usr/local/hestia/web/templates/user/list_db.html
# Restart services
$HESTIA/bin/v-restart-service apache2
fi
fi
# Check if alias is different for nginx
if [ ! -z "$nginx_pma" ]; then
if [ ! "$nginx_pma" = "$PMA" ]; then
# Replace pma alias in config files.
sed -i "s|$nginx_pma|$PMA|" /etc/nginx/conf.d/phpmyadmin.inc
sed -i "s|/usr/share$PMA|/usr/share/phpmyadmin|" /etc/nginx/conf.d/phpmyadmin.inc
# Replace in Backend UI
sed -i "s|$nginx_pma/|$PMA/|" /usr/local/hestia/web/templates/admin/list_db.html
sed -i "s|$nginx_pma/|$PMA/|" /usr/local/hestia/web/templates/user/list_db.html
# Restart services
$HESTIA/bin/v-restart-service nginx
fi
fi
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
#log_event "$OK" "$ARGUMENTS"
exit