about summary refs log tree commit diff
path: root/install-user-units.sh
diff options
context:
space:
mode:
Diffstat (limited to 'install-user-units.sh')
-rwxr-xr-xinstall-user-units.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/install-user-units.sh b/install-user-units.sh
new file mode 100755

index 0000000..b84f53a --- /dev/null +++ b/install-user-units.sh
@@ -0,0 +1,33 @@ +#! /usr/bin/env sh + + +mkdir -p "$HOME/.config/systemd/user/" +cp MiniUtils@.service "$HOME/.config/systemd/user/MiniUtils@.service" + +if [ ! -d "$HOME/.config/MiniUtils" ]; then + mkdir -p "$HOME/.config/MiniUtils" + cp -v MiniUtils/appsettings.Development.json "$HOME/.config/MiniUtils/appsettings.Template.json" + echo "Please copy and edit the template configuration to your liking." + echo "The template is located at $HOME/.config/MiniUtils/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 'MiniUtils@{profile}.service'" + exit +fi + +cp MiniUtils@.service "$HOME/.config/systemd/user/MiniUtils@.service" +find "$HOME/.config/MiniUtils" -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 "MiniUtils@${environmentName}" + systemctl --user restart "MiniUtils@${environmentName}" +done