#!/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}${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 get_username temp_matomo_script=/home/$username/matomo.html index_file=/var/www/html/public/index.html tmp_file=/home/$username/tmp_index cp assets/matomo.html $temp_matomo_script sed -i "s/var matomoSiteId = '';/var matomoSiteId = '$matomo_website_id';/g" $temp_matomo_script sed -i "s/var matomoInstanceUrl = '';/var matomoInstanceUrl = '$matomo_url';/g" $temp_matomo_script sed -i 's/<\/head>/\n<\/head>/' $index_file line_number=$(grep -n '' $index_file | cut -d':' -f1) head -n $(($line_number - 1)) $index_file > $tmp_file cat $temp_matomo_script >> $tmp_file tail -n +$line_number $index_file >> $tmp_file mv $tmp_file $index_file