mirror of
https://github.com/YunoHost-Apps/framaforms_ynh.git
synced 2024-09-03 18:36:12 +02:00
Apply example_ynh
This commit is contained in:
parent
8a85fbfc92
commit
3c54df74b2
7 changed files with 234 additions and 225 deletions
188
manifest.json
188
manifest.json
|
@ -1,96 +1,96 @@
|
|||
{
|
||||
"name": "Framaforms",
|
||||
"id": "framaforms",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Create online webforms and surveys",
|
||||
"fr": "Créez des formulaires et questionnaires en ligne"
|
||||
},
|
||||
"version": "1.0.3~ynh2",
|
||||
"url": "https://framagit.org/framasoft/framaforms",
|
||||
"license": "GPL-2.0-only",
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.2.4"
|
||||
},
|
||||
"maintainer": {
|
||||
"name": "ljf",
|
||||
"email": "ljf+framaforms_ynh@reflexlibre.net",
|
||||
"url": "https://reflexlibre.net"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php7.3-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"example": "/poll",
|
||||
"default": "/poll"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"example": "johndoe"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password",
|
||||
"example": "Choose a password"
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the application language",
|
||||
"fr": "Choisissez la langue de l'application"
|
||||
},
|
||||
"choices": ["de", "en", "es", "fr", "it", "pt"],
|
||||
"default": "en"
|
||||
},
|
||||
{
|
||||
"name": "expiration",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "After how many weeks do the forms expire?",
|
||||
"fr": "Après combien de semaines les formulaires expirent-ils ?"
|
||||
},
|
||||
"help": {
|
||||
"en": "Set 0 to disable expiration",
|
||||
"fr": "Mettre 0 pour désactiver l'expiration"
|
||||
},
|
||||
"default": "0"
|
||||
},
|
||||
{
|
||||
"name": "deletion",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "After how many weeks is the forms deleted?",
|
||||
"fr": "Après combien de semaines les formulaires sont-ils supprimés ?"
|
||||
},
|
||||
"help": {
|
||||
"en": "Set 0 to disable deletion",
|
||||
"fr": "Mettre 0 pour désactiver la suppression"
|
||||
},
|
||||
"default": "0"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"help": {
|
||||
"en": "If no, only person with an account on your server will be able to create forms. In all cases, visitors will be able to reply to form.",
|
||||
"fr": "Si non, seule la personne disposant d'un compte sur votre serveur pourra créer des formulaires. Dans tous les cas, les visiteurs pourront répondre au formulaire."
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
"name": "Framaforms",
|
||||
"id": "framaforms",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Create online webforms and surveys",
|
||||
"fr": "Créez des formulaires et questionnaires en ligne"
|
||||
},
|
||||
"version": "1.0.3~ynh2",
|
||||
"url": "https://framagit.org/framasoft/framaforms",
|
||||
"license": "GPL-2.0-only",
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.1.7"
|
||||
},
|
||||
"maintainer": {
|
||||
"name": "ljf",
|
||||
"email": "ljf+framaforms_ynh@reflexlibre.net",
|
||||
"url": "https://reflexlibre.net"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php7.3-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"example": "/poll",
|
||||
"default": "/poll"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"example": "johndoe"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password",
|
||||
"example": "Choose a password"
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the application language",
|
||||
"fr": "Choisissez la langue de l'application"
|
||||
},
|
||||
"choices": ["de", "en", "es", "fr", "it", "pt"],
|
||||
"default": "en"
|
||||
},
|
||||
{
|
||||
"name": "expiration",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "After how many weeks do the forms expire?",
|
||||
"fr": "Après combien de semaines les formulaires expirent-ils ?"
|
||||
},
|
||||
"help": {
|
||||
"en": "Set 0 to disable expiration",
|
||||
"fr": "Mettre 0 pour désactiver l'expiration"
|
||||
},
|
||||
"default": "0"
|
||||
},
|
||||
{
|
||||
"name": "deletion",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "After how many weeks is the forms deleted?",
|
||||
"fr": "Après combien de semaines les formulaires sont-ils supprimés ?"
|
||||
},
|
||||
"help": {
|
||||
"en": "Set 0 to disable deletion",
|
||||
"fr": "Mettre 0 pour désactiver la suppression"
|
||||
},
|
||||
"default": "0"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"help": {
|
||||
"en": "If no, only person with an account on your server will be able to create forms. In all cases, visitors will be able to reply to form.",
|
||||
"fr": "Si non, seule la personne disposant d'un compte sur votre serveur pourra créer des formulaires. Dans tous les cas, les visiteurs pourront répondre au formulaire."
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -28,6 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -40,7 +41,11 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
ynh_backup --src_path="/home/yunohost.app/$app/data" --is_big=1
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$datadir" --is_big
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
|
|
|
@ -32,9 +32,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
# Add settings here as needed by your application
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the app before changing its URL (may take a while)..."
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -42,7 +42,7 @@ ynh_clean_setup () {
|
|||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# restore it if the upgrade fails
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
@ -73,19 +73,19 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
# Change the path in the NGINX config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
# Make a backup of the original NGINX config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
# Set global variables for NGINX helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated nginx config
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
|
@ -102,13 +102,10 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating Drush alias..." --weight=1
|
||||
|
||||
drush_aliasconfig="$final_path/.drush/$app.aliases.drushrc.php"
|
||||
cp -f "../conf/yoursite.aliases.drushrc.php" "$drush_aliasconfig"
|
||||
domain="$new_domain"
|
||||
path_url="$new_path"
|
||||
|
||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$drush_aliasconfig"
|
||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$drush_aliasconfig"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$new_domain" --target_file="$drush_aliasconfig"
|
||||
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$new_path" --target_file="$drush_aliasconfig"
|
||||
ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination="$final_path/.drush/$app.aliases.drushrc.php"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
|
|
|
@ -22,13 +22,13 @@ ynh_abort_if_errors
|
|||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
expiration=$YNH_APP_ARG_EXPIRATION
|
||||
deletion=$YNH_APP_ARG_DELETION
|
||||
admin_mail="root@$domain"
|
||||
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -65,6 +65,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=7
|
|||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=3
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
|
@ -77,14 +85,6 @@ db_user=$db_name
|
|||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=3
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -94,6 +94,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path/app"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -130,7 +134,7 @@ ynh_script_progression --message="Installing Composer..." --weight=31
|
|||
|
||||
mkdir -p "$final_path/.composer"
|
||||
|
||||
cp -f "../conf/composer.json" "$final_path/.composer/composer.json"
|
||||
ynh_add_config --template="../conf/composer.json" --destination="$final_path/.composer/composer.json"
|
||||
|
||||
ynh_install_composer --phpversion="$phpversion" --workdir="$final_path/.composer"
|
||||
|
||||
|
@ -141,13 +145,26 @@ export PATH="$final_path/.composer/vendor/bin:$PATH"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Initializing tmp and private directory..." --weight=1
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
mkdir -p "$final_path/app/sites/default/files"
|
||||
chmod 2775 "$final_path/app/sites/default/files"
|
||||
mkdir -p "$final_path/app/sites/default/files/tmp"
|
||||
|
||||
mkdir -p "/home/yunohost.app/$app/data"
|
||||
chown -R $app: "/home/yunohost.app/$app/data"
|
||||
chmod 775 "/home/yunohost.app/$app/data"
|
||||
#=================================================
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a data directory..." --time --weight=1
|
||||
|
||||
datadir=/home/yunohost.app/$app
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
|
||||
mkdir -p $datadir
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
|
||||
#=================================================
|
||||
# ADD MISSING IMAGES
|
||||
|
@ -161,21 +178,20 @@ chmod 775 "/home/yunohost.app/$app/data"
|
|||
#cp ../sources/partager.png "$final_path/sites/default/files/imgforms/"
|
||||
|
||||
#=================================================
|
||||
# MODIFY CONFIG FILES
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..." --weight=1
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
config_file=$final_path/app/sites/default/settings.php
|
||||
ynh_add_config --template="../conf/default.settings.php" --destination="$final_path/app/sites/default/settings.php"
|
||||
|
||||
ynh_add_config --template="../conf/default.settings.php" --destination="$config_file"
|
||||
chmod 600 "$final_path/app/sites/default/settings.php"
|
||||
chown $app:$app "$final_path/app/sites/default/settings.php"
|
||||
|
||||
#=================================================
|
||||
# INSTALLING FRAMAFORMS WITH DRUSH
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing database..." --weight=19
|
||||
|
||||
chown -R $app: $final_path
|
||||
|
||||
update-alternatives --set php /usr/bin/php$phpversion
|
||||
sudo -u $app env PATH=$PATH drush @$app site-install framaforms_org install_configure_form.site_contact_url="https://forum.yunohost.org/t/framaforms-create-polls-using-drag-and-drop/8208" install_configure_form.site_default_country=FR -y --locale="$language" --account-name="admin" --account-pass="$password" --site-name="Framaforms" --site-mail="$admin_mail" 2>&1
|
||||
sudo -u $app env PATH=$PATH drush @$app variable-set update_notify_emails "$admin_mail"
|
||||
|
@ -213,7 +229,6 @@ sudo -u $app env PATH=$PATH drush @$app vset framaforms_deletion_period_value $d
|
|||
# Remove framaforms footer
|
||||
sudo -u $app env PATH=$PATH drush @$app sql-query "UPDATE block SET region='-1', status=0 WHERE delta='framaforms_footer' AND region='footer'"
|
||||
|
||||
|
||||
#=================================================
|
||||
# CONFIGURING LDAP
|
||||
#=================================================
|
||||
|
@ -229,14 +244,6 @@ cat ../conf/ldap.conf | sudo -u $app env PATH=$PATH drush @$app variable-set --f
|
|||
|
||||
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing the config file checksum..." --weight=1
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$config_file"
|
||||
|
||||
#=================================================
|
||||
# SETUP THE CRON FILE
|
||||
#=================================================
|
||||
|
@ -246,16 +253,6 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..." --weight=1
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app: $final_path
|
||||
chmod o-rwx $final_path
|
||||
chmod 600 $config_file
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
@ -264,6 +261,8 @@ ynh_script_progression --message="Configuring permissions..." --weight=1
|
|||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
|
|
|
@ -47,20 +47,12 @@ ynh_script_progression --message="Removing app main directory..." --weight=1
|
|||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP DATA DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="/home/yunohost.app/$app"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
@ -68,11 +60,19 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
# Remove the dedicated PHP-FPM config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE APP DATA DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="/home/yunohost.app/$app"
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE CRON FILE
|
||||
#=================================================
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -20,7 +20,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..." --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -31,6 +31,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -51,6 +52,14 @@ ynh_script_progression --message="Restoring the NGINX configuration..." --weight
|
|||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -58,28 +67,24 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
|||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring user rights..." --weight=1
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R root: $final_path
|
||||
chmod o-rwx $final_path
|
||||
chmod 2775 "$final_path/app/sites/default/files"
|
||||
|
||||
mkdir -p "/home/yunohost.app/$app/data"
|
||||
chown -R $app: "/home/yunohost.app/$app/data"
|
||||
chmod 775 "/home/yunohost.app/$app/data"
|
||||
chmod 600 "$final_path/app/sites/default/settings.php"
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..." --time --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
mkdir -p $datadir
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
|
@ -90,8 +95,11 @@ ynh_script_progression --message="Restoring PHP-FPM configuration..." --weight=1
|
|||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
# Recreate a dedicated php-fpm config
|
||||
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
|
||||
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# RESTORE THE CRON FILE
|
||||
#=================================================
|
||||
|
@ -100,8 +108,6 @@ ynh_script_progression --message="Restoring cron file..." --weight=1
|
|||
# Restore the file first, so it can have a backup if different
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
|
|
@ -22,6 +22,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -30,6 +31,22 @@ ynh_script_progression --message="Checking version..." --weight=1
|
|||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=21
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -47,6 +64,12 @@ if [ -z "$final_path" ]; then
|
|||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
# If datadir doesn't exist, create it
|
||||
if [ -z "$datadir" ]; then
|
||||
final_path=/home/yunohost.app/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$datadir
|
||||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
@ -59,30 +82,14 @@ if ! ynh_permission_exists --permission="admin"; then
|
|||
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=21
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
|
||||
# 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
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -95,12 +102,16 @@ then
|
|||
ynh_setup_source --dest_dir="$final_path/app"
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
@ -120,6 +131,16 @@ ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencie
|
|||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a data directory..." --time --weight=1
|
||||
|
||||
mkdir -p $datadir
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE COMPOSER
|
||||
#=================================================
|
||||
|
@ -139,8 +160,6 @@ then
|
|||
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/app/sites/default/settings.php"
|
||||
|
||||
chown -R $app: $final_path
|
||||
|
||||
update-alternatives --set php /usr/bin/php$phpversion
|
||||
|
||||
pushd "$final_path"
|
||||
|
@ -156,32 +175,15 @@ then
|
|||
fi
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing the config file checksum..." --weight=1
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
|
||||
config_file=$final_path/app/sites/default/settings.php
|
||||
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$config_file"
|
||||
|
||||
#=================================================
|
||||
chmod 600 "$final_path/app/sites/default/settings.php"
|
||||
chown $app:$app "$final_path/app/sites/default/settings.php"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..." --weight=1
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app: $final_path
|
||||
chmod o-rwx $final_path
|
||||
mkdir -p "/home/yunohost.app/$app/data"
|
||||
chown -R $app: "/home/yunohost.app/$app/data"
|
||||
chmod 775 "/home/yunohost.app/$app/data"
|
||||
chmod 600 $config_file
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
Loading…
Reference in a new issue