diff --git a/assets/matomo.html b/assets/matomo.html
new file mode 100644
index 0000000..d5101bc
--- /dev/null
+++ b/assets/matomo.html
@@ -0,0 +1,19 @@
+
+
+
\ No newline at end of file
diff --git a/bin/setup_directus.sh b/bin/setup_directus.sh
index 2a3192e..b9a2e82 100644
--- a/bin/setup_directus.sh
+++ b/bin/setup_directus.sh
@@ -52,6 +52,7 @@ npx directus users create --email \"${directus_admin_email}\" \
npx directus users create --email \"website@${DOMAIN_NAME}\" --password \"${website_password}\" --role \"${website_role_uuid}\"" www-data
WEBSITE_TOKEN=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
+
mariadb -u directus -p${DB_DIRECTUS_PASSWORD} -e \
"UPDATE directus.directus_roles SET icon='robot' WHERE name='Website'"
mariadb -u directus -p${DB_DIRECTUS_PASSWORD} -e \
diff --git a/bin/setup_matomo.sh b/bin/setup_matomo.sh
new file mode 100644
index 0000000..1a0f721
--- /dev/null
+++ b/bin/setup_matomo.sh
@@ -0,0 +1,27 @@
+#!/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 -s matomo_url
+echo -e "${PURPLE}${BOLD}Find the website ID at the following URL${RESET}"
+echo -e "${PURPLE}https://${matomo_url}/index.php?module=SitesManager${RESET}"
+echo -e "${PURPLE}${BOLD}Enter the Website ID :${RESET}"
+read -s matomo_website_id
+
+get_username
+
+temp_matomo_script = /home/$username/matomo.html
+index_file = /var/www/html/public/index.html
+
+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 '/<\/head>/i\'"$(cat $temp_matomo_script)"'' $index_file
+
+rm $temp_matomo_script
\ No newline at end of file
diff --git a/bin/setup_webhook.sh b/bin/setup_webhook.sh
index f111ff4..2e113d5 100644
--- a/bin/setup_webhook.sh
+++ b/bin/setup_webhook.sh
@@ -8,7 +8,7 @@ echo -e "${BLUE}${BOLD}Authorization Header ${RESET}${ORANGE}Generate a safe str
echo -e "${PURPLE}${BOLD}Enter the Authorization Header${RESET}"
read -s auth_header
-# check if the build flow already exists and get the auth header from there if so
+# TODO: check if the build flow already exists and get the auth header from there if so
install_pkg php
install_pkg php-fpm
@@ -47,7 +47,7 @@ if [[ -z "$DB_DIRECTUS_PASSWORD" ]]; then
echo
fi
-FLOW_EXISTS=$(echo $(mariadb -u directus -p${DB_DIRECTUS_PASSWORD} directus -e "SELECT COUNT(*) FROM directus_flows WHERE name='build';") | awk '{print $2}')
+flow_exists=$(echo $(mariadb -u directus -p${DB_DIRECTUS_PASSWORD} directus -e "SELECT COUNT(*) FROM directus_flows WHERE name='build';") | awk '{print $2}')
website_role_uuid=$(echo $(mariadb -u directus -p${DB_DIRECTUS_PASSWORD} \
-e "SELECT id FROM directus.directus_roles WHERE name='Website'") | awk '{print $2}')
@@ -55,9 +55,9 @@ website_role_uuid=$(echo $(mariadb -u directus -p${DB_DIRECTUS_PASSWORD} \
website_user_uuid=$(echo $(mariadb -u directus -p${DB_DIRECTUS_PASSWORD} \
-e "SELECT id FROM directus.directus_users WHERE role='${website_role_uuid}'") | awk '{print $2}')
-if [ $FLOW_EXISTS -eq 0 ]; then
- flow_id="fdd75914-80dd-44ac-9d62-c7a08bc9cae6"
- operation_id="371b1b41-312d-4df6-ab68-336b416e1f16"
+if [ $flow_exists -eq 0 ]; then
+ flow_id=$(uuidgen)
+ operation_id=$(uuidgen)
mariadb -u directus -p${DB_DIRECTUS_PASSWORD} directus -e \
"INSERT INTO directus_flows (id, name, icon, color, description, status, \`trigger\`, accountability, options, operation, user_created) \
diff --git a/install.sh b/install.sh
index e79e7ef..eab2fd1 100644
--- a/install.sh
+++ b/install.sh
@@ -10,6 +10,7 @@
## reboot a running system
## MATOMO
## NODE EXPORTER
+## setup webhook : get auth header
. bin/functions.sh
. bin/variables.sh
@@ -95,6 +96,12 @@ read answer
if [[ "$answer" == "y" ]]; then
. bin/install_nuxt_front.sh
+ echo -e "${PURPLE}${BOLD}Track with Matomo ? (y/N) ${RESET}"
+ read answer
+ if [[ "$answer" == "y" ]]; then
+ . bin/setup_matomo.sh
+ fi
+
echo -e "${PURPLE}${BOLD}Setup a webhook ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then