#! /usr/bin/env sh mkdir -p "$HOME/.config/systemd/user/" cp MatrixAntiDmSpam@.service "$HOME/.config/systemd/user/MatrixAntiDmSpam@.service" if [ ! -d "$HOME/.config/MatrixAntiDmSpam" ]; then mkdir -p "$HOME/.config/MatrixAntiDmSpam" cp -v MatrixAntiDmSpam/appsettings.Development.json "$HOME/.config/MatrixAntiDmSpam/appsettings.Template.json" echo "Please copy and edit the template configuration to your liking." echo "The template is located at $HOME/.config/MatrixAntiDmSpam/appsettings.Template.json" echo "Please rename it to appsettings.{profile}.json." echo "Once you have done so, re-run this script, and you will find the services named as 'MatrixAntiDmSpam@{profile}.service'" exit fi cp MatrixAntiDmSpam@.service "$HOME/.config/systemd/user/MatrixAntiDmSpam@.service" find "$HOME/.config/MatrixAntiDmSpam" -maxdepth 1 -type f | while read -r line; do # enable unit name="$(basename "$line")" environmentName="$(echo "$name" | cut -d'.' -f2)" echo "Found environment ${environmentName}: $line" if [ "$environmentName" = "Template" ] || [ "$environmentName" = ".json" ]; then echo "Skipping template file ${name}" continue fi systemctl --user daemon-reload systemctl --user enable "MatrixAntiDmSpam@${environmentName}" systemctl --user restart "MatrixAntiDmSpam@${environmentName}" done