Skip to content

Commit c02b4ec

Browse files
authored
Merge pull request #53 from andydna/andydna
don't overwrite systemd unit file if it already exists
2 parents f5e554a + f1197ab commit c02b4ec

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

scripts/handle_tmux_automatic_start/systemd_enable.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,27 @@ enable_tmux_unit_on_boot() {
4646
fi
4747
}
4848

49-
main() {
49+
systemd_unit_file() {
5050
local options="$(get_tmux_option "$auto_start_config_option" "${auto_start_config_default}")"
5151
local systemd_tmux_server_start_cmd="$(get_tmux_option "${systemd_tmux_server_start_cmd_option}" "${systemd_tmux_server_start_cmd_default}" )"
5252
local tmux_start_script_path="${CURRENT_DIR}/linux_start_tmux.sh"
5353
local systemd_unit_file=$(template "${tmux_start_script_path}" "${options}")
5454
mkdir -p "$(dirname ${systemd_unit_file_path})"
55-
echo "$systemd_unit_file" > "${systemd_unit_file_path}"
55+
echo "$systemd_unit_file"
56+
}
57+
58+
write_unit_file() {
59+
systemd_unit_file > "${systemd_unit_file_path}"
60+
}
61+
62+
write_unit_file_unless_exists() {
63+
if ! [ -e "${systemd_unit_file_path}" ]; then
64+
write_unit_file
65+
fi
66+
}
67+
68+
main() {
69+
write_unit_file_unless_exists
5670
enable_tmux_unit_on_boot
5771
}
5872
main

0 commit comments

Comments
 (0)