1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/snserver_ynh.git synced 2024-09-03 20:26:22 +02:00

Apply last example_ynh

This commit is contained in:
yalh76 2022-08-31 02:25:01 +02:00
parent f5489c7556
commit abaf892728
30 changed files with 624 additions and 675 deletions

View file

@ -15,8 +15,7 @@
# Fetching information # Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
#repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
repo="standardnotes/server"
commit="" commit=""
id=0 id=0
while [[ -z $commit && $id -le 29 ]] while [[ -z $commit && $id -le 29 ]]
@ -93,6 +92,8 @@ SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true
EOT EOT
echo "... conf/app.src updated" echo "... conf/app.src updated"
@ -104,7 +105,7 @@ echo "... conf/app.src updated"
# The GitHub Action workflow takes care of committing all changes after this script ends. # The GitHub Action workflow takes care of committing all changes after this script ends.
#================================================= #=================================================
# GENERIC FINALIZA-TION # GENERIC FINALIZATION
#================================================= #=================================================
# Replace new version in manifest # Replace new version in manifest

View file

@ -1,8 +1,3 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
@ -23,8 +18,7 @@
change_url=1 change_url=1
;;; Options ;;; Options
Email= Email=
Notification= Notificationnone
;;; Upgrade options ;;; Upgrade options
; commit=2a0f413937f8a3d4bd067a5890480bce1222ec5a ; commit=2a0f413937f8a3d4bd067a5890480bce1222ec5a
name=2022.06.20~ynh1 name=2022.06.20~ynh1

View file

@ -1,5 +1,7 @@
SOURCE_URL=https://github.com/standardnotes/server/archive/033bc25d8f55e22ba168bad2d0c44fa1ac9a86e4.tar.gz SOURCE_URL=https://github.com/standardnotes/server/archive/f6b359a77207deb66b497038e8ff2f04b287bea2.tar.gz
SOURCE_SUM=1f64d26630932d19985df8989f51c909912066b1dc4539b22f952f5e81f978f2 SOURCE_SUM=50f92435eb2c86e42ab2dc9c17b3a6d2b45278e845355e3fa148bcb003ff8763
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -10,6 +10,7 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live/ WorkingDirectory=__FINALPATH__/live/
EnvironmentFile=__FINALPATH__/live/api-gateway.env EnvironmentFile=__FINALPATH__/live/api-gateway.env
Environment="__YNH_NODE_LOAD_PATH__"
ExecStart=/usr/bin/yarn start:api-gateway ExecStart=/usr/bin/yarn start:api-gateway
StandardOutput=append:/var/log/__APP__/api-gateway.log StandardOutput=append:/var/log/__APP__/api-gateway.log
StandardError=inherit StandardError=inherit

View file

@ -11,6 +11,7 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/auth-worker.env EnvironmentFile=__FINALPATH__/live/auth-worker.env
Environment="__YNH_NODE_LOAD_PATH__"
ExecStart=/usr/bin/yarn start:auth-worker ExecStart=/usr/bin/yarn start:auth-worker
StandardOutput=append:/var/log/__APP__/auth-worker.log StandardOutput=append:/var/log/__APP__/auth-worker.log
StandardError=inherit StandardError=inherit

View file

@ -11,6 +11,7 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/auth.env EnvironmentFile=__FINALPATH__/live/auth.env
Environment="__YNH_NODE_LOAD_PATH__"
ExecStart=/usr/bin/yarn start:auth ExecStart=/usr/bin/yarn start:auth
StandardOutput=append:/var/log/__APP__/auth.log StandardOutput=append:/var/log/__APP__/auth.log
StandardError=inherit StandardError=inherit

View file

@ -11,6 +11,7 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/files.env EnvironmentFile=__FINALPATH__/live/files.env
Environment="__YNH_NODE_LOAD_PATH__"
ExecStart=/usr/bin/yarn start:files ExecStart=/usr/bin/yarn start:files
StandardOutput=append:/var/log/__APP__/files.log StandardOutput=append:/var/log/__APP__/files.log
StandardError=inherit StandardError=inherit

View file

@ -11,6 +11,7 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/syncing-server-worker.env EnvironmentFile=__FINALPATH__/live/syncing-server-worker.env
Environment="__YNH_NODE_LOAD_PATH__"
ExecStart=/usr/bin/yarn start:syncing-server-worker ExecStart=/usr/bin/yarn start:syncing-server-worker
StandardOutput=append:/var/log/__APP__/syncing-server-worker.log StandardOutput=append:/var/log/__APP__/syncing-server-worker.log
StandardError=inherit StandardError=inherit

View file

@ -10,6 +10,7 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/live WorkingDirectory=__FINALPATH__/live
EnvironmentFile=__FINALPATH__/live/syncing-server.env EnvironmentFile=__FINALPATH__/live/syncing-server.env
Environment="__YNH_NODE_LOAD_PATH__"
ExecStart=/usr/bin/yarn start:syncing-server ExecStart=/usr/bin/yarn start:syncing-server
StandardOutput=append:/var/log/__APP__/syncing-server.log StandardOutput=append:/var/log/__APP__/syncing-server.log
StandardError=inherit StandardError=inherit

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Standard Notes is an end-to-end encrypted note-taking app for digitalists and professionals. Capture your notes, files, and lifes work all in one secure place.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Standard Notes est une application de prise de notes chiffrée de bout en bout pour les numériciens et les professionnels. Capturez vos notes, vos fichiers et le travail de votre vie en un seul endroit sécurisé.

View file

@ -1,4 +1,3 @@
* No single-sign on or LDAP integration * No single-sign on or LDAP integration
* Ram requirements ( 4GB swap memory will be created during install ): * Ram requirements ( 4GB swap memory will be created during install ):
* Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel * Configuration can be changed under: https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel

3
doc/DISCLAIMER_fr.md Normal file
View file

@ -0,0 +1,3 @@
* Pas d'authentification unique ou d'intégration LDAP.
* Besoins en mémoire vive (4 Go de mémoire swap seront créés pendant l'installation) :
* La configuration peut être modifiée sous : https://my_domain.tld/yunohost/admin/#/apps/$app_id/config-panel

View file

@ -5,7 +5,7 @@
"description": { "description": {
"en": "The Standard Notes syncing server. An end-to-end encrypted note-taking app." "en": "The Standard Notes syncing server. An end-to-end encrypted note-taking app."
}, },
"version": "2022.07.29~ynh1", "version": "2022.08.30~ynh1",
"url": "https://github.com/standardnotes/standalone", "url": "https://github.com/standardnotes/standalone",
"upstream": { "upstream": {
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
@ -13,7 +13,7 @@
"demo": "https://standardnotes.org/demo", "demo": "https://standardnotes.org/demo",
"admindoc": "https://docs.standardnotes.org/", "admindoc": "https://docs.standardnotes.org/",
"userdoc": "https://standardnotes.com/help", "userdoc": "https://standardnotes.com/help",
"code": "https://github.com/standardnotes/standalone" "code": "https://github.com/standardnotes/server"
}, },
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"maintainer": { "maintainer": {

View file

@ -3,12 +3,13 @@
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
NODEJS_VERSION="16"
nodejs_version=16.13.1
swap_needed=4096 swap_needed=4096
node_max_old_space_size=4096 node_max_old_space_size=4096
# dependencies used by the app # dependencies used by the app (must be on a single line)
pkg_dependencies="" pkg_dependencies=""
#================================================= #=================================================
@ -52,12 +53,10 @@ ynh_replace_string_on_line() {
sed --in-place "${line} s${delimit}${match_string}${delimit}${replace_string}${delimit}" "$target_file" sed --in-place "${line} s${delimit}${match_string}${delimit}${replace_string}${delimit}" "$target_file"
} }
#================================================ #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================

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
@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -24,7 +23,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -33,10 +32,14 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Backing up the main app directory..."
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
@ -49,21 +52,12 @@ ynh_backup --src_path="$datadir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up nginx web server configuration..."
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# BACKUP FAIL2BAN CONFIGURATION # BACKUP FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up fail2ban configuration..."
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
@ -73,14 +67,12 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_print_info "Backing up logrotate configuration..."
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_print_info "Backing up systemd configuration..."
ynh_backup --src_path="/etc/systemd/system/$app-api-gateway.service" ynh_backup --src_path="/etc/systemd/system/$app-api-gateway.service"
ynh_backup --src_path="/etc/systemd/system/$app-auth.service" ynh_backup --src_path="/etc/systemd/system/$app-auth.service"
@ -90,14 +82,20 @@ ynh_backup --src_path="/etc/systemd/system/$app-syncing-server.service"
ynh_backup --src_path="/etc/systemd/system/$app-syncing-server-worker.service" ynh_backup --src_path="/etc/systemd/system/$app-syncing-server-worker.service"
#================================================= #=================================================
# CRON LOGROTATE # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_print_info "Backing up cron configuration..."
ynh_backup --src_path="/etc/cron.d/$app" ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -29,6 +29,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway) port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth) port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker) port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
@ -39,9 +40,9 @@ port_syncing_server_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_s
config_api_gateway="$final_path/live/api-gateway.env" config_api_gateway="$final_path/live/api-gateway.env"
#================================================= #=================================================
# 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)..." --weight=33 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -49,7 +50,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
@ -77,23 +78,23 @@ fi
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --weight=2 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
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
@ -116,11 +117,11 @@ ynh_store_file_checksum --file="$config_api_gateway"
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Configuring fail2ban..." --weight=1 ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
domain=$new_domain domain=$new_domain
path_url=$new_path path_url=$new_path
# Create a dedicated fail2ban config # Create a dedicated Fail2Ban config
touch "/var/log/$app/$app.log" touch "/var/log/$app/$app.log"
ynh_add_fail2ban_config --use_template ynh_add_fail2ban_config --use_template
@ -130,7 +131,7 @@ ynh_add_fail2ban_config --use_template
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting true
} }
# 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
@ -29,11 +29,16 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
redis_db=$(ynh_redis_get_free_db)
disable_user_registration=false
files_size=100
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app final_path=/opt/yunohost/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
@ -46,15 +51,7 @@ ynh_script_progression --message="Storing installation settings..." --weight=3
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
#=================================================
# STORE SETTINGS
#=================================================
disable_user_registration=false
files_size=100
ynh_app_setting_set --app=$app --key=DISABLE_USER_REGISTRATION --value=$disable_user_registration ynh_app_setting_set --app=$app --key=DISABLE_USER_REGISTRATION --value=$disable_user_registration
ynh_app_setting_set --app=$app --key=FILES_SIZE --value=$files_size ynh_app_setting_set --app=$app --key=FILES_SIZE --value=$files_size
@ -86,7 +83,7 @@ ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_sy
ynh_script_progression --message="Installing dependencies..." --weight=17 ynh_script_progression --message="Installing dependencies..." --weight=17
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 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"
#================================================= #=================================================
@ -95,7 +92,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
ynh_script_progression --message="Configuring system user..." --weight=1 ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
@ -112,8 +109,8 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=2 ynh_script_progression --message="Setting up source files..." --weight=2
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
mkdir -p "$final_path/live"
ynh_setup_source --source_id=app --dest_dir="$final_path/live" ynh_setup_source --source_id=app --dest_dir="$final_path/live"
cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$final_path/cron.sh" cp "$YNH_APP_BASEDIR/sources/extra_files/cron.sh" "$final_path/cron.sh"
@ -124,14 +121,20 @@ chown -R $app:$app "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=3 ynh_script_progression --message="Configuring NGINX web server..." --weight=3
# Create a dedicated nginx config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# ADD SWAP
#=================================================
ynh_script_progression --message="Adding swap..."
ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
@ -142,21 +145,14 @@ ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir/uploads mkdir -p $datadir/uploads
chmod -R 750 "$datadir" chmod 750 "$datadir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir" chown -R $app:$app "$datadir"
#================================================= #=================================================
# ADD SWAP # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding swap..." ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_swap --size=$swap_needed
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=2
config_api_gateway="$final_path/live/api-gateway.env" config_api_gateway="$final_path/live/api-gateway.env"
config_auth="$final_path/live/auth.env" config_auth="$final_path/live/auth.env"
@ -193,8 +189,8 @@ ynh_script_progression --message="Installing Standard Notes - Syncing Server..."
ynh_use_nodejs ynh_use_nodejs
pushd "$final_path/live" pushd "$final_path/live"
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --immutable ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn install --immutable
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn build
popd popd
#================================================= #=================================================
@ -211,23 +207,19 @@ ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_synci
ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service" ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # SETUP A CRON
#================================================= #=================================================
ynh_script_progression --message="Storing the config file checksum..." --weight=1 ynh_script_progression --message="Setup a cron..."
# Calculate and store the config file checksum into the app settings ynh_add_config --template="../conf/cron.env" --destination="$final_path/cron.env"
ynh_store_file_checksum --file="$config_api_gateway" ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
ynh_store_file_checksum --file="$config_auth"
ynh_store_file_checksum --file="$config_auth_worker" chown root: "/etc/cron.d/$app"
ynh_store_file_checksum --file="$config_files" chmod 640 "/etc/cron.d/$app"
ynh_store_file_checksum --file="$config_syncing_server"
ynh_store_file_checksum --file="$config_syncing_server_worker"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
#=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1 ynh_script_progression --message="Configuring log rotation..." --weight=1
@ -246,7 +238,7 @@ ynh_use_logrotate --logfile="/var/log/$app/syncing-server-worker.log"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log" yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log" yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
@ -292,29 +284,18 @@ ynh_systemd_action \
--log_path="/var/log/$app/syncing-server-worker.log" \ --log_path="/var/log/$app/syncing-server-worker.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setup a cron..."
ynh_add_config --template="../conf/cron.env" --destination="$final_path/cron.env"
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 640 "/etc/cron.d/$app"
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Configuring fail2ban..." --weight=1 ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
# Create a dedicated fail2ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --use_template ynh_add_fail2ban_config --use_template
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=3 ynh_script_progression --message="Configuring permissions..." --weight=3
# Everyone can access the app. # Everyone can access the app.
# The "main" permission is automatically created before the install script. # The "main" permission is automatically created before the install script.
@ -323,7 +304,7 @@ ynh_permission_update --permission="main" --add="visitors" --show_tile="false"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -19,7 +19,6 @@ ynh_script_progression --message="Loading installation settings..." --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)
port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway) port_api_gateway=$(ynh_app_setting_get --app=$app --key=port_api_gateway)
port_auth=$(ynh_app_setting_get --app=$app --key=port_auth) port_auth=$(ynh_app_setting_get --app=$app --key=port_auth)
port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker) port_auth_worker=$(ynh_app_setting_get --app=$app --key=port_auth_worker)
@ -37,7 +36,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
# 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-api-gateway" >/dev/null if ynh_exec_warn_less yunohost service status "$app-api-gateway" >/dev/null
then then
ynh_script_progression --message="Removing $app-api-gateway service..." --weight=1 ynh_script_progression --message="Removing $app-api-gateway service..." --weight=1
@ -84,6 +83,14 @@ ynh_remove_systemd_config --service="$app-syncing-server-worker"
ynh_reset_systemd ynh_reset_systemd
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
@ -92,22 +99,13 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
##================================================= #=================================================
## REMOVE REDIS DB # REMOVE REDIS DB
##================================================= #=================================================
ynh_script_progression --message="Removing the Redis database..." --weight=1 ynh_script_progression --message="Removing the Redis database..." --weight=1
ynh_redis_remove_db ynh_redis_remove_db
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=10
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -130,37 +128,41 @@ fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 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 ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=10
# Remove the app-specific logrotate config # Remove metapackage and its dependencies
ynh_remove_logrotate ynh_remove_app_dependencies
ynh_secure_remove --file="/var/log/$app" ynh_remove_nodejs
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing fail2ban configuration..." --weight=1 ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
# Remove the dedicated fail2ban config # Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE CRON CONFIGURATION # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing cron configuration..." --weight=1 ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# REMOVE SWAP # REMOVE SWAP
#================================================= #=================================================

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 ../settings/scripts/ynh_add_swap source ../settings/scripts/ynh_add_swap
source ../settings/scripts/ynh_redis source ../settings/scripts/ynh_redis
@ -17,7 +17,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -26,7 +25,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --weight=2 ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -35,7 +34,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
redis_db=$(ynh_redis_get_free_db) redis_db=$(ynh_redis_get_free_db)
@ -54,7 +52,8 @@ config_nginx="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2 ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -79,10 +78,12 @@ ynh_app_setting_set --app=$app --key=port_syncing_server --value=$port_syncing_s
ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_syncing_server_worker ynh_app_setting_set --app=$app --key=port_syncing_server_worker --value=$port_syncing_server_worker
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
@ -91,6 +92,10 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
@ -100,40 +105,21 @@ ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p "$datadir/uploads" mkdir -p "$datadir/uploads"
#=================================================
# 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 USER RIGHTS
#=================================================
# Restore permissions on app files
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
chmod 750 "$datadir" chmod 750 "$datadir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir" chown -R $app:$app "$datadir"
mkdir -p "/var/log/$app" #=================================================
chown -R $app: "/var/log/$app" # RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#=================================================
#=================================================
# ADD SWAP
#=================================================
ynh_script_progression --message="Adding swap..."
ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
@ -141,14 +127,22 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=17
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 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"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=2 ynh_script_progression --message="Restoring the MySQL database..." --weight=2
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
@ -185,6 +179,20 @@ ynh_replace_string_on_line --line="2" --match_string="proxy_pass.*$" --replace_s
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_files" --target_file="$config_files" ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_files" --target_file="$config_files"
ynh_replace_string_on_line --line="17" --match_string="proxy_pass.*$" --replace_string="proxy_pass http://127.0.0.1:$port_files/;" --target_file="$config_nginx" ynh_replace_string_on_line --line="17" --match_string="proxy_pass.*$" --replace_string="proxy_pass http://127.0.0.1:$port_files/;" --target_file="$config_nginx"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# ADD SWAP
#=================================================
ynh_script_progression --message="Adding swap..."
ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
@ -204,10 +212,20 @@ systemctl enable $app-files.service --quiet
systemctl enable $app-syncing-server.service --quiet systemctl enable $app-syncing-server.service --quiet
systemctl enable $app-syncing-server-worker.service --quiet systemctl enable $app-syncing-server-worker.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
mkdir -p "/var/log/$app"
chown -R $app: "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log" yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log" yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
@ -252,35 +270,12 @@ ynh_systemd_action \
--log_path="/var/log/$app/syncing-server-worker.log" \ --log_path="/var/log/$app/syncing-server-worker.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$' --line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#=================================================
# RESTORE THE CRON CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring cron configuration..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the fail2ban configuration..." --weight=1
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=2 ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -20,10 +20,8 @@ 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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
@ -59,13 +57,8 @@ nodejs_version_installed=$(ynh_app_setting_get --app=$app --key=nodejs_version)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
@ -76,7 +69,7 @@ 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
@ -258,17 +251,20 @@ if [ -z "$datadir" ]; then
chown -R $app:$app "$datadir" chown -R $app:$app "$datadir"
fi fi
ynh_app_setting_set --app=$app --key=standalone --value="true"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --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"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
@ -284,32 +280,25 @@ then
chown -R $app:$app "$final_path" chown -R $app:$app "$final_path"
fi fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1
# Create a dedicated nginx config
ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_script_progression --message="Upgrading dependencies..." --weight=1
# Remove old nodejs version
if [[ "$nodejs_version_installed" < "$NODEJS_VERSION" && -n "$nodejs_version_installed" ]]
then
ynh_remove_nodejs
fi
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 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"
#================================================= #=================================================
# SPECIFIC UPGRADE # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# ADD SWAP # ADD SWAP
#================================================= #=================================================
@ -318,9 +307,9 @@ ynh_script_progression --message="Adding swap..."
ynh_add_swap --size=$swap_needed ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# MODIFY A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Modify a config file..." --weight=2 ynh_script_progression --message="Updating a configuration file..." --weight=2
ynh_add_config --template="env_api-gateway.env.sample" --destination="$config_api_gateway" ynh_add_config --template="env_api-gateway.env.sample" --destination="$config_api_gateway"
ynh_add_config --template="env_auth.env.sample" --destination="$config_auth" ynh_add_config --template="env_auth.env.sample" --destination="$config_auth"
@ -337,8 +326,8 @@ then
ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93 ynh_script_progression --message="Installing Standard Notes - Syncing Server..." --weight=93
ynh_use_nodejs ynh_use_nodejs
pushd "$final_path/live" pushd "$final_path/live"
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install --immutable ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn install --immutable
ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn build
popd popd
fi fi
@ -355,24 +344,9 @@ ynh_add_systemd_config --service="$app-files" --template="systemd_files.service"
ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_syncing-server.service" ynh_add_systemd_config --service="$app-syncing-server" --template="systemd_syncing-server.service"
ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service" ynh_add_systemd_config --service="$app-syncing-server-worker" --template="systemd_syncing-server-worker.service"
#=================================================
# 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_api_gateway"
ynh_store_file_checksum --file="$config_auth"
ynh_store_file_checksum --file="$config_auth_worker"
ynh_store_file_checksum --file="$config_files"
ynh_store_file_checksum --file="$config_syncing_server"
ynh_store_file_checksum --file="$config_syncing_server_worker"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
#=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
@ -391,7 +365,7 @@ ynh_use_logrotate --logfile="/var/log/$app/syncing-server-worker.log"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrate $app service in Yunohost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log" yunohost service add "$app-api-gateway" --description="Standard Notes - API Gateway" --log="/var/log/$app/api-gateway.log"
yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log" yunohost service add "$app-auth" --description="Standard Notes - Auth" --log="/var/log/$app/auth.log"
@ -449,25 +423,20 @@ chown root: "/etc/cron.d/$app"
chmod 640 "/etc/cron.d/$app" chmod 640 "/etc/cron.d/$app"
#================================================= #=================================================
# SETUP FAIL2BAN # UPGRADE FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Reconfiguring fail2ban..." --weight=1 ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
# Create a dedicated fail2ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --use_template ynh_add_fail2ban_config --use_template
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# STORE SETTINGS
#=================================================
ynh_app_setting_set --app=$app --key=standalone --value="true"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -91,4 +91,3 @@ ynh_is_main_device_a_sd_card () {
return 1 return 1
fi fi
} }

View file

@ -1,2 +0,0 @@
*~
*.sw[op]