diff --git a/bin/setup_matomo.sh b/bin/setup_matomo.sh index 20cd827..214d1ad 100644 --- a/bin/setup_matomo.sh +++ b/bin/setup_matomo.sh @@ -16,10 +16,16 @@ 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 '/<\/head>/i\'"$(cat $temp_matomo_script)"'' $index_file \ No newline at end of file +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 +tail -n +$line_number $index_file >> $tmp_file +mv $tmp_file $index_file +rm $tmp_file \ No newline at end of file