1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/firefly-iii_ynh.git synced 2024-09-03 18:36:13 +02:00

Fix for upgrade and restore

(missing working directory return after making artisan stuff)
This commit is contained in:
root 2020-05-10 00:40:14 +02:00
parent 8d3a467dd1
commit c5850cc394
5 changed files with 86 additions and 99 deletions

View file

@ -38,34 +38,6 @@ exec_as() {
# Composer helpers
#
# Execute a composer command from a given directory
# usage: composer_exec AS_USER WORKDIR COMMAND [ARG ...]
exec_composer() {
local WORKDIR=$1
shift 1
COMPOSER_HOME="${WORKDIR}/.composer" \
# sudo /usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \
/usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \
-d "${WORKDIR}" --no-interaction
}
# Install and initialize Composer in the given directory
# usage: init_composer DESTDIR [AS_USER]
init_composer() {
local DESTDIR=$1
local AS_USER=${2:-admin}
# install composer
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="${DESTDIR}/.composer" \
sudo /usr/bin/php7.2 -- --quiet --install-dir="$DESTDIR" \
|| ynh_die "Unable to install Composer"
# update dependencies to create composer.lock
exec_composer "$DESTDIR" install --no-dev --prefer-dist --no-scripts \
|| ynh_die "Unable to update firefly-iii core dependencies"
}
sudo_path () {
sudo env "PATH=$PATH" $@

View file

@ -11,9 +11,14 @@ if [ ! -e _common.sh ]; then
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source ynh_add_extra_apt_repos__3
source ynh_install_php__3
source ynh_composer
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================

View file

@ -48,7 +48,6 @@ ynh_script_progression --message="Validating installation parameters..." --time
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#mkdir $final_path
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -143,9 +142,9 @@ ynh_replace_string "yunoappurl" "$domain$path_url" "$final_path/.env"
#init_composer $final_path $app
cd $final_path && php$phpversion artisan migrate:refresh --seed
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
cd $final_path && php$phpversion artisan passport:install
cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD
cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD
#=================================================

View file

@ -13,8 +13,12 @@ if [ ! -e _common.sh ]; then
fi
source _common.sh
source ynh_add_extra_apt_repos__3
source ynh_install_php__3
source ynh_composer
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
@ -116,12 +120,27 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# SPECIFIC UPGRADE
#=================================================
init_composer $final_path
cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
# Install via composer
ynh_install_composer --phpversion="$phpversion"
#cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force
#cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear
#cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database
#cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify
#cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install
cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD
cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD
#=================================================
# SETUP APPLICATION PERMISSIONS
#=================================================
# Set right permissions
chown -R $app:$app $final_path
chmod -R 775 ${final_path}/storage
#=================================================
# GENERIC FINALIZATION

View file

@ -81,6 +81,13 @@ ynh_abort_if_errors
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path --path_url=$path_url)
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --time --weight=1
ynh_install_php --phpversion="$phpversion" --package="$pkg_dependencies"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -99,25 +106,61 @@ rm -Rf "$final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
#=================================================
# SPECIFIC SETUP
#=================================================
# Install via composer
ynh_install_composer --phpversion="$phpversion"
cd $final_path && php$phpversion artisan migrate:refresh --seed
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
cd $final_path && php$phpversion artisan passport:install
# create a user
email=$(ynh_user_get_info $admin 'mail')
rm -rf "$final_path/bootstrap/cache/*"
# setup application config
sudo cp ../conf/.env $final_path/.env
cd $final_path && php$phpversion artisan cache:clear
cd $final_path && php$phpversion artisan migrate --seed
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
cd $final_path && php$phpversion artisan passport:install
cd $final_path && php$phpversion artisan cache:clear
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_replace_string "random_key" "$random_key" "$final_path/.env"
ynh_replace_string "yunouser" "$db_name" "$final_path/.env"
ynh_replace_string "yunopass" "$db_pwd" "$final_path/.env"
ynh_replace_string "yunobase" "$db_name" "$final_path/.env"
ynh_replace_string "yunomail" "$email" "$final_path/.env"
ynh_replace_string "yunodomain" "$domain" "$final_path/.env"
ynh_replace_string "yunoappurl" "$domain$path_url" "$final_path/.env"
#Run artisan stuff
cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD
cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD
#rm -rf "$final_path/bootstrap/cache/*"
#cd $final_path && php$phpversion artisan cache:clear
#cd $final_path && php$phpversion artisan migrate --seed
#cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
#cd $final_path && php$phpversion artisan passport:install
#cd $final_path && php$phpversion artisan cache:clear
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$final_path/.env"
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/.env"
cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/"
cp -a "$tmpdir/storage/export/" "$final_path/storage/export/"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set right permissions
chown -R $app:$app $final_path
chown -R $app: $final_path
chmod -R 775 ${final_path}/storage
#remove tmp dir
@ -131,13 +174,6 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." -
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -172,50 +208,6 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --time -
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# SPECIFIC UPGRADE
#=================================================
# Install via composer
ynh_install_composer --phpversion="$phpversion"
# Get the admin email
email=$(ynh_user_get_info --username=$admin --key='mail')
# setup application config
sudo cp ../conf/.env $final_path/.env
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_replace_string --match_string"random_key" --replace_string="$random_key" --file="$final_path/.env"
ynh_replace_string --match_string"yunouser" --replace_string="$db_name" --file="$final_path/.env"
ynh_replace_string --match_string"yunopass" --replace_string="$db_pwd" --file="$final_path/.env"
ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --file="$final_path/.env"
ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env"
ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env"
#init_composer $final_path
cd $final_path && php$phpversion artisan migrate --env=production --force
cd $final_path && php$phpversion artisan cache:clear
cd $final_path && php$phpversion artisan firefly:upgrade-database
cd $final_path && php$phpversion artisan firefly:verify
cd $final_path && php$phpversion artisan passport:install
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$final_path/.env"
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/.env"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set right permissions
chown -R $app: $final_path
chmod -R 775 ${final_path}/storage
#=================================================
# SETUP SSOWAT
#=================================================