diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 009b28f..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/outline/outline/archive/25e8c32b8403042b6813e2a6861f4cd16586ed69.zip -SOURCE_SUM=8bb592ae014e653752311eb0664cc7741faaeb14b7101b06c5b55d878b616658 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 787da88..e456da6 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,7 +6,7 @@ After=network.target postgresql.service redis-server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ +WorkingDirectory=__INSTALL_DIR__/ Environment="NODE_ENV=production" Environment="__YNH_NODE_LOAD_PATH__" ExecStart=__YNH_NPM__ start diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..5377af4 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,93 @@ +packaging_format = 2 + +id = "outline" +name = "Outline" +description.en = "Wiki and knowledge base for teams" +description.fr = "Wiki et base de connaissances pour les équipes" + +version = "0.69.2.2~ynh1" + +maintainers = ["Raoul de Limezy"] + +[upstream] +license = "BUSL-1.1" +website = "https://www.getoutline.com" +demo = "https://app.getoutline.com/create" +admindoc = "https://www.getoutline.com/developers" +userdoc = "https://www.getoutline.com/about" +code = "https://github.com/outline/outline" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.0.9" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = false +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + full_domain = true + + [install.init_main_permission] + type = "group" + default = "visitors" + + [install.language] + ask.en = "Choose the application language" + ask.fr = "Choisissez la langue de l'application" + type = "string" + choices = ["fr", "en"] + default = "en" + + [install.dex_domain] + ask.en = "Domain for authentication. It can't be the same domain as above. Dex app will be installed and used for the authentication mechanism." + ask.fr = "Domaine pour l'authentification. Il ne peut pas s'agir du même domaine que ci-dessus. L'application Dex sera installée et utilisée pour le mécanisme d'authentification." + type = "domain" + + [install.dex_path] + ask.en = "Path for authentication URL. Please don't use 'auth' as it will break NGINX configuration." + ask.fr = "Chemin de l'URL d'authentification. Veuillez ne pas utiliser 'auth' car cela casserait la configuration NGINX." + type = "path" + default = "/" + + [install.minio_domain] + ask.en = "Domain for MinIO app, used for images and attachments storage. If not yet installed, it will automatically be. MinIO has to be installed at the root." + ask.fr = "Domaine pour l'application MinIO, utilisé pour le stockage des images et des pièces jointes. S'il n'est pas encore installé, il le sera automatiquement. MinIO doit être installé à la racine." + type = "domain" + + [install.minio_admin] + ask.en = "Administrator for MinIO app, used for images and attachments storage. Please note that if MinIO is already installed, that setting won't be used." + ask.fr = "Administrateur pour l'application MinIO, utilisée pour le stockage des images et des pièces jointes. Veuillez noter que si MinIO est déjà installé, ce paramètre ne sera pas utilisé." + type = "user" + + [install.minio_password] + ask.en = "Password for MinIO administrator" + ask.fr = "Mot de passe pour l'administrateur MinIO" + type = "password" + +[resources] + [resources.sources.main] + url = "https://github.com/outline/outline/archive/25e8c32b8403042b6813e2a6861f4cd16586ed69.zip" + sha256 = "8bb592ae014e653752311eb0664cc7741faaeb14b7101b06c5b55d878b616658" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + [[resources.apt.extras]] + repo = "deb https://dl.yarnpkg.com/debian/ stable main" + key = "https://dl.yarnpkg.com/debian/pubkey.gpg 2>&1" + packages = "yarn" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 11978d9..cd2d226 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="postgresql" +#REMOVEME? pkg_dependencies="postgresql" NODEJS_VERSION=18 diff --git a/scripts/backup b/scripts/backup index 370370f..57a4c22 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,41 +14,41 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path_url) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -language_key=$(ynh_app_setting_get --app=$app --key=language_key) -secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) -minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) -minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) -minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) -mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) -dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) -dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) -dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) -oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) -oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) -oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) -dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) -dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) -dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? language_key=$(ynh_app_setting_get --app=$app --key=language_key) +#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +#REMOVEME? utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +#REMOVEME? minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) +#REMOVEME? minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) +#REMOVEME? minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) +#REMOVEME? mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) +#REMOVEME? dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) +#REMOVEME? dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) +#REMOVEME? dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) +#REMOVEME? oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) +#REMOVEME? oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) +#REMOVEME? oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) +#REMOVEME? dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) +#REMOVEME? dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) +#REMOVEME? dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -70,15 +70,15 @@ pushd "$mc_path" ynh_exec_warn_less sudo -u minio ./mc mirror --a minio/outlinestorage ./outlinestorage/ popd -ynh_secure_remove --file="$final_path/outlinestorage" -mv "$mc_path/outlinestorage" "$final_path/outlinestorage" -chown -R outline:www-data "$final_path/outlinestorage" +#REMOVEME? ynh_secure_remove --file="$install_dir/outlinestorage" +mv "$mc_path/outlinestorage" "$install_dir/outlinestorage" +chown -R outline:www-data "$install_dir/outlinestorage" #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 3be27d0..3e0fd8f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,71 +13,71 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path_url) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -language_key=$(ynh_app_setting_get --app=$app --key=language_key) -secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) -minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) -minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) -minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) -mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) -dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) -dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) -dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) -oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) -oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) -oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) -dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) -dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) -dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? language_key=$(ynh_app_setting_get --app=$app --key=language_key) +#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +#REMOVEME? utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +#REMOVEME? minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) +#REMOVEME? minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) +#REMOVEME? minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) +#REMOVEME? mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) +#REMOVEME? dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) +#REMOVEME? dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) +#REMOVEME? dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) +#REMOVEME? oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) +#REMOVEME? oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) +#REMOVEME? oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) +#REMOVEME? dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) +#REMOVEME? dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) +#REMOVEME? dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 +#REMOVEME? 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 -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] +#REMOVEME? change_path=0 +#REMOVEME? if [ "$old_path" != "$new_path" ] then ynh_die "Outline has to be installed on the root of a domain" fi @@ -96,38 +96,40 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_change_url_nginx_config + +#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= # UPDATING A CONFIGURATION #================================================= - +#REMOVEME? domain=$new_domain -ynh_secure_remove --file="$final_path/.env" +#REMOVEME? ynh_secure_remove --file="$install_dir/.env" ynh_script_progression --message="Updating the configuration file..." --weight=1 -ynh_add_config --template="../conf/.env" --destination="$final_path/.env" +ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" -chmod 400 "$final_path/.env" -chown $app:$app "$final_path/.env" +chmod 400 "$install_dir/.env" +chown $app:$app "$install_dir/.env" #================================================= # RUN DB MIGRATION #================================================= ynh_script_progression --message="Running DB initial migration..." --weight=3 -pushd "$final_path" +pushd "$install_dir" ynh_use_nodejs ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn db:migrate popd @@ -144,9 +146,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # SLACK WARNING diff --git a/scripts/install b/scripts/install index 4881e1f..806b309 100755 --- a/scripts/install +++ b/scripts/install @@ -13,22 +13,22 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url="/" -is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +path="/" +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -language=$YNH_APP_ARG_LANGUAGE +#REMOVEME? language=$YNH_APP_ARG_LANGUAGE if [ $language == "fr" ]; then language_key="fr_FR" @@ -41,7 +41,7 @@ fi secret_key=$(ynh_hex_32_random) utils_secret=$(ynh_hex_32_random) -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF MINIO IS INSTALLED, IF NOT INSTALL IT @@ -51,31 +51,31 @@ ynh_script_progression --message="Installing MinIO if needed..." --weight=18 if ! yunohost app list | grep -q "id: minio"; then echo "MinIO is not installed. Installing... " yunohost tools update - if yunohost app list | grep -q "$YNH_APP_ARG_MINIO_DOMAIN"; then +#REMOVEME? if yunohost app list | grep -q "$YNH_APP_ARG_MINIO_DOMAIN"; then ynh_die "The domain provided for MinIO is already used by another app. Please chose another one !" fi # FIXME hackish workaround to circumvent the linter public=public - yunohost app install https://github.com/YunoHost-Apps/minio_ynh --force --args "domain=$YNH_APP_ARG_MINIO_DOMAIN&is_$public=true&admin=$YNH_APP_ARG_MINIO_ADMIN&password=$YNH_APP_ARG_MINIO_PASSWORD" +#REMOVEME? yunohost app install https://github.com/YunoHost-Apps/minio_ynh --force --args "domain=$YNH_APP_ARG_MINIO_DOMAIN&is_$public=true&admin=$YNH_APP_ARG_MINIO_ADMIN&password=$YNH_APP_ARG_MINIO_PASSWORD" fi -minio_domain=$(ynh_app_setting_get --app="minio" --key=domain) -minio_admin=$(ynh_app_setting_get --app="minio" --key=admin) -minio_password=$(ynh_app_setting_get --app="minio" --key=password) -mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path) +#REMOVEME? minio_domain=$(ynh_app_setting_get --app="minio" --key=domain) +#REMOVEME? minio_admin=$(ynh_app_setting_get --app="minio" --key=admin) +#REMOVEME? minio_password=$(ynh_app_setting_get --app="minio" --key=password) +#REMOVEME? mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path) #================================================= # INSTALL DEX APP FOR OAUTH2 / OIDC #================================================= ynh_script_progression --message="Installing Dex..." --weight=18 -dex_domain=$YNH_APP_ARG_DEX_DOMAIN -dex_path=$YNH_APP_ARG_DEX_PATH +#REMOVEME? dex_domain=$YNH_APP_ARG_DEX_DOMAIN +#REMOVEME? dex_path=$YNH_APP_ARG_DEX_PATH oidc_secret=$(ynh_hex_32_random) oidc_name="Outline" oidc_callback="$domain/auth/oidc.callback" -if yunohost app list | grep -q "$YNH_APP_ARG_DEX_DOMAIN$YNH_APP_ARG_DEX_PATH"; then +#REMOVEME? if yunohost app list | grep -q "$YNH_APP_ARG_DEX_DOMAIN$YNH_APP_ARG_DEX_PATH"; then ynh_die "The domain provided for Dex is already used by another app. Please chose another one !" fi @@ -98,32 +98,32 @@ fi #=================================================== # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #=================================================== -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key ynh_app_setting_set --app=$app --key=utils_secret --value=$utils_secret ynh_app_setting_set --app=$app --key=language_key --value=$language_key -ynh_app_setting_set --app=$app --key=minio_domain --value=$minio_domain -ynh_app_setting_set --app=$app --key=minio_admin --value=$minio_admin -ynh_app_setting_set --app=$app --key=minio_password --value=$minio_password -ynh_app_setting_set --app=$app --key=mc_path --value=$mc_path +#REMOVEME? ynh_app_setting_set --app=$app --key=minio_domain --value=$minio_domain +#REMOVEME? ynh_app_setting_set --app=$app --key=minio_admin --value=$minio_admin +#REMOVEME? ynh_app_setting_set --app=$app --key=minio_password --value=$minio_password +#REMOVEME? ynh_app_setting_set --app=$app --key=mc_path --value=$mc_path ynh_app_setting_set --app=$app --key=dex_app --value=$dex_app -ynh_app_setting_set --app=$app --key=dex_domain --value=$dex_domain -ynh_app_setting_set --app=$app --key=dex_path --value=$dex_path +#REMOVEME? ynh_app_setting_set --app=$app --key=dex_domain --value=$dex_domain +#REMOVEME? ynh_app_setting_set --app=$app --key=dex_path --value=$dex_path ynh_app_setting_set --app=$app --key=oidc_name --value=$oidc_name ynh_app_setting_set --app=$app --key=oidc_secret --value=$oidc_secret ynh_app_setting_set --app=$app --key=oidc_callback --value=$oidc_callback @@ -136,42 +136,42 @@ ynh_app_setting_set --app=$app --key=dex_user_uri --value=$dex_user_uri #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 +#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port -port=$(ynh_find_port --port=2410) -ynh_app_setting_set --app=$app --key=port --value=$port +#REMOVEME? port=$(ynh_find_port --port=2410) +#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 # Install nodejs ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1 -ynh_install_app_dependencies $pkg_dependencies 2>&1 +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies 2>&1 # Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" 2>&1 +#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" 2>&1 #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 +#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 -db_name=$(ynh_sanitize_dbid --db_name=$app) -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$secret_key +#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$secret_key ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name @@ -181,13 +181,13 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --datab #================================================= ynh_script_progression --message="Setting up source files..." --weight=2 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # SETUP MINIO BUCKET @@ -215,9 +215,9 @@ ynh_add_nginx_config # BUILD YARN DEPENDENCIES #================================================= -pushd "$final_path" +pushd "$install_dir" ynh_use_nodejs - ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --weight=18 +#REMOVEME? ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --weight=18 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --frozen-lockfile --network-timeout 1000000000 2>&1 ynh_script_progression --message="Building... This can be very long, be patient !" --weight=18 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_OPTIONS="--max-old-space-size=3000" yarn build 2>&1 @@ -230,17 +230,17 @@ popd #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/.env" --destination="$final_path/.env" +ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" -chmod 400 "$final_path/.env" -chown $app:$app "$final_path/.env" +chmod 400 "$install_dir/.env" +chown $app:$app "$install_dir/.env" #================================================= # RUN DB MIGRATION #================================================= ynh_script_progression --message="Running DB initial migration..." --weight=3 -pushd "$final_path" +pushd "$install_dir" ynh_use_nodejs ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn db:migrate popd @@ -281,21 +281,21 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary -if [ $is_public -eq 1 ] +#REMOVEME? if [ $is_public -eq 1 ] then - ynh_permission_update --permission="main" --add="visitors" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi ynh_permission_url --permission="main" --auth_header=false #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 2baf0b1..4b23842 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,31 +12,31 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path_url) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -language_key=$(ynh_app_setting_get --app=$app --key=language_key) -secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) -minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) -minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) -minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) -mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) -dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) -dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) -dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) -oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) -oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) -oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) -dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) -dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) -dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? language_key=$(ynh_app_setting_get --app=$app --key=language_key) +#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +#REMOVEME? utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +#REMOVEME? minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) +#REMOVEME? minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) +#REMOVEME? minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) +#REMOVEME? mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) +#REMOVEME? dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) +#REMOVEME? dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) +#REMOVEME? dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) +#REMOVEME? oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) +#REMOVEME? oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) +#REMOVEME? oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) +#REMOVEME? dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) +#REMOVEME? dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) +#REMOVEME? dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) #================================================= # STANDARD REMOVE @@ -70,27 +70,27 @@ ynh_remove_logrotate #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." +#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_name --db_name=$db_name +#REMOVEME? ynh_psql_remove_db --db_user=$db_name --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies ynh_remove_nodejs #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE DEX APP @@ -122,10 +122,10 @@ ynh_remove_nginx_config #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 815c140..ebb21bd 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,49 +14,49 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { #### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path_url) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -language_key=$(ynh_app_setting_get --app=$app --key=language_key) -secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) -minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) -minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) -minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) -mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) -dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) -dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) -dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) -oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) -oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) -oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) -dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) -dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) -dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? language_key=$(ynh_app_setting_get --app=$app --key=language_key) +#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +#REMOVEME? utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +#REMOVEME? minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) +#REMOVEME? minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) +#REMOVEME? minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) +#REMOVEME? mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) +#REMOVEME? dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) +#REMOVEME? dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) +#REMOVEME? dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) +#REMOVEME? oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) +#REMOVEME? oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) +#REMOVEME? oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) +#REMOVEME? dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) +#REMOVEME? dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) +#REMOVEME? dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path" +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir" #================================================= # CHECK IF DEX IS INSTALLED, IF NOT INSTALL IT @@ -100,27 +100,27 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +#REMOVEME? 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" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE MINIO #================================================= -mv "$final_path/outlinestorage" "$mc_path/outlinestorage" +mv "$install_dir/outlinestorage" "$mc_path/outlinestorage" chown -R minio:www-data "$mc_path/outlinestorage" ynh_add_config --template="../conf/policy.json" --destination="$mc_path/policy.json" @@ -138,36 +138,36 @@ ynh_secure_remove --file="$mc_path/outlinestorage" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Install nodejs ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1 -ynh_install_app_dependencies $pkg_dependencies 2>&1 +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies 2>&1 # Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#REMOVEME? 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 POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 +#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$secret_key +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$secret_key ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # UPDATING A CONFIGURATION #================================================= -ynh_secure_remove --file="$final_path/.env" +#REMOVEME? ynh_secure_remove --file="$install_dir/.env" ynh_script_progression --message="Updating the configuration file..." --weight=1 -ynh_add_config --template="../conf/.env" --destination="$final_path/.env" +ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" -chmod 400 "$final_path/.env" -chown $app:$app "$final_path/.env" +chmod 400 "$install_dir/.env" +chown $app:$app "$install_dir/.env" #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index a44c16d..23ac2d9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,31 +12,31 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path_url) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -language_key=$(ynh_app_setting_get --app=$app --key=language_key) -secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) -minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) -minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) -minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) -mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) -dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) -dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) -dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) -oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) -oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) -oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) -dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) -dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) -dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? language_key=$(ynh_app_setting_get --app=$app --key=language_key) +#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +#REMOVEME? utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret) +#REMOVEME? minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain) +#REMOVEME? minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin) +#REMOVEME? minio_password=$(ynh_app_setting_get --app=$app --key=minio_password) +#REMOVEME? mc_path=$(ynh_app_setting_get --app=$app --key=mc_path) +#REMOVEME? dex_app=$(ynh_app_setting_get --app=$app --key=dex_app) +#REMOVEME? dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain) +#REMOVEME? dex_path=$(ynh_app_setting_get --app=$app --key=dex_path) +#REMOVEME? oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret) +#REMOVEME? oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name) +#REMOVEME? oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback) +#REMOVEME? dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri) +#REMOVEME? dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri) +#REMOVEME? dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri) #================================================= # CHECK VERSION @@ -47,20 +47,20 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Ugly fix for an early mistake - to be removed with next upgrade -ynh_secure_remove --file="$final_path/outlinestorage" +#REMOVEME? ynh_secure_remove --file="$install_dir/outlinestorage" ynh_secure_remove --file="$mc_path/outlinestorage" # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -74,10 +74,10 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -88,12 +88,12 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --full_replace=1 + ynh_setup_source --dest_dir="$install_dir" --full_replace=1 fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # UPDATE MINIO BUCKET @@ -118,24 +118,24 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1 # Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" 2>&1 +#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" 2>&1 #================================================= # UPGRADE YARN DEPENDENCIES #================================================= -ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=10 +#REMOVEME? ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=10 -pushd "$final_path" +pushd "$install_dir" ynh_use_nodejs - ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --weight=18 +#REMOVEME? ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --weight=18 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --frozen-lockfile --network-timeout 1000000000 2>&1 ynh_script_progression --message="Building... This can be very long, be patient !" --weight=18 ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_OPTIONS="--max-old-space-size=3000" yarn build 2>&1 @@ -148,17 +148,17 @@ popd #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/.env" --destination="$final_path/.env" +ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" -chmod 400 "$final_path/.env" -chown $app:$app "$final_path/.env" +chmod 400 "$install_dir/.env" +chown $app:$app "$install_dir/.env" #================================================= # RUN DB MIGRATION #================================================= ynh_script_progression --message="Running DB initial migration..." -pushd "$final_path" +pushd "$install_dir" ynh_use_nodejs ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn db:migrate popd @@ -198,9 +198,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT