mirror of
https://github.com/YunoHost-Apps/invoiceninja5_ynh.git
synced 2024-09-03 19:26:23 +02:00
try to fix upgrade
This commit is contained in:
parent
8c63326e45
commit
71a7255c85
3 changed files with 37 additions and 45 deletions
|
@ -33,7 +33,7 @@ MAIL_USERNAME=null
|
||||||
MAIL_PASSWORD=null
|
MAIL_PASSWORD=null
|
||||||
MAIL_ENCRYPTION=tls
|
MAIL_ENCRYPTION=tls
|
||||||
MAIL_FROM_ADDRESS='__EMAIL__'
|
MAIL_FROM_ADDRESS='__EMAIL__'
|
||||||
MAIL_FROM_NAME="__EMAIL_NAME__"
|
MAIL_FROM_NAME="__EMAIL_FIRSTNAME__ __EMAIL_LASTNAME__"
|
||||||
|
|
||||||
POSTMARK_API_TOKEN=
|
POSTMARK_API_TOKEN=
|
||||||
REQUIRE_HTTPS=false
|
REQUIRE_HTTPS=false
|
||||||
|
|
|
@ -31,7 +31,8 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
api_secret="$(ynh_string_random --length=32)"
|
api_secret="$(ynh_string_random --length=32)"
|
||||||
app_key="$(ynh_string_random --length=32)"
|
app_key="$(ynh_string_random --length=32)"
|
||||||
phantomjs_key="$(ynh_string_random --length=32)"
|
phantomjs_key="$(ynh_string_random --length=32)"
|
||||||
email_name="$(ynh_user_get_info $admin firstname) $(ynh_user_get_info $admin lastname)"
|
email_firstname="$(ynh_user_get_info $admin firstname)"
|
||||||
|
email_lastname="$(ynh_user_get_info $admin lastname)"
|
||||||
email="$(ynh_user_get_info $admin mail)"
|
email="$(ynh_user_get_info $admin mail)"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,7 +59,8 @@ ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
ynh_app_setting_set --app=$app --key=api_secret --value=$api_secret
|
ynh_app_setting_set --app=$app --key=api_secret --value=$api_secret
|
||||||
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
|
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
|
||||||
ynh_app_setting_set --app=$app --key=phantomjs_key --value=$phantomjs_key
|
ynh_app_setting_set --app=$app --key=phantomjs_key --value=$phantomjs_key
|
||||||
ynh_app_setting_set --app=$app --key=email_name --value=$email_name
|
ynh_app_setting_set --app=$app --key=email_firstname --value="$email_firstname"
|
||||||
|
ynh_app_setting_set --app=$app --key=email_lastname --value="$email_lastname"
|
||||||
ynh_app_setting_set --app=$app --key=email --value=$email
|
ynh_app_setting_set --app=$app --key=email --value=$email
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -123,7 +125,10 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Modifying a config file..."
|
ynh_script_progression --message="Modifying a config file..."
|
||||||
|
|
||||||
ynh_add_config --template="../conf/default.env" --destination="$final_path/.env"
|
ynh_add_config --template="default.env" --destination="$final_path/.env"
|
||||||
|
|
||||||
|
chmod 400 "$final_path/.env"
|
||||||
|
chown $app:$app "$final_path/.env"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||||
|
|
|
@ -12,13 +12,14 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
|
@ -29,10 +30,10 @@ db_user=$db_name
|
||||||
api_secret=$(ynh_app_setting_get --app=$app --key=api_secret)
|
api_secret=$(ynh_app_setting_get --app=$app --key=api_secret)
|
||||||
app_key=$(ynh_app_setting_get --app=$app --key=app_key)
|
app_key=$(ynh_app_setting_get --app=$app --key=app_key)
|
||||||
phantomjs_key=$(ynh_app_setting_get --app=$app --key=phantomjs_key)
|
phantomjs_key=$(ynh_app_setting_get --app=$app --key=phantomjs_key)
|
||||||
email_name=$(ynh_app_setting_get --app=$app --key=email_name)
|
email_firstname=$(ynh_app_setting_get --app=$app --key=email_firstname)
|
||||||
|
email_lastname=$(ynh_app_setting_get --app=$app --key=email_lastname)
|
||||||
email=$(ynh_app_setting_get --app=$app --key=email)
|
email=$(ynh_app_setting_get --app=$app --key=email)
|
||||||
|
|
||||||
final_path=/var/www/$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -48,40 +49,16 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
||||||
|
|
||||||
# If db_name doesn't exist, create it
|
|
||||||
if [ -z "$db_name" ]; then
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
|
||||||
if [ -z "$final_path" ]; then
|
|
||||||
final_path=/var/www/$app
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cleaning legacy permissions
|
|
||||||
if ynh_legacy_permissions_exists; then
|
|
||||||
ynh_legacy_permissions_delete_all
|
|
||||||
|
|
||||||
ynh_app_setting_delete --app=$app --key=is_public
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
@ -90,19 +67,26 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
config="$final_path/.env"
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/.env"
|
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# FIXME: this should be managed by the core in the future
|
||||||
|
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||||
|
# such that the appropriate users (e.g. maybe www-data) can access
|
||||||
|
# files in some cases.
|
||||||
|
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
||||||
|
# this will be treated as a security issue.
|
||||||
|
chmod 750 "$final_path"
|
||||||
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
|
@ -135,14 +119,17 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..."
|
||||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
|
||||||
# MODIFY A CONFIG FILE
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_add_config --template="../conf/default.env" --destination="$final_path/.env"
|
ynh_script_progression --message="Updating a configuration file..."
|
||||||
|
|
||||||
|
ynh_add_config --template="default.env" --destination="$final_path/.env"
|
||||||
|
|
||||||
|
chmod 400 "$final_path/.env"
|
||||||
|
chown $app:$app "$final_path/.env"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue