-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsystemd_setup.sh
More file actions
executable file
·29 lines (21 loc) · 1.03 KB
/
systemd_setup.sh
File metadata and controls
executable file
·29 lines (21 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
user_home=$HOME
script_path=$(realpath -s ./service/synchronizer_service.py)
script_directory=$(pwd)/service
escaped_user_home=$(echo "$user_home" | sed 's/[\/&]/\\&/g')
escaped_script_path=$(echo "$script_path" | sed 's/[\/&]/\\&/g')
escaped_script_directory=$(echo "$script_directory" | sed 's/[\/&]/\\&/g')
sed -i "s/user_home/$escaped_user_home/g" ./setup/dotfiles_synchronizer.service
sed -i "s/script_path/$escaped_script_path/g" ./setup/dotfiles_synchronizer.service
sed -i "s/script_directory/$escaped_script_directory/g" ./setup/dotfiles_synchronizer.service
cp ./setup/targets.json $HOME/.config/synchronization_targets.json
cp ./setup/dotfiles_synchronizer.service $HOME/.config/systemd/user
systemctl --user daemon-reload
read -p "Do you want to enable the daemon right away? (y/n): " answer
if [ "$answer" == "y" ]; then
systemctl --user start dotfiles_synchronizer
systemctl --user enable dotfiles_synchronizer
elif [ "$answer" != "n" ]; then
echo "Invalid input. Please enter 'y' or 'n'."
fi
rm -r setup systemd_setup.sh