flinventory-gui/update-bikeparts.sh
2024-08-20 15:45:30 +02:00

33 lines
1.1 KiB
Bash

# rudimentary script for saving changes and update code
# need to fill in the following variables:
BACKUPDIR="<insert here>"
DATA_LOCATION="<absolute path to data repository>"
CODE_LOCATION="<absolute path to gui code repository>"
WAREHOUSE="<name of the place the inventory is for. The corresponding branch is WAREHOUSE-main>"
set -e
systemctl stop flinventory-gui.service
now="$(date +%y-%m-%dT%H%M%S)"
backupdir="/root/backup-flinventory/${now}/"
echo "${backupdir}"
mkdir -p "${backupdir}"
cd "${DATA_LOCATION}"
cp locations.json parts.json "${backupdir}"
branchname="website-changes-${WAREHOUSE}-${now}"
git switch -c "${branchname}"
git add parts.json
git commit -m "[for main] changes to parts.json via Website" || true
git add locations.json
git commit -m "[for ${WAREHOUSE}] changes to locations.json via Website" || true
git add .
git commit -m "[?] other changes via Website" || true # allow empty commit
git push -u origin "${branchname}"
git switch "${WAREHOUSE}-main"
git pull
cd "${CODE_LOCATION}/flinventory"
git pull
cd "${CODE_LOCATION}"
git pull --recurse-submodules=yes
systemctl start flinventory-gui.service
systemctl status flinventory-gui.service