Skip to content

Commit e5d296d

Browse files
authored
Merge pull request #27 from MITLibraries/INFRA-558
Add SearchEngineKeywordsPerformance Premium Plugin
2 parents 30dc127 + e6764e9 commit e5d296d

File tree

920 files changed

+139711
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

920 files changed

+139711
-22
lines changed

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ COPY ./files/plugin-EnvironmentVariables-5.0.3/ /var/www/html/plugins/Environmen
99
COPY ./files/plugin-CustomVariables-5.0.4/ /var/www/html/plugins/CustomVariables
1010

1111
# Add the HeatmapSessionRecording plugin
12-
COPY ./files/plugin-HeatmapSessionRecording-5.2.3/ /var/www/html/plugins/HeatmapSessionRecording
12+
COPY ./files/plugin-HeatmapSessionRecording-5.2.4/ /var/www/html/plugins/HeatmapSessionRecording
1313

1414
# Add the UsersFlow plugin
1515
COPY ./files/plugin-UsersFlow-5.0.5/ /var/www/html/plugins/UsersFlow
1616

17-
# Our custom configuration settings. We put it in /usr/src because the
18-
# entrypoint.sh builds the /var/www/html folder from the /usr/src/matomo
19-
# folder. This ensures that the config file from our updated container is the
20-
# one that is pushed to the persistent EFS storage.
21-
COPY ./files/config.ini.php /usr/src/matomo/config/config.ini.php
17+
# Add the SearchEngineKeywordsPerformance plugin
18+
COPY ./files/plugin-SearchEngineKeywordsPerformance-5.0.22/ /var/www/html/plugins/SearchEngineKeywordsPerformance
19+
20+
# Our custom configuration settings.
21+
COPY ./files/config.ini.php /var/www/html/config/config.ini.php
2222

2323
# The HeatmapSessionRecording and UsersFlow update the matomo.js and piwik.js
2424
# files when they are activated. Those updates have been captured and we

docs/HowTos/HOWTO-miscellaneous.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ To retrieve the **task number** value for the command:
3434
OR
3535

3636
```bash
37-
aws ecs list-clusters --output text | grep matomo | cut -d'/' -f2
38-
aws ecs list-tasks --cluster $(aws ecs list-clusters --output text | grep matomo | cut -d'/' -f2) --query "taskArns[*]" --output text | cut -d'/' -f3
37+
aws ecs execute-command --region us-east-1 --cluster $(aws ecs list-clusters --output text | grep matomo | cut -d'/' -f2) --task $(aws ecs list-tasks --cluster $(aws ecs list-clusters --output text | grep matomo | cut -d'/' -f2) --query "taskArns[*]" --output text | cut -d'/' -f3) --command "/bin/bash" --interactive
38+
```
39+
40+
If you need to force a redeployment of the task for the service, this one-liner will work:
41+
42+
```bash
43+
aws ecs update-service --cluster $(aws ecs list-clusters --output text | grep matomo | cut -d'/' -f2) --service $(aws ecs list-services --cluster $(aws ecs list-clusters --output text | grep matomo | cut -d'/' -f2) --output text | grep matomo | cut -d'/' -f3) --force-new-deployment
3944
```
4045

4146
## Reset 2-Factor auth

docs/HowTos/HOWTO-premium-plugins.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ After some initial testing in Dev1, it's not as simple as just dumping the new p
88
1. Some plugins require changes to the database tables or just new tables. This requires that the plugin installation process is triggered to kick off the script that updates the tables.
99
1. The *Marketplace* plugin must be active for license keys to work.
1010

11-
## The config.ini.php file
11+
## A note about the config.ini.php file
1212

1313
The `config.ini.php` file has two lists of plugins under two different headings.
1414

@@ -22,28 +22,30 @@ In the end, the premium plugin installation is a two-pass process.
2222

2323
### High level overview
2424

25-
1. Install license key (via UI or CLI) so that it is in the database.
26-
2. Go through a dev -> stage -> prod deployment cycle of the container to install the plugin folder(s) into the container.
25+
1. Install license key (via UI or CLI) so that it is in the database (this apparently only needs to be done once as all future premium plugins get linked to the same license key).
26+
2. Go through a dev -> stage -> prod deployment cycle of the container to install the plugin folder(s) into the container
2727
3. Activate the new plugin(s) (via UI or CLI) so that any database changes are properly executed.
2828
4. Go through a dev -> stage -> prod deployment cycle of the container to match the updated `config.ini.php` file on the server.
2929

3030
### Details for each step
3131

3232
#### 1. Install the license key
3333

34-
Before installing the license key, the *Marketplace* plugin must be activated. This is a one-time update to the `config.ini.php` file to add the *Marketplace* pluging to the `[Plugins]` section.
34+
Before installing the license key, the *Marketplace* plugin must be activated. This is a one-time update to the `config.ini.php` file to add the *Marketplace* pluging to the `[Plugins]` section - all new premium plugin purchases are linked to the same license key.
3535

3636
According to the support team at Matomo, the premium license key can be installed in two instances of Matomo, "stage" and "prod." So, we can do some initial validation of a license key in Dev1, but the key cannot remain installed in the Dev1 instance. The license key installation can either be done by a user with "superuser" privileges in the Matomo web UI or it can be done by a member of InfraEng who has ssh access to the running container task/service. The CLI command is
3737

3838
```bash
3939
./console marketplace:set-license-key --license-key=LICENSE-KEY "<key>"
4040
```
4141

42-
This needs to be done on each of the stage & prod instances of Matomo.
42+
This needs to be done once on each of the stage & prod instances of Matomo.
4343

4444
#### 2. Install the plugin files
4545

46-
In this phase, the files are installed in the container *but no changes are made to the `config.ini.php` file. This will **not** activate the plugins, it will just make them visible in the UI.
46+
In this phase, the files are installed in the container **but** no changes are made to the `config.ini.php` file. This will **not** activate the plugins, it will just make them visible in the UI.
47+
48+
**Note**: It is possible to do this with the `/var/www/html/console` utility when logged in to the cli of the running conatiner. However, that method introduces potential file permission errors since the command is run as `root` and the content in the `/var/www/html` folder needs to be owned by `www-data`.
4749

4850
#### 3. Activate the plugin
4951

@@ -53,7 +55,9 @@ Once the plugin files are installed in the container, it's time to activate the
5355
./console plugin:activate [<plugin>...]
5456
```
5557

56-
This will change the `config.ini.php` file on the container. It is **very** important to capture these changes and put them back in the `config.ini.php` in the container (see step 4).
58+
This will change the `config/config.ini.php` file -- which is actually persisted on the EFS filesystem linked to the container. It is important to capture any changes that happen in this file so that we can back-fill this repository in case we need to redeploy in a DR scenario.
59+
60+
It's also important to note that this `plugin:activate` command very likely makes changes to the database (adding/removing tables/columns or other changes).
5761

5862
#### 4. Backfill this repo
5963

files/backup-data.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
#!/bin/bash
22

3-
target_dir="/mnt/efs"
3+
# Define source directories
4+
source_dirs=(
5+
"/var/www/html/config"
6+
"/var/www/html/misc"
7+
"/var/www/html/js"
8+
)
49

5-
mkdir -p "$target_dir/config"
6-
tar -cf - -C "/var/www/html/config" . | tar -xf - -C "$target_dir/config"
10+
# Define target directory
11+
target_dir="/mnt/efs/backups"
712

8-
mkdir -p "$target_dir/misc"
9-
tar -cf - -C "/var/www/html/misc" . | tar -xf - -C "$target_dir/misc"
13+
# Loop through each source directory and duplicate it to the target directory
14+
for src in "${source_dirs[@]}"; do
15+
# Extract the directory name from the source path
16+
dir_name=$(basename "$src")
17+
18+
# Create the target directory if it doesn't exist
19+
mkdir -p "$target_dir/$dir_name"
20+
21+
# Use tar to duplicate the directory
22+
tar -cf - -C "$src" . | tar -xf - -C "$target_dir/$dir_name"
23+
done
1024

11-
mkdir -p "$target_dir/js"
12-
tar -cf - -C "/var/www/html/js" . | tar -xf - -C "$target_dir/js"
25+
echo "Directories have been successfully duplicated to $target_dir."
1326

1427
cp -a "/var/www/html/matomo.js" "$target_dir/matomo.js"
1528
cp -a "/var/www/html/piwik.js" "$target_dir/piwik.js"
29+
30+
# finally, make sure everything is www-data:www-data
31+
chown -R www-data:www-data "$target_dir"

0 commit comments

Comments
 (0)