forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-sys-db-alias
More file actions
executable file
·106 lines (80 loc) · 3.45 KB
/
v-change-sys-db-alias
File metadata and controls
executable file
·106 lines (80 loc) · 3.45 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
# info: change phpmyadmin/phppgadmin alias url
# options: type alias
# 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
source $HESTIA/func/main.sh
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'type 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.conf" ]; then
rm -f /etc/apache2/conf.d/phpmyadmin.conf
cp -f $HESTIA_INSTALL_DIR/pma/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
sed -i "s|%pma_alias%|$alias|g" /etc/apache2/conf.d/phpmyadmin.conf
# 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.conf" ]; then
rm -f /etc/apache2/conf.d/phppgadmin.conf
cp -f $HESTIA_INSTALL_DIR/pga/phppgadmin.conf /etc/apache2/conf.d/phppgadmin.conf
sed -i "s|%pga_alias%|$alias|g" /etc/apache2/conf.d/phppgadmin.conf
# 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
log_history "changed $db_editor alias to $alias"
log_event "$OK" "$ARGUMENTS"
exit