Browse Source

Add a script to install SMF packages into the image.

mw_31
Adrian Malacoda 7 months ago
parent
commit
2d417f433d
2 changed files with 56 additions and 0 deletions
  1. 4
    0
      Dockerfile
  2. 52
    0
      scripts/add_mod.php

+ 4
- 0
Dockerfile View File

@@ -42,6 +42,10 @@ RUN /scripts/add_extension.sh FlaggedRevs $MW_VERSION && \
42 42
     /scripts/add_extension.sh Nuke $MW_VERSION && \
43 43
     /scripts/add_extension.sh Auth_remoteuser $MW_VERSION
44 44
 
45
+# Install SMF mods
46
+# 3 September 2018: These would also need to be installed in the database.
47
+RUN /scripts/add_mod.php "http://custom.simplemachines.org/mods/index.php?action=download;mod=3067;id=179832"
48
+
45 49
 # Add our stuff
46 50
 ADD --chown=www-data:www-data application application
47 51
 RUN cd $WIKI_SOURCE && composer update --no-dev

+ 52
- 0
scripts/add_mod.php View File

@@ -0,0 +1,52 @@
1
+#!/usr/bin/env php
2
+<?php
3
+define("SMF", true);
4
+$boarddir = getenv("FORUMS_SOURCE");
5
+$sourcedir = "$boarddir/Sources";
6
+$forum_version = "SMF " . getenv("SMF_VERSION");
7
+
8
+$temp_dir = "$boarddir/Packages/temp";
9
+
10
+require_once("$sourcedir/Errors.php");
11
+require_once("$sourcedir/QueryString.php");
12
+require_once("$sourcedir/Subs.php");
13
+require_once("$sourcedir/Subs-Package.php");
14
+
15
+function loadLanguage($language) {}
16
+
17
+function download($uri) {
18
+    $entries = scandir(".");
19
+    passthru("wget --content-disposition \"$uri\"");
20
+    return array_values(array_diff(scandir("."), $entries))[0];
21
+}
22
+
23
+function downloadPackage($packageUrl) {
24
+    global $boarddir;
25
+    $packageFile = download($packageUrl);
26
+    $fullPackageName = "$boarddir/Packages/$packageFile";
27
+    rename($packageFile, $fullPackageName);
28
+    return $packageFile;
29
+}
30
+
31
+function unpackPackage($packageFile) {
32
+    global $boarddir, $temp_dir;
33
+    $fullPackageName = "$boarddir/Packages/$packageFile";
34
+    mktree($temp_dir, 0777);
35
+    read_tgz_file($fullPackageName, $temp_dir);
36
+}
37
+
38
+function installPackage($packageFile) {
39
+    $packageInfo = getPackageInfo($packageFile);
40
+    return parsePackageInfo($packageInfo['xml'], false);
41
+}
42
+
43
+function cleanup() {
44
+    global $temp_dir;
45
+    deltree($temp_dir);
46
+}
47
+
48
+$packageUrl = $argv[1];
49
+$packageFile = downloadPackage($packageUrl);
50
+unpackPackage($packageFile);
51
+installPackage($packageFile);
52
+cleanup();

Loading…
Cancel
Save