Skip to content

Commit b044109

Browse files
committed
fix(helpers,update.sh): add helpers file to the root and edited update script to import it in target folders/images
Signed-off-by: lordrobincbz <[email protected]>
1 parent 0e85faf commit b044109

File tree

6 files changed

+53
-9
lines changed

6 files changed

+53
-9
lines changed

apache/config.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
require '/etc/phpmyadmin/config.secret.inc.php';
4-
require '/etc/phpmyadmin/helpers.php';
3+
require_once '/etc/phpmyadmin/config.secret.inc.php';
4+
require_once '/etc/phpmyadmin/helpers.php';
55

66
/* Ensure we got the environment */
77
$vars = [

config.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
require '/etc/phpmyadmin/config.secret.inc.php';
4-
require '/etc/phpmyadmin/helpers.php';
3+
require_once '/etc/phpmyadmin/config.secret.inc.php';
4+
require_once '/etc/phpmyadmin/helpers.php';
55

66
/* Ensure we got the environment */
77
$vars = [

fpm-alpine/config.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
require '/etc/phpmyadmin/config.secret.inc.php';
4-
require '/etc/phpmyadmin/helpers.php';
3+
require_once '/etc/phpmyadmin/config.secret.inc.php';
4+
require_once '/etc/phpmyadmin/helpers.php';
55

66
/* Ensure we got the environment */
77
$vars = [

fpm/config.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
require '/etc/phpmyadmin/config.secret.inc.php';
4-
require '/etc/phpmyadmin/helpers.php';
3+
require_once '/etc/phpmyadmin/config.secret.inc.php';
4+
require_once '/etc/phpmyadmin/helpers.php';
55

66
/* Ensure we got the environment */
77
$vars = [

helpers.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
4+
define('PMA_SSL_DIR', $_ENV['PMA_SSL_DIR'] ?? '/etc/phpmyadmin/ssl');
5+
6+
/**
7+
* Helper function to decode and save multiple SSL files from base64.
8+
*
9+
* @param string $base64_string The base64 encoded string containing multiple SSL files separated by commas.
10+
* If no commas are present, the entire string is treated as a single file.
11+
* @param string $prefix The prefix to use for the generated SSL file names.
12+
* @param string $extension The file extension to use for the generated SSL files.
13+
* @return string A comma-separated list of paths to the generated SSL files.
14+
*/
15+
function decodeAndSaveSslFiles(string $base64_string, string $prefix, string $extension): array {
16+
// Ensure the output directory exists
17+
if (!is_dir(PMA_SSL_DIR)) {
18+
mkdir(PMA_SSL_DIR, 0755, true);
19+
}
20+
21+
// Split the base64 string into an array of files
22+
$files = strpos($base64_string, ',') !== false ? explode(',', $base64_string) : [$base64_string];
23+
$counter = 1;
24+
$ssl_files = [];
25+
26+
// Process each file
27+
foreach ($files as $file) {
28+
$output_file = PMA_SSL_DIR . "/pma-ssl-$prefix-$counter.$extension";
29+
30+
// Write the decoded file to the output directory
31+
if (file_put_contents($output_file, base64_decode($file)) === false) {
32+
echo 'Failed to write to ' . $output_file;
33+
exit(1);
34+
}
35+
36+
// Add the output file path to the list
37+
$ssl_files[] = $output_file;
38+
$counter++;
39+
}
40+
41+
// Return a comma-separated list of the generated file paths
42+
return implode(',', $ssl_files);
43+
}

update.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ function create_variant() {
6767
sed -i "/^\s*# start: Apache specific build$/,/^\s*# end: Apache specific build$/d" "$variant/Dockerfile"
6868
fi
6969

70-
# Copy config.inc.php
70+
# Copy config.inc.php and helpers.php
7171
cp config.inc.php "$variant/config.inc.php"
72+
cp helpers.php "$variant/helpers.php"
7273

7374
# Add variant to versions.json
7475
versionVariantsJson="$(jq -e \

0 commit comments

Comments
 (0)