Skip to content
Snippets Groups Projects
Commit a39f6ac0 authored by root's avatar root
Browse files

Add updater and update logic to install script.

parent 8866e9e7
Branches
Tags
No related merge requests found
#!/bin/bash #!/bin/bash
# Check for correct repository path
if [[ ! -d /opt/sql-backup ]]; if [[ ! -d /opt/sql-backup ]];
then then
echo "ERROR: Could not find sql-backup repository in /opt/sql-backup. Please clone git repository to the" \ echo "ERROR: Could not find sql-backup repository in /opt/sql-backup. Please clone git repository to the" \
...@@ -9,12 +10,17 @@ else ...@@ -9,12 +10,17 @@ else
cd /opt/sql-backup cd /opt/sql-backup
fi fi
# Update repository
bash update.sh
# Check if config.json exists; create from template if not
if [[ ! -f ./config.json ]] if [[ ! -f ./config.json ]]
then then
echo "WARN: No configuration file found. Creating one with default values from config_template.json." echo "WARN: No configuration file found. Creating one with default values from config_template.json."
cp ./config_template.json ./config.json cp ./config_template.json ./config.json
fi fi
# Check for existing systemd unit and replace
if [[ ! -f /etc/systemd/system/sql-backup.service ]]; if [[ ! -f /etc/systemd/system/sql-backup.service ]];
then then
echo "WARN: existing service file found. Overwriting." echo "WARN: existing service file found. Overwriting."
...@@ -27,4 +33,5 @@ then ...@@ -27,4 +33,5 @@ then
fi fi
cp -r ./service-unit/sql-backup.timer /etc/systemd/system cp -r ./service-unit/sql-backup.timer /etc/systemd/system
# enable systemd unit
systemctl enable sql-backup.service systemctl enable sql-backup.service
#!/usr/bin/bash
#scriptroot=${BASH_SOURCE[0]}
# create temporary directory in home
mkdir -p ~/tmp
# Switch to Application Directory
cd /opt/sql-backup
# save settings file
cp config.json ~/tmp/
# update git repository
git stash
git pull
# restore settings file
cp -f ~/tmp/config.json .
# clear temporary directory
rm -r ~/tmp/*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment