From 010434996129e56e64b55238244592a53f209eac Mon Sep 17 00:00:00 2001 From: gmpinder Date: Sat, 3 Jun 2023 18:49:43 -0400 Subject: [PATCH] Install syncthing --- scripts/pre/install-syncthing.sh | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 scripts/pre/install-syncthing.sh diff --git a/scripts/pre/install-syncthing.sh b/scripts/pre/install-syncthing.sh new file mode 100644 index 0000000..3f415c0 --- /dev/null +++ b/scripts/pre/install-syncthing.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -oue pipefail + +VERSION="v1.23.4" +BASE_URL="https://github.com/syncthing/syncthing/releases/download" +FILENAME="syncthing-linux-amd64-${VERSION}.tar.gz" +EXTRACTED_DIR="syncthing-linux-amd64-${VERSION}" + +# Download the file +wget "${BASE_URL}/${VERSION}/${FILENAME}" + +# Extract the file +tar xvf "${FILENAME}" + +# Move the binary to /usr/local/bin +mv "${EXTRACTED_DIR}/syncthing" /usr/local/bin + +# Move .desktop files +mv "${EXTRACTED_DIR}/etc/linux-desktop/"*.desktop /usr/share/applications/ + +# Move the systemd service file +cp "${EXTRACTED_DIR}/etc/linux-systemd/user/syncthing.service" /etc/systemd/system/ + +# Enable the systemd service +systemctl enable syncthing + +# Verify the installation +if command -v syncthing &> /dev/null +then + echo "Syncthing command is found in PATH." +else + echo "Syncthing command not found in PATH." + exit 1 +fi + +# Verify that syncthing --version works +if syncthing --version &> /dev/null +then + echo "Syncthing --version executes successfully." +else + echo "Syncthing --version did not execute successfully." + exit 1 +fi + +# Cleanup +rm -rf "${EXTRACTED_DIR}"