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 #91 from YunoHost-Apps/example

Apply example_ynh
This commit is contained in:
yalh76 2021-04-21 20:54:33 +02:00 committed by GitHub
commit f74ddadbe2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 107 additions and 139 deletions

View file

@ -46,8 +46,8 @@ LDAP is supported but HTTP auth is not supported?
#### Supported architectures #### 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/) * 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%20%28Apps%29.svg)](https://ci-apps-arm.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 ## Links

View file

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

View file

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

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers

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) #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 # Backup the current version of the app
ynh_backup_before_upgrade 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. # 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" 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 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
@ -79,23 +79,23 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # 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 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 ] if [ $change_path -eq 1 ]
then 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" 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" domain="$old_domain"
path_url="$new_path" path_url="$new_path"
# Create a dedicated nginx config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
fi fi
# Change the domain for nginx # Change the domain for NGINX
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
@ -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. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:www-data "$config"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
@ -134,7 +137,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#================================================= #=================================================
# RELOAD NGINX # 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 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' 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)" 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' 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 # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
@ -113,25 +119,18 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# 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/$app" ynh_setup_source --dest_dir="$final_path/$app"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # 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 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 # SPECIFIC SETUP
#================================================= #=================================================
@ -139,9 +138,6 @@ yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforwar
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies and building app..." --weight=5 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" config="$final_path/$app/config/prod.secret.exs"
pushd $final_path/$app/js pushd $final_path/$app/js
@ -178,6 +174,11 @@ pushd $final_path/$app
sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password" sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password"
popd popd
ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:www-data "$config"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -186,30 +187,14 @@ ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_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 # 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 # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating 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 # START SYSTEMD SERVICE
@ -235,7 +220,7 @@ fi
#================================================= #=================================================
# RELOAD NGINX # 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 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 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 if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service integration..." ynh_script_progression --message="Removing $app service integration..."
@ -71,9 +71,9 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # 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 ynh_remove_nginx_config
#================================================= #=================================================

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -23,7 +23,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -52,10 +52,21 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # 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" 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 # RESTORE THE APP MAIN DIR
#================================================= #=================================================
@ -63,24 +74,9 @@ ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= chmod 750 "$final_path"
# RECREATE THE DEDICATED USER chmod -R o-rwx "$final_path"
#================================================= chown -R $app:$app "$final_path"
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"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -124,7 +120,7 @@ systemctl enable $app.service --quiet
#================================================= #=================================================
ynh_script_progression --message="Integrating 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 # START SYSTEMD SERVICE
@ -136,7 +132,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." ynh_script_progression --message="Reloading NGINX web server..."

View file

@ -45,6 +45,13 @@ previous_version="${version}"
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." 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 if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions # Create the required permissions
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
@ -62,9 +69,9 @@ 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
ynh_restore_upgradebackup
ynh_clean_check_starting ynh_clean_check_starting
# Restore it if the upgrade fails
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
@ -111,6 +118,14 @@ if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"
fi 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"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -123,7 +138,7 @@ then
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir # Backup the config file in the temp dir
cp -a "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs" cp -af "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs"
# Backup upload dir # Backup upload dir
rsync -a "$final_path/$app/uploads" "$tmpdir/." rsync -a "$final_path/$app/uploads" "$tmpdir/."
@ -135,7 +150,7 @@ then
ynh_setup_source --dest_dir="$final_path/$app" ynh_setup_source --dest_dir="$final_path/$app"
# Restore the config file # Restore the config file
cp -a "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs" cp -af "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs"
# Restore upload dir # Restore upload dir
rsync -a "$tmpdir/uploads" "$final_path/$app/." rsync -a "$tmpdir/uploads" "$final_path/$app/."
@ -144,12 +159,16 @@ then
ynh_secure_remove --file="$tmpdir" ynh_secure_remove --file="$tmpdir"
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # 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 ynh_add_nginx_config
#================================================= #=================================================
@ -159,42 +178,18 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
if ynh_version_gt "1.0.3~ynh1" "${previous_version}" ; then ynh_remove_nodejs
ynh_script_progression --message="Mobilizon v1.0.3: Remove previous NodeJS"
ynh_remove_nodejs
fi
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
lsb_name="$(lsb_release --codename --short)" 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' 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 # 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 # MAKE SETUP
#================================================= #=================================================
# Give permission to the final_path
chown -R "$app":"$app" "$final_path"
pushd $final_path/$app/js pushd $final_path/$app/js
ynh_use_nodejs ynh_use_nodejs
ynh_script_progression --message="Installing NodeJS dependencies (this is going to take a while...)" ynh_script_progression --message="Installing NodeJS dependencies (this is going to take a while...)"
@ -224,13 +219,18 @@ if ynh_version_gt "1.0.3~ynh1" "${previous_version}" ; then
fi 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" ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:www-data "$config"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -241,20 +241,12 @@ ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # 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 # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating 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 # START SYSTEMD SERVICE
@ -266,7 +258,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#================================================= #=================================================
# RELOAD NGINX # 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 ynh_systemd_action --service_name=nginx --action=reload