From bdf5ca5683d0bdd876aef61b905ccccece5f8635 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Sun, 3 Dec 2023 12:31:01 -0500 Subject: [PATCH] Added fixed init script to not clobber existing files --- init.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/init.sh b/init.sh index fbd39c5..64c6b8d 100755 --- a/init.sh +++ b/init.sh @@ -2,6 +2,13 @@ scriptPath="$(dirname "$(readlink -f "$0")")" -cp "$scriptPath/templates/profiles.toml" "$scriptPath/profiles.toml" -cp "$scriptPath/templates/excludes" "$scriptPath/excludes" -resticprofile generate --random-key > "$scriptPath/key" +if [[ ! -f "${scriptPath}/profiles.toml" ]]; then + cp "${scriptPath}/templates/profiles.toml" "${scriptPath}/profiles.toml" +fi +if [[ ! -f "${scriptPath}/excludes" ]]; then + cp "${scriptPath}/templates/excludes" "${scriptPath}/excludes" +fi +if [[ ! -f "${scriptPath}/key" ]]; then + resticprofile generate --random-key > "${scriptPath}/key" +fi +chmod go-rwx "${scriptPath}/key "${scriptPath}/profiles.toml" "${scriptPath}/excludes"