Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Linux ./install.sh script fails when used for updating backrest #226

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

cd "$(dirname "$0")" # cd to the directory of this script

install_unix() {
echo "Installing backrest to /usr/local/bin"
install_or_update_unix() {
if systemctl is-active --quiet backrest; then
sudo systemctl stop backrest
echo "Updating backrest in /usr/local/bin"
else
echo "Installing backrest to /usr/local/bin"
fi

sudo mkdir -p /usr/local/bin

sudo cp $(ls -1 backrest | head -n 1) /usr/local/bin
Expand All @@ -15,6 +21,11 @@ create_systemd_service() {
exit 1
fi

if [ -f /etc/systemd/system/backrest.service ]; then
echo "Systemd unit already exists. Skipping creation."
return 0
fi

echo "Creating systemd service at /etc/systemd/system/backrest.service"

sudo tee /etc/systemd/system/backrest.service > /dev/null <<- EOM
Expand Down Expand Up @@ -85,7 +96,7 @@ if [ "$OS" = "Darwin" ]; then
sudo xattr -d com.apple.quarantine /usr/local/bin/backrest # remove quarantine flag
elif [ "$OS" = "Linux" ]; then
echo "Installing on Linux"
install_unix
install_or_update_unix
create_systemd_service
echo "Enabling systemd service backrest.service"
sudo systemctl enable backrest
Expand Down