From 4685ff4145539ab4b3e67289668d1e8238dd9cb5 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 25 Jul 2018 08:22:27 +0200 Subject: [PATCH] Add an update script for Linux --- README.md | 4 +++- update.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 update.sh diff --git a/README.md b/README.md index b02b0ac7..f2246d3c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ If you use nginx as your webserver, please include `try_files $uri /index.php;` If, however, your webserver does not support URL rewriting, set `DISABLE_URL_REWRITING` in `data/config.php` (`Setting('DISABLE_URL_REWRITING', true);`). ## How to update -Just overwrite everything with the latest release while keeping the `/data` directory, check `config-dist.php` for new configuration options and add them to your `data/config.php` (the default from values `config-dist.php` will be used for not in `data/config.php` defined settings). +Just overwrite everything with the latest release while keeping the `/data` directory, check `config-dist.php` for new configuration options and add them to your `data/config.php` (the default from values `config-dist.php` will be used for not in `data/config.php` defined settings). Just to be sure, please empty `/data/viewcache`. + +If you run grocy on Linux, there is also `/update.sh` (beside the basic tools `unzip` is needed) which does exact this and additionally creates a backup (`.tgz` archive) of the current installation in `/data/backups` (backups older than 60 days will be deleted during the update). ## Localization grocy is fully localizable - the default language is English (integrated into code), a German localization is always maintained by me. There is one file per language in the `localization` directory, if you want to create a translation, it's best to copy `localization/de.php` to a new one (e. g. `localization/it.php`) and translating all strings there. (Language can be changed in `data/config.php`, e. g. `Setting('CULTURE', 'it');`) diff --git a/update.sh b/update.sh new file mode 100644 index 00000000..a9602ace --- /dev/null +++ b/update.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +GROCY_RELEASE_URL=https://releases.grocy.info/latest + + +echo Start updating grocy + +set -e +shopt -s extglob +pushd `dirname $0` > /dev/null + +backupBundleFileName="backup-`date +%d-%m-%Y-%H-%M-%S`.tgz" +echo Making a backup of the current installation in /data/backups/$backupBundleFileName +mkdir -p ./data/backups > /dev/null +tar -zcvf ./data/backups/$backupBundleFileName --exclude ./data/backups . > /dev/null +find ./data/backups/*.tgz -mtime +60 -type f -delete + +echo Deleting everything except /data and this script +rm -rf !(data|update.sh) > /dev/null + +echo Emptying /data/viewcache +rm -rf ./data/viewcache/* > /dev/null + +echo Downloading latest release +rm -f ./grocy-latest.zip > /dev/null +wget $GROCY_RELEASE_URL -q -O ./grocy-latest.zip > /dev/null + +echo Unzipping latest release +unzip -o ./grocy-latest.zip > /dev/null +rm -f ./grocy-latest.zip > /dev/null + +popd > /dev/null + +echo Finished updating grocy