1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mobilizon_ynh.git synced 2024-09-03 19:46:19 +02:00

Merge pull request #93 from YunoHost-Apps/testing

Upgrade to 1.1.1
This commit is contained in:
yalh76 2021-04-29 08:15:59 +02:00 committed by GitHub
commit 6e69a7aa43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 207 additions and 151 deletions

View file

@ -13,7 +13,7 @@ Mobilizon aims to solve existing platform's problems to organize events in a dec
Mobilizon is a tool that helps you find, create and organise events. You can also create a page for your group where the members will be able to organise together.
**Shipped version:** 1.1.0
**Shipped version:** 1.1.1
## Important points to read before installing
@ -46,8 +46,8 @@ LDAP is supported but HTTP auth is not supported?
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mobilizon/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/)
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mobilizon.svg)](https://ci-apps.yunohost.org/ci/apps/mobilizon/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mobilizon.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/)
## Links

View file

@ -15,21 +15,23 @@
setup_public=1
upgrade=1
# 0.1.0-2019-05-15~ynh1
# upgrade=1 from_commit=185cc16e516076e340cca149e8e9140a8762e22e
#upgrade=1 from_commit=185cc16e516076e340cca149e8e9140a8762e22e
# 0.1.0-2019-12-28~ynh1
# upgrade=1 from_commit=6b77f268d4e7e2cd525e11e11f3ed5a5162d0bd2
#upgrade=1 from_commit=6b77f268d4e7e2cd525e11e11f3ed5a5162d0bd2
# 1.0.0~ynh1
# upgrade=1 from_commit=ac87692da6eaff71f40e3069c7bc6129eddba5e6
#upgrade=1 from_commit=ac87692da6eaff71f40e3069c7bc6129eddba5e6
# 1.0.3~ynh1
# upgrade=1 from_commit=8413ab8bd3aca3e2f6c431153dd9dfab37860956
#upgrade=1 from_commit=8413ab8bd3aca3e2f6c431153dd9dfab37860956
# 1.0.6-2021-02-23~ynh1
upgrade=1 from_commit=8d20652e67015a535b2063edc54379604a7d932d
# 1.0.7~ynh1
upgrade=1 from_commit=cba843be0d7e00d7d7290f0d0da95807711a96d4
# 1.1.0~ynh1
upgrade=1 from_commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e
backup_restore=1
multi_instance=1
port_already_use=0
change_url=0
change_url=1
;;; Options
Email=yalh@yahoo.com
Notification=all
@ -46,3 +48,5 @@ Notification=all
name=1.0.6-2021-02-23~ynh1
; commit=cba843be0d7e00d7d7290f0d0da95807711a96d4
name=1.0.7~ynh1
; commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e
name=1.1.0~ynh1

View file

@ -1,7 +1,7 @@
SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/1.1.0/mobilizon-1.1.0.tar.gz
SOURCE_SUM=b1cc0e8c2588f67aedd6c43200656132535ac6cf360dadd0a02bac6fc19dbe02
SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/1.1.1/mobilizon-1.1.1.tar.gz
SOURCE_SUM=38d5b382d5409aeabb8aba31ce80d59cdaef8b57a97c5ad28a3ff4a2ec9209b8
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mobilizon-1.1.0.tar.gz
SOURCE_FILENAME=mobilizon-1.1.1.tar.gz
SOURCE_EXTRACT=true

2
conf/uploads.exs Normal file
View file

@ -0,0 +1,2 @@
config :mobilizon, Mobilizon.Web.Upload.Uploader.Local, uploads: "__DATADIR__/uploads"

View file

@ -6,7 +6,7 @@
"en": "A decentralized and federated platform to organize events",
"fr": "Une plateforme décentralisée et fédérée pour organiser des événements"
},
"version": "1.1.0~ynh1",
"version": "1.1.1~ynh1",
"url": "https://joinmobilizon.org/",
"license": "AGPL-3.0-or-later",
"maintainer": {
@ -24,28 +24,16 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for Mobilizon",
"fr": "Choisissez un nom de domaine pour Mobilizon"
},
"example": "example.com"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez l'administrateur"
},
"example": "johndoe"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
},
{

View 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
@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -56,6 +57,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================

View file

@ -35,9 +35,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --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
@ -45,7 +45,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
@ -79,23 +79,23 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..."
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
@ -103,7 +103,7 @@ then
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
yunohost user update "${app}_notifs" --mail ${app}_notifs@{$new_domain} --remove-mailalias ${app}@${old_domain} --add-mailalias ${app}@${new_domain}
yunohost user update "${app}_notifs" --mail "${app}_notifs@${new_domain}" --add-mailalias "${app}@${new_domain}"
fi
#=================================================
@ -121,6 +121,9 @@ ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" -
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:$app "$config"
#=================================================
# GENERIC FINALISATION
#=================================================
@ -134,7 +137,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -79,14 +79,20 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
#=================================================
# INSTALL EXTRA DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing extra dependencies ..."
lsb_name="$(lsb_release --codename --short)"
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
@ -113,35 +119,43 @@ 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
#=================================================
ynh_script_progression --message="Configuring nginx web server..."
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating the data directory..."
# Define app's data directory
datadir="/home/yunohost.app/${app}"
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
# Create app folders
mkdir -p "$datadir/"
mkdir -p "$datadir/uploads/"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#=================================================
# MAKE SETUP
#=================================================
ynh_script_progression --message="Installing dependencies and building app..." --weight=5
# Give permission to the final_path
chown -R "$app":"$app" "$final_path"
config="$final_path/$app/config/prod.secret.exs"
pushd $final_path/$app/js
@ -152,6 +166,8 @@ pushd $final_path/$app/js
sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
popd
ynh_secure_remove --file="$final_path/$app/js"
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
pushd $final_path/$app
sudo -u "$app" MIX_ENV=prod mix local.hex --force
@ -163,6 +179,8 @@ popd
cat "../conf/ldap.exs" >> "$config"
cat "../conf/mail.exs" >> "$config"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/uploads.exs"
cat "../conf/uploads.exs" >> "$config"
pushd $final_path/$app
chmod o-rwx $config
@ -178,6 +196,13 @@ pushd $final_path/$app
sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password"
popd
ynh_secure_remove --file="$final_path/.cache"
ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:$app "$config"
#=================================================
# SETUP SYSTEMD
#=================================================
@ -186,30 +211,14 @@ ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_script_progression --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R "$app":"$app" "$final_path"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Mobilizon"
yunohost service add $app --description="$app daemon for Mobilizon"
#=================================================
# START SYSTEMD SERVICE
@ -235,7 +244,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -28,7 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..."
@ -71,9 +71,9 @@ ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing nginx web server configuration..."
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated nginx config
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================

View 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
@ -23,7 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..."
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -36,6 +36,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
port=$(ynh_app_setting_get --app=$app --key=port)
ynh_user_password=$(ynh_app_setting_get --app=$app --key=ynh_user_password)
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -52,10 +53,21 @@ test ! -d $final_path \
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the nginx configuration..."
ynh_script_progression --message="Restoring the NGINX web server configuration..."
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..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
@ -63,27 +75,28 @@ ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R "$app":"$app" "$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RECREATE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Recreating the data directory..."
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
ynh_restore_file --origin_path="$datadir" --not_mandatory
# Create app folders
mkdir -p "$datadir/"
mkdir -p "$datadir/uploads/"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
@ -124,7 +137,7 @@ systemctl enable $app.service --quiet
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Mobilizon"
yunohost service add $app --description="$app daemon for Mobilizon"
#=================================================
# START SYSTEMD SERVICE
@ -136,7 +149,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."

View file

@ -28,6 +28,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
port=$(ynh_app_setting_get --app=$app --key=port)
secret=$(ynh_app_setting_get --app=$app --key=secret)
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK VERSION
@ -45,6 +46,13 @@ previous_version="${version}"
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
@ -62,9 +70,9 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -111,6 +119,52 @@ if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
ynh_store_file_checksum --file="$config"
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE DATADIR FOLDER
#=================================================
# If datadir doesn't exist, create it
if [ -z "$datadir" ]; then
ynh_script_progression --message="Create datadir folder..."
# Define app's data directory
datadir="/home/yunohost.app/${app}"
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
# Create app folders
mkdir -p "$datadir/"
mkdir -p "$datadir/uploads/"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
rsync -a $final_path/$app/uploads/ $datadir/uploads/
config="$final_path/$app/config/prod.secret.exs"
ynh_backup_if_checksum_is_different --file="$config"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/uploads.exs"
cat "../conf/uploads.exs" >> "$config"
ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:$app "$config"
ynh_secure_remove --file="$final_path/$app/uploads"
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -123,10 +177,7 @@ then
tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir
cp -a "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs"
# Backup upload dir
rsync -a "$final_path/$app/uploads" "$tmpdir/."
cp -af "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs"
# Remove the app directory securely
ynh_secure_remove --file="$final_path/$app"
@ -135,21 +186,22 @@ then
ynh_setup_source --dest_dir="$final_path/$app"
# Restore the config file
cp -a "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs"
# Restore upload dir
rsync -a "$tmpdir/uploads" "$final_path/$app/."
cp -af "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
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..."
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
@ -159,50 +211,29 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
if ynh_version_gt "1.0.3~ynh1" "${previous_version}" ; then
ynh_script_progression --message="Mobilizon v1.0.3: Remove previous NodeJS"
ynh_remove_nodejs
fi
ynh_remove_nodejs
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
lsb_name="$(lsb_release --codename --short)"
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# SPECIFIC UPGRADE
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..."
config="$final_path/$app/config/prod.secret.exs"
ynh_backup_if_checksum_is_different --file="$config"
chmod o-rwx $config
#=================================================
# MAKE SETUP
#=================================================
# Give permission to the final_path
chown -R "$app":"$app" "$final_path"
pushd $final_path/$app/js
ynh_use_nodejs
ynh_script_progression --message="Installing NodeJS dependencies (this is going to take a while...)"
sudo -u $app env PATH=$PATH yarn install
ynh_script_progression --message="Building NodeJS application (this is going to take a while...)"
sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
sudo -u $app env PATH=$PATH yarn cache clean --all
popd
ynh_secure_remove --file="$final_path/$app/js"
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
pushd $final_path/$app
sudo -u "$app" MIX_ENV=prod mix local.hex --force
@ -212,6 +243,8 @@ pushd $final_path/$app
sudo -u "$app" MIX_ENV=prod mix ecto.migrate
popd
ynh_secure_remove --file="$final_path/.cache"
#=================================================
# RUN APP MIGRATIONS
#=================================================
@ -224,13 +257,18 @@ if ynh_version_gt "1.0.3~ynh1" "${previous_version}" ; then
fi
#=================================================
# STORE THE CONFIG FILE CHECKSUM
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Storing the config file checksum..."
ynh_script_progression --message="Updating a config file..."
# Recalculate and store the checksum of the file for the next upgrade.
config="$final_path/$app/config/prod.secret.exs"
ynh_backup_if_checksum_is_different --file="$config"
ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:$app "$config"
#=================================================
# SETUP SYSTEMD
#=================================================
@ -241,20 +279,12 @@ ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files
chown -R "$app":"$app" "$final_path"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Mobilizon"
yunohost service add $app --description="$app daemon for Mobilizon"
#=================================================
# START SYSTEMD SERVICE
@ -266,7 +296,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload