diff --git a/install.sh b/install.sh index 34dcd08d340838e77f8fe22502d232f226bdc4c7..a4636fcce2f972811f9668899b874d5e7c71593f 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,6 @@ #!/bin/bash +# Check for correct repository path if [[ ! -d /opt/sql-backup ]]; then echo "ERROR: Could not find sql-backup repository in /opt/sql-backup. Please clone git repository to the" \ @@ -9,12 +10,17 @@ else cd /opt/sql-backup fi +# Update repository +bash update.sh + +# Check if config.json exists; create from template if not if [[ ! -f ./config.json ]] then echo "WARN: No configuration file found. Creating one with default values from config_template.json." cp ./config_template.json ./config.json fi +# Check for existing systemd unit and replace if [[ ! -f /etc/systemd/system/sql-backup.service ]]; then echo "WARN: existing service file found. Overwriting." @@ -27,4 +33,5 @@ then fi cp -r ./service-unit/sql-backup.timer /etc/systemd/system +# enable systemd unit systemctl enable sql-backup.service diff --git a/update.sh b/update.sh new file mode 100644 index 0000000000000000000000000000000000000000..a8cf2c1a3ec267a8be649c085c2db64bfbfcd1d0 --- /dev/null +++ b/update.sh @@ -0,0 +1,21 @@ +#!/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/*