deployment_dcdn_static/bin/setup_matomo.sh

21 lines
1.1 KiB
Bash

#!/bin/bash
echo -e "${PURPLE}${BOLD}Add a new website to track from the Matomo interface as an admin user${RESET}"
echo -e "${PURPLE}${BOLD}All website → Add a new Website → Website${RESET}"
echo -e "${PURPLE}${BOLD}Fill in the following informations :${RESET}"
echo -e "${BLUE}${BOLD}Website name : ${RESET}${BLUE}${DOMAIN_NAME}${RESET}"
echo -e "${BLUE}${BOLD}Urls : ${RESET}${BLUE}https://${DOMAIN_NAME}/${RESET}"
echo -e "${PURPLE}${BOLD}Enter the Matomo instance URL :${RESET}"
echo -e "${PURPLE} ie : matomo.example.com${RESET}"
read matomo_url
echo -e "${PURPLE}${BOLD}Find the website ID at the following URL${RESET}"
echo -e "${BLUE}https://${matomo_url}/index.php?module=SitesManager${RESET}"
echo -e "${PURPLE}${BOLD}Enter the Website ID :${RESET}"
read matomo_website_id
mkdir ${FRONT_DIRECTORY}/plugins
cp assets/matomo-plugin.client.js ${FRONT_DIRECTORY}/plugins
chown -R www-data:www-data ${FRONT_DIRECTORY}/plugins
sed -i "s/host: ''/host: 'https://$matomo_url'/" "$FRONT_DIRECTORY/plugins/matomo-plugin.client.js"
sed -i "s/siteId: 0/siteId: $matomo_website_id/" "$FRONT_DIRECTORY/plugins/matomo-plugin.client.js"