69 lines
1.5 KiB
Bash
69 lines
1.5 KiB
Bash
|
#!/bin/bash
|
||
|
set -euo pipefail
|
||
|
|
||
|
# See documentation at https://docs.firefly-iii.org/advanced-installation/upgrade#created-using-composer-create-project
|
||
|
|
||
|
if [ "$USER" != "www-data" -a "$USER" != "http" ]; then
|
||
|
echo "Please run this script as the user used by the webserver"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ $# -ne 2 ]; then
|
||
|
echo "Usage : FireflyUpdate /path/to/firefly/rootdir newVersion"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ ! -d "$1" ]; then
|
||
|
echo "Directory does not exist"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
|
||
|
(
|
||
|
|
||
|
cd "$1"/..
|
||
|
|
||
|
rootDir=$(pwd)
|
||
|
originalDir=$(basename "$1")
|
||
|
newDir="$originalDir"-updated
|
||
|
|
||
|
echo "Downloading new version..."
|
||
|
|
||
|
composer create-project grumpydictator/firefly-iii --no-dev --prefer-dist "$originalDir"-updated $2
|
||
|
|
||
|
echo "Copying stored data..."
|
||
|
|
||
|
cp "$1"/.env "$rootDir/$newDir"/.env
|
||
|
cp -r "$1"/storage/{upload,export} "$rootDir/$newDir"/storage
|
||
|
cp "$1"/storage/database/database.sqlite "$rootDir/$newDir"/storage/database/
|
||
|
|
||
|
echo "Cleaning caches and running migrations..."
|
||
|
|
||
|
cd "$newDir"
|
||
|
rm -rf bootstrap/cache/*
|
||
|
php artisan cache:clear
|
||
|
php artisan migrate --seed
|
||
|
php artisan firefly-iii:upgrade-database
|
||
|
php artisan passport:install
|
||
|
php artisan cache:clear
|
||
|
|
||
|
echo "Forcing access rights to 775 on storage..."
|
||
|
|
||
|
chmod -R 775 storage
|
||
|
|
||
|
cd "$rootDir"
|
||
|
|
||
|
echo "Switching installs..."
|
||
|
|
||
|
mv "$originalDir" "$originalDir"-old
|
||
|
mv "$newDir" "$originalDir"
|
||
|
|
||
|
echo "Upgrade done !"
|
||
|
echo "Please check if it was sucessful, if so you can safely run the following command to remove the previous version:"
|
||
|
echo "sudo rm -rf \"$rootDir/$originalDir-old\""
|
||
|
|
||
|
)
|
||
|
|
||
|
exit 0
|
||
|
|