Compare commits

...

1 Commits

Author SHA1 Message Date
push-app-to-main[bot]
a23f908aa1 Add matomo (ct) 2026-05-04 17:26:24 +00:00
3 changed files with 162 additions and 0 deletions

6
ct/headers/matomo Normal file
View File

@@ -0,0 +1,6 @@
__ ___ __
/ |/ /___ _/ /_____ ____ ___ ____
/ /|_/ / __ `/ __/ __ \/ __ `__ \/ __ \
/ / / / /_/ / /_/ /_/ / / / / / / /_/ /
/_/ /_/\__,_/\__/\____/_/ /_/ /_/\____/

90
ct/matomo.sh Normal file
View File

@@ -0,0 +1,90 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://matomo.org/
APP="Matomo"
var_tags="${var_tags:-analytics;tracking;privacy}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-16}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function flatten_matomo_layout() {
if [[ -d /opt/matomo/matomo ]]; then
msg_info "Migrating Legacy Layout"
rm -rf /opt/matomo/tmp "/opt/matomo/How to install Matomo.html"
find /opt/matomo/matomo -mindepth 1 -maxdepth 1 -exec mv -t /opt/matomo {} +
rm -rf /opt/matomo/matomo
msg_ok "Migrated Legacy Layout"
fi
}
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/matomo ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "matomo" "matomo-org/matomo"; then
msg_info "Stopping Services"
systemctl stop caddy
msg_ok "Stopped Services"
flatten_matomo_layout
msg_info "Backing up Data"
[[ -f /opt/matomo/config/config.ini.php ]] && cp /opt/matomo/config/config.ini.php /opt/matomo_config.bak
[[ -d /opt/matomo/misc/user ]] && cp -r /opt/matomo/misc/user /opt/matomo_user_backup
[[ -f /root/matomo.creds ]] && cp /root/matomo.creds /opt/matomo_db_creds.bak
msg_ok "Backed up Data"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "matomo" "matomo-org/matomo" "prebuild" "latest" "/opt/matomo" "matomo-*.zip"
flatten_matomo_layout
msg_info "Restoring Data"
if [[ -f /opt/matomo_config.bak ]]; then
mkdir -p /opt/matomo/config
cp /opt/matomo_config.bak /opt/matomo/config/config.ini.php
fi
if [[ -d /opt/matomo_user_backup ]]; then
mkdir -p /opt/matomo/misc/user
cp -r /opt/matomo_user_backup/. /opt/matomo/misc/user
fi
[[ -f /opt/matomo_db_creds.bak ]] && cp /opt/matomo_db_creds.bak /root/matomo.creds
rm -f /opt/matomo_config.bak /opt/matomo_db_creds.bak
rm -rf /opt/matomo_user_backup
chown -R www-data:www-data /opt/matomo
msg_ok "Restored Data"
msg_info "Starting Services"
systemctl start caddy
msg_ok "Started Services"
msg_ok "Updated successfully!"
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

66
install/matomo-install.sh Normal file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://matomo.org/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y caddy
msg_ok "Installed Dependencies"
mkdir -p /opt/matomo
PHP_VERSION="8.3" PHP_FPM="YES" PHP_MODULES="pdo_mysql,gd,mbstring,xml,curl,intl,zip,ldap" setup_php
setup_mariadb
MARIADB_DB_NAME="matomo" MARIADB_DB_USER="matomo" setup_mariadb_db
msg_info "Allowing Local TCP Database Access"
$STD mariadb -u root -e "CREATE USER IF NOT EXISTS '$MARIADB_DB_USER'@'127.0.0.1' IDENTIFIED BY '$MARIADB_DB_PASS';"
$STD mariadb -u root -e "ALTER USER '$MARIADB_DB_USER'@'127.0.0.1' IDENTIFIED BY '$MARIADB_DB_PASS';"
$STD mariadb -u root -e "GRANT ALL ON \`$MARIADB_DB_NAME\`.* TO '$MARIADB_DB_USER'@'127.0.0.1';"
$STD mariadb -u root -e "FLUSH PRIVILEGES;"
msg_ok "Allowed Local TCP Database Access"
fetch_and_deploy_gh_release "matomo" "matomo-org/matomo" "prebuild" "latest" "/opt/matomo" "matomo-*.zip"
msg_info "Setting up Matomo"
if [[ -d /opt/matomo/matomo ]]; then
rm -rf /opt/matomo/tmp "/opt/matomo/How to install Matomo.html"
find /opt/matomo/matomo -mindepth 1 -maxdepth 1 -exec mv -t /opt/matomo {} +
rm -rf /opt/matomo/matomo
fi
mkdir -p /opt/matomo/tmp
chown -R www-data:www-data /opt/matomo
chmod -R 755 /opt/matomo/tmp
msg_ok "Set up Matomo"
msg_info "Configuring Caddy"
PHP_VER=$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;')
cat <<EOF >/etc/caddy/Caddyfile
:80 {
root * /opt/matomo
@blocked path /config /config/* /tmp /tmp/* /.* /.*/*
respond @blocked 403
php_fastcgi unix//run/php/php${PHP_VER}-fpm.sock
file_server
encode gzip
}
EOF
usermod -aG www-data caddy
msg_ok "Configured Caddy"
systemctl enable -q --now php${PHP_VER}-fpm
systemctl restart caddy
motd_ssh
customize
cleanup_lxc