forked from skurudo/phpmyadmin-fixer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpma-ubuntu.sh
189 lines (176 loc) · 7.71 KB
/
pma-ubuntu.sh
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/bash
#
# phpmyadmin-fixer
#
# Fixes for phpmyadmin (configuration storage and some extended features)
#
# If you're tired from message - "The phpMyAdmin configuration storage
# is not completely configured, some extended features have been deactivated",
# this patch for you ;-)
#
#
# https://github.com/skurudo/phpmyadmin-fixer
# Author - Pavel Galkin (https://skurudo.ru)
#
# Code for check curl/wget
# by Serghey Rodin (https://vestacp.com) from (https://github.com/serghey-rodin/vesta/)
#
# ...
#
echo "Phpmyadmin fixes for configuration storage and some extended features";
echo "................";
echo "Let's do it";
echo "............";
echo "..........";
echo ".........";
echo "........";
echo "......";
echo "Generate password for PMA (pma.txt)";
PASS=`tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32 ; echo`
echo "PMA Password = $PASS";
#debian phpmyadmin path
pmapath1="/etc/phpmyadmin/config.inc.php"
pmapath2="/usr/share/phpmyadmin/config.sample.inc.php"
cp $pmapath1 /root/config.inc.php.old
cp $pmapath2 /root/config.inc.php.old2
#delete old and paste new value
sed -i '/pmadb/d' $pmapath1
sed -i '/controluser/d' $pmapath1
sed -i '/bookmarktable/d' $pmapath1
sed -i '/relation/d' $pmapath1
sed -i '/userconfig/d' $pmapath1
sed -i '/table_info/d' $pmapath1
sed -i '/column_info/d' $pmapath1
sed -i '/history/d' $pmapath1
sed -i '/recent/d' $pmapath1
sed -i '/table_uiprefs/d' $pmapath1
sed -i '/tracking/d' $pmapath1
sed -i '/table_coords/d' $pmapath1
sed -i '/pdf_pages/d' $pmapath1
sed -i '/designer_coords/d' $pmapath1
sed -i '/controlpass/d' $pmapath1
sed -i '/\$i = 1; /d' $pmapath1
echo "\$i = 1;" >> $pmapath1
sed -i '/savedsearches/d' $pmapath1
sed -i '/navigationhiding/d' $pmapath1
sed -i '/users/d' $pmapath1
sed -i '/controlpass/d' $pmapath1
sed -i '/favorite/d' $pmapath1
sed -i '/usergroups/d' $pmapath1
sed -i '/central_columns/d' $pmapath1
sed -i '/designer_settings/d' $pmapath1
sed -i '/export_templates/d' $pmapath1
echo "\$cfg['Servers'][\$i]['favorite'] = 'pma__favorite';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['central_columns'] = 'pma__central_columns';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['designer_settings'] = 'pma__designer_settings';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['export_templates'] = 'pma__export_templates';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['savedsearches'] = 'pma__savedsearches';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['navigationhiding'] = 'pma__navigationhiding';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['users'] = 'pma__users';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['pmadb'] = 'phpmyadmin';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['controluser'] = 'pma';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['controlpass'] = '$PASS';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['bookmarktable'] = 'pma__bookmark';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['relation'] = 'pma__relation';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['userconfig'] = 'pma__userconfig';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['table_info'] = 'pma__table_info';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['column_info'] = 'pma__column_info';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['history'] = 'pma__history';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['recent'] = 'pma__recent';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['table_uiprefs'] = 'pma__table_uiprefs';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['tracking'] = 'pma__tracking';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['table_coords'] = 'pma__table_coords';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['pdf_pages'] = 'pma__pdf_pages';" >> $pmapath1
echo "\$cfg['Servers'][\$i]['designer_coords'] = 'pma__designer_coords';" >> $pmapath1
sed -i '/pmadb/d' $pmapath2
sed -i '/controluser/d' $pmapath2
sed -i '/bookmarktable/d' $pmapath2
sed -i '/relation/d' $pmapath2
sed -i '/userconfig/d' $pmapath2
sed -i '/table_info/d' $pmapath2
sed -i '/column_info/d' $pmapath2
sed -i '/history/d' $pmapath2
sed -i '/recent/d' $pmapath2
sed -i '/table_uiprefs/d' $pmapath2
sed -i '/tracking/d' $pmapath2
sed -i '/table_coords/d' $pmapath2
sed -i '/pdf_pages/d' $pmapath2
sed -i '/designer_coords/d' $pmapath2
sed -i '/controlpass/d' $pmapath2
sed -i '/savedsearches/d' $pmapath2
sed -i '/navigationhiding/d' $pmapath2
sed -i '/users/d' $pmapath2
sed -i '/controlpass/d' $pmapath2
sed -i '/favorite/d' $pmapath2
sed -i '/usergroups/d' $pmapath2
sed -i '/central_columns/d' $pmapath2
sed -i '/designer_settings/d' $pmapath2
sed -i '/export_templates/d' $pmapath2
echo "\$cfg['Servers'][\$i]['favorite'] = 'pma__favorite';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['central_columns'] = 'pma__central_columns';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['designer_settings'] = 'pma__designer_settings';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['export_templates'] = 'pma__export_templates';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['savedsearches'] = 'pma__savedsearches';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['navigationhiding'] = 'pma__navigationhiding';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['users'] = 'pma__users';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['pmadb'] = 'phpmyadmin';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['controluser'] = 'pma';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['controlpass'] = '$PASS';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['bookmarktable'] = 'pma__bookmark';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['relation'] = 'pma__relation';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['userconfig'] = 'pma__userconfig';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['table_info'] = 'pma__table_info';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['column_info'] = 'pma__column_info';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['history'] = 'pma__history';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['recent'] = 'pma__recent';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['table_uiprefs'] = 'pma__table_uiprefs';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['tracking'] = 'pma__tracking';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['table_coords'] = 'pma__table_coords';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['pdf_pages'] = 'pma__pdf_pages';" >> $pmapath2
echo "\$cfg['Servers'][\$i]['designer_coords'] = 'pma__designer_coords';" >> $pmapath2
#SOME WORK with DATABASE (table / user)
PMADB=phpmyadmin
PMAUSER=pma
#DROP USER and TABLE
mysql -u root -p <<MYSQL_PMA1
DROP USER '$PMAUSER'@'localhost';
DROP DATABASE $PMADB;
FLUSH PRIVILEGES;
MYSQL_PMA1
#CREATE PMA USER
mysql -u root -p <<MYSQL_PMA2
CREATE USER '$PMAUSER'@'localhost' IDENTIFIED BY '$PASS';
CREATE DATABASE $PMADB;
MYSQL_PMA2
#GRANT PMA USE SOME RIGHTS
mysql -u root -p <<MYSQL_PMA3
USE $PMADB;
GRANT USAGE ON $PMADB.* TO '$PMAUSER'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $PMADB.* TO '$PMAUSER'@'localhost';
FLUSH PRIVILEGES;
MYSQL_PMA3
#MYSQL DB and TABLES ADDITION
echo "Download tables for our mysql server";
wget --no-check-certificate https://raw.githubusercontent.com/skurudo/phpmyadmin-fixer/master/create_tables.sql;
# Check wget
if [ -e '/usr/bin/wget' ]; then
echo "Download via wget" &&
wget --no-check-certificate https://raw.githubusercontent.com/skurudo/phpmyadmin-fixer/master/create_tables.sql;
else
echo "Error: download via wget failed"
fi
# Check curl
if [ -e '/usr/bin/curl' ]; then
echo "Download via curl" &&
curl -O -k https://raw.githubusercontent.com/skurudo/phpmyadmin-fixer/master/create_tables.sql;
else
echo "Error: download via curl failed."
fi
mysql -u root -p < create_tables.sql
echo "Delete temp files";
rm create_tables.sql*
echo "pma@localhost user password = $PASS" > pma.txt