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

switch to helpers_2.1

This commit is contained in:
Thomas 2024-06-27 20:48:13 +02:00 committed by GitHub
parent 73e60dbdc2
commit 6756285a45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 333 additions and 380 deletions

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="CHAT_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/chat/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/chat/app.js
StandardOutput=append:/var/log/__APP__/chat.log
StandardError=inherit
Restart=on-failure

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="CLSI_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/clsi/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/clsi/app.js
StandardOutput=append:/var/log/__APP__/clsi.log
StandardError=inherit
Restart=on-failure

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="CONTACTS_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/contacts/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/contacts/app.js
StandardOutput=append:/var/log/__APP__/contacts.log
StandardError=inherit
Restart=on-failure

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="DOCSTORE_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/docstore/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/docstore/app.js
StandardOutput=append:/var/log/__APP__/docstore.log
StandardError=inherit
Restart=on-failure

View file

@ -11,7 +11,7 @@ EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="DOCUMENT_UPDATER_HOST=127.0.0.1"
Environment="DOCUPDATER_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/document-updater/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/document-updater/app.js
StandardOutput=append:/var/log/__APP__/document-updater.log
StandardError=inherit
Restart=on-failure

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="FILESTORE_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/filestore/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/filestore/app.js
StandardOutput=append:/var/log/__APP__/filestore.log
StandardError=inherit
Restart=on-failure

View file

@ -11,7 +11,7 @@ EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="HISTORY_V1_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
Environment="NODE_CONFIG_DIR=__INSTALL_DIR__/live/services/history-v1/config"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/history-v1/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/history-v1/app.js
StandardOutput=append:/var/log/__APP__/history-v1.log
StandardError=inherit
Restart=on-failure

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="NOTIFICATIONS_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/notifications/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/notifications/app.js
StandardOutput=append:/var/log/__APP__/notifications.log
StandardError=inherit
Restart=on-failure

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/variables.env
Environment="PROJECT_HISTORY_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/project-history/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/project-history/app.js
StandardOutput=append:/var/log/__APP__/project-history.log
StandardError=inherit
Restart=on-failure

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
Environment="REALTIME_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/real-time/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/real-time/app.js
StandardOutput=append:/var/log/__APP__/real-time.log
StandardError=inherit
Restart=on-failure

View file

@ -10,7 +10,7 @@ WorkingDirectory=__INSTALL_DIR__/
Environment="SPELLING_HOST=127.0.0.1"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/spelling/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/spelling/app.js
StandardOutput=append:/var/log/__APP__/spelling.log
StandardError=inherit
Restart=on-failure

View file

@ -12,7 +12,7 @@ Environment="WEB_API_HOST=127.0.0.1"
Environment="WEB_PORT=__PORT__"
Environment="MONGO_CONNECTION_STRING=mongodb://127.0.0.1:27017/__DB_NAME__"
EnvironmentFile=__INSTALL_DIR__/variables.env
ExecStart=__YNH_NODE__ __INSTALL_DIR__/live/services/web/app.js
ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/live/services/web/app.js
StandardOutput=append:/var/log/__APP__/web.log
StandardError=inherit
Restart=on-failure

View file

@ -103,4 +103,4 @@ OT_JWT_AUTH_KEY=__JWT_KEY__
# TEX_LIVE_DOCKER_IMAGE=quay.io/OVERLEAF/texlive-full:2021.1
# ALL_TEX_LIVE_DOCKER_IMAGES=quay.io/OVERLEAF/texlive-full:2021.1,quay.io/OVERLEAF/texlive-full:2020.1
# OVERLEAF_PROXY_LEARN=true
# OVERLEAF_PROXY_LEARN=true

View file

@ -18,7 +18,8 @@ userdoc = "https://www.overleaf.com/learn"
code = "https://github.com/overleaf/overleaf"
[integration]
yunohost = ">= 11.2.13"
yunohost = ">= 11.2.17"
helpers_version = "2.1"
architectures = ["amd64"]
multi_instance = false
@ -93,4 +94,4 @@ ram.runtime = "3G"
# clsi dependencies
"poppler-utils",
]
]

View file

@ -1,13 +1,5 @@
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
nodejs_version="20"
YNH_MONGO_VERSION="7.0"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
mongo_version="7.0"

View file

@ -1,37 +1,28 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$data_dir" --is_big
ynh_backup "$data_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
@ -39,34 +30,34 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app-chat.service"
ynh_backup --src_path="/etc/systemd/system/$app-clsi.service"
ynh_backup --src_path="/etc/systemd/system/$app-contacts.service"
ynh_backup --src_path="/etc/systemd/system/$app-docstore.service"
ynh_backup --src_path="/etc/systemd/system/$app-document-updater.service"
ynh_backup --src_path="/etc/systemd/system/$app-filestore.service"
ynh_backup --src_path="/etc/systemd/system/$app-history-v1.service"
ynh_backup --src_path="/etc/systemd/system/$app-notifications.service"
ynh_backup --src_path="/etc/systemd/system/$app-project-history.service"
ynh_backup --src_path="/etc/systemd/system/$app-real-time.service"
ynh_backup --src_path="/etc/systemd/system/$app-spelling.service"
ynh_backup --src_path="/etc/systemd/system/$app-web.service"
ynh_backup "/etc/systemd/system/$app-chat.service"
ynh_backup "/etc/systemd/system/$app-clsi.service"
ynh_backup "/etc/systemd/system/$app-contacts.service"
ynh_backup "/etc/systemd/system/$app-docstore.service"
ynh_backup "/etc/systemd/system/$app-document-updater.service"
ynh_backup "/etc/systemd/system/$app-filestore.service"
ynh_backup "/etc/systemd/system/$app-history-v1.service"
ynh_backup "/etc/systemd/system/$app-notifications.service"
ynh_backup "/etc/systemd/system/$app-project-history.service"
ynh_backup "/etc/systemd/system/$app-real-time.service"
ynh_backup "/etc/systemd/system/$app-spelling.service"
ynh_backup "/etc/systemd/system/$app-web.service"
#=================================================
# BACKUP THE MONGODB DATABASE
#=================================================
ynh_print_info --message="Backing up the MongoDB database..."
ynh_print_info "Backing up the MongoDB database..."
ynh_mongo_dump_db --database="$db_name" > ./dump.bson
ynh_mongo_dump_db > ./dump.bson
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,81 +1,82 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app-chat" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-clsi" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-contacts" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-docstore" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-document-updater" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-filestore" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-history-v1" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-notifications" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-project-history" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-real-time" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-spelling" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app-chat" --action="stop"
ynh_systemctl --service="$app-clsi" --action="stop"
ynh_systemctl --service="$app-contacts" --action="stop"
ynh_systemctl --service="$app-docstore" --action="stop"
ynh_systemctl --service="$app-document-updater" --action="stop"
ynh_systemctl --service="$app-filestore" --action="stop"
ynh_systemctl --service="$app-history-v1" --action="stop"
ynh_systemctl --service="$app-notifications" --action="stop"
ynh_systemctl --service="$app-project-history" --action="stop"
ynh_systemctl --service="$app-real-time" --action="stop"
ynh_systemctl --service="$app-spelling" --action="stop"
ynh_systemctl --service="$app-web" --action="stop"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..."
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_script_progression "Updating configuration..."
domain=$new_domain
path=$new_path
ynh_add_config --template="../conf/variables.env" --destination="$install_dir/variables.env"
ynh_config_add --template="variables.env" --destination="$install_dir/variables.env"
chmod 400 "$install_dir/variables.env"
chown $app:$app "$install_dir/variables.env"
ynh_add_config --template="../conf/settings.js" --destination="$install_dir/settings.js"
ynh_config_add --template="settings.js" --destination="$install_dir/settings.js"
chmod 400 "$install_dir/settings.js"
chown $app:$app "$install_dir/settings.js"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --line_match="Loading backend"
ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="Using settings from"
ynh_systemctl --service="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --wait_until="Loading backend"
ynh_systemctl --service="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-web" --action="start" --log_path="/var/log/$app/web.log" --wait_until="listening on" --wait_until="Using settings from"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app"
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -13,34 +7,32 @@ web_api_password=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2-
crypto_random=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/')
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
ynh_app_setting_set --app=$app --key=crypto_random --value=$crypto_random
ynh_app_setting_set --app=$app --key=web_api_password --value=$web_api_password
ynh_app_setting_set --key=crypto_random --value=$crypto_random
ynh_app_setting_set --key=web_api_password --value=$web_api_password
# key for the .env __JWT_KEY__
jwt_key=$(ynh_string_random --length=45 | base64)
ynh_app_setting_set --app=$app --key=jwt_key --value=$jwt_key
ynh_app_setting_set --key=jwt_key --value=$jwt_key
# Retrieve YunoHost main domain for mails to work
main_domain=$(cat /etc/yunohost/current_host)
ynh_app_setting_set --app=$app --key=main_domain --value=$main_domain
ynh_app_setting_set --key=main_domain --value=$main_domain
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_nodejs_install
ynh_install_mongo
#=================================================
# CREATE A MONGODB DATABASE
#=================================================
ynh_script_progression --message="Creating a MongoDB database..."
ynh_script_progression "Creating a MongoDB database..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --key=db_name --value=$db_name
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
@ -48,21 +40,21 @@ ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring MongoDB..." --weight=10
ynh_script_progression "Configuring MongoDB..."
ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs0" --target_file="/etc/mongod.conf"
ynh_replace --match="#replication:" --replace="replication:\n replSetName: rs0" --file="/etc/mongod.conf"
ynh_exec_warn_less systemctl enable mongod --quiet
ynh_systemd_action --service_name=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --line_match="Waiting for connections"
ynh_hide_warnings systemctl enable mongod --quiet
ynh_systemctl --service=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --wait_until="Waiting for connections"
if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
if ynh_hide_warnings ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_hide_warnings ynh_mongo_exec --command="printjson(rs.initiate())" --eval
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir/build"
@ -77,17 +69,17 @@ chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
ynh_script_progression "Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
ynh_script_progression "Creating a data directory..."
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
@ -96,20 +88,20 @@ chown -R $app:www-data "$data_dir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_script_progression "Adding $app's configuration..."
ynh_add_config --template="../conf/variables.env" --destination="$install_dir/variables.env"
ynh_config_add --template="variables.env" --destination="$install_dir/variables.env"
chmod 400 "$install_dir/variables.env"
chown $app:$app "$install_dir/variables.env"
ynh_add_config --template="../conf/settings.js" --destination="$install_dir/settings.js"
ynh_config_add --template="settings.js" --destination="$install_dir/settings.js"
chmod 400 "$install_dir/settings.js"
chown $app:$app "$install_dir/settings.js"
#=================================================
# BUILDING APP
#=================================================
ynh_script_progression --message="Preparing app..."
ynh_script_progression "Preparing app..."
mkdir -p "$install_dir/live"
cp "$install_dir/build/server-ce/genScript.js" "$install_dir/live/genScript.js"
@ -120,30 +112,30 @@ cp -r "$install_dir/build/libraries/" "$install_dir/live/libraries/"
cp -r "$install_dir/build/services/" "$install_dir/live/services/"
cp -r "$install_dir/build/patches/" "$install_dir/live/patches/"
cp -r "$install_dir/build/server-ce/config" "$install_dir/config/"
ynh_secure_remove --file="$install_dir/config/settings.js"
ynh_secure_remove --file="$install_dir/config/production.json"
ynh_safe_rm "$install_dir/config/settings.js"
ynh_safe_rm "$install_dir/config/production.json"
ynh_add_config --template="../conf/production.json" --destination="$install_dir/config/production.json"
ynh_add_config --template="../conf/production.json" --destination="$install_dir/live/services/history-v1/config/production.json"
ynh_config_add --template="production.json" --destination="$install_dir/config/production.json"
ynh_config_add --template="production.json" --destination="$install_dir/live/services/history-v1/config/production.json"
cp "$install_dir/build/server-ce/config/custom-environment-variables.json" "$install_dir/live/services/history-v1/config/"
ynh_secure_remove --file="$install_dir/build"
ynh_safe_rm "$install_dir/build"
ynh_script_progression --message="Building app... This may take a LOT of time depending of your CPU" --weight=25
ynh_script_progression "Building app... This may take a LOT of time depending of your CPU"
pushd "$install_dir/live"
ynh_use_nodejs
ynh_exec_warn_less npm cache clean --force
ynh_exec_warn_less npm install
ynh_exec_warn_less npm ci
ynh_hide_warnings npm cache clean --force
ynh_hide_warnings npm install
ynh_hide_warnings npm ci
popd
pushd "$install_dir/live/services/web"
ynh_exec_warn_less npm run webpack:production
ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache"
ynh_hide_warnings npm run webpack:production
ynh_safe_rm "$install_dir/live/services/web/node_modules/.cache"
popd
# remove build dir
ynh_secure_remove "$install_dir/build"
ynh_safe_rm "$install_dir/build"
chmod 750 "$install_dir/live"
chmod -R o-rwx "$install_dir/live"
@ -158,38 +150,36 @@ chown -R $app:www-data "$install_dir/tmp"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
ynh_script_progression "Configuring $app's systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config --service="$app-chat" --template="overleaf-chat.service"
ynh_add_systemd_config --service="$app-clsi" --template="overleaf-clsi.service"
ynh_add_systemd_config --service="$app-contacts" --template="overleaf-contacts.service"
ynh_add_systemd_config --service="$app-docstore" --template="overleaf-docstore.service"
ynh_add_systemd_config --service="$app-document-updater" --template="overleaf-document-updater.service"
ynh_add_systemd_config --service="$app-filestore" --template="overleaf-filestore.service"
ynh_add_systemd_config --service="$app-history-v1" --template="overleaf-history-v1.service"
ynh_add_systemd_config --service="$app-notifications" --template="overleaf-notifications.service"
ynh_add_systemd_config --service="$app-project-history" --template="overleaf-project-history.service"
ynh_add_systemd_config --service="$app-real-time" --template="overleaf-real-time.service"
ynh_add_systemd_config --service="$app-spelling" --template="overleaf-spelling.service"
ynh_add_systemd_config --service="$app-web" --template="overleaf-web.service"
ynh_config_add_systemd --service="$app-chat" --template="overleaf-chat.service"
ynh_config_add_systemd --service="$app-clsi" --template="overleaf-clsi.service"
ynh_config_add_systemd --service="$app-contacts" --template="overleaf-contacts.service"
ynh_config_add_systemd --service="$app-docstore" --template="overleaf-docstore.service"
ynh_config_add_systemd --service="$app-document-updater" --template="overleaf-document-updater.service"
ynh_config_add_systemd --service="$app-filestore" --template="overleaf-filestore.service"
ynh_config_add_systemd --service="$app-history-v1" --template="overleaf-history-v1.service"
ynh_config_add_systemd --service="$app-notifications" --template="overleaf-notifications.service"
ynh_config_add_systemd --service="$app-project-history" --template="overleaf-project-history.service"
ynh_config_add_systemd --service="$app-real-time" --template="overleaf-real-time.service"
ynh_config_add_systemd --service="$app-spelling" --template="overleaf-spelling.service"
ynh_config_add_systemd --service="$app-web" --template="overleaf-web.service"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..."
ynh_script_progression "Configuring log rotation..."
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
ynh_config_add_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add "$app-chat" --log="/var/log/$app/chat.log"
yunohost service add "$app-clsi" --log="/var/log/$app/clsi.log"
@ -207,23 +197,24 @@ yunohost service add "$app-web" --log="/var/log/$app/web.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --line_match="Loading backend"
ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="Using settings from"
ynh_systemctl --service="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --wait_until="Loading backend"
ynh_systemctl --service="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-web" --action="start" --log_path="/var/log/$app/web.log" --wait_until="listening on" --wait_until="Using settings from"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"
ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -14,67 +8,67 @@ source /usr/share/yunohost/helpers
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
ynh_script_progression "Stopping and removing the systemd service..."
# 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-chat" >/dev/null
if ynh_hide_warnings yunohost service status "$app-chat" >/dev/null
then
ynh_script_progression --message="Removing $app-chat service integration..."
ynh_script_progression "Removing $app-chat service integration..."
yunohost service remove "$app-chat"
fi
if ynh_exec_warn_less yunohost service status "$app-clsi" >/dev/null
if ynh_hide_warnings yunohost service status "$app-clsi" >/dev/null
then
ynh_script_progression --message="Removing $app-clsi service integration..."
ynh_script_progression "Removing $app-clsi service integration..."
yunohost service remove "$app-clsi"
fi
if ynh_exec_warn_less yunohost service status "$app-contacts" >/dev/null
if ynh_hide_warnings yunohost service status "$app-contacts" >/dev/null
then
ynh_script_progression --message="Removing $app-contacts service integration..."
ynh_script_progression "Removing $app-contacts service integration..."
yunohost service remove "$app-contacts"
fi
if ynh_exec_warn_less yunohost service status "$app-docstore" >/dev/null
if ynh_hide_warnings yunohost service status "$app-docstore" >/dev/null
then
ynh_script_progression --message="Removing $app-docstore service integration..."
ynh_script_progression "Removing $app-docstore service integration..."
yunohost service remove "$app-docstore"
fi
if ynh_exec_warn_less yunohost service status "$app-document-updater" >/dev/null
if ynh_hide_warnings yunohost service status "$app-document-updater" >/dev/null
then
ynh_script_progression --message="Removing $app-document-updater service integration..."
ynh_script_progression "Removing $app-document-updater service integration..."
yunohost service remove "$app-document-updater"
fi
if ynh_exec_warn_less yunohost service status "$app-filestore" >/dev/null
if ynh_hide_warnings yunohost service status "$app-filestore" >/dev/null
then
ynh_script_progression --message="Removing $app-filestore service integration..."
ynh_script_progression "Removing $app-filestore service integration..."
yunohost service remove "$app-filestore"
fi
if ynh_exec_warn_less yunohost service status "$app-history-v1" >/dev/null
if ynh_hide_warnings yunohost service status "$app-history-v1" >/dev/null
then
ynh_script_progression --message="Removing $app-history-v1 service integration..."
ynh_script_progression "Removing $app-history-v1 service integration..."
yunohost service remove "$app-history-v1"
fi
if ynh_exec_warn_less yunohost service status "$app-notifications" >/dev/null
if ynh_hide_warnings yunohost service status "$app-notifications" >/dev/null
then
ynh_script_progression --message="Removing $app-notifications service integration..."
ynh_script_progression "Removing $app-notifications service integration..."
yunohost service remove "$app-notifications"
fi
if ynh_exec_warn_less yunohost service status "$app-project-history" >/dev/null
if ynh_hide_warnings yunohost service status "$app-project-history" >/dev/null
then
ynh_script_progression --message="Removing $app-project-history service integration..."
ynh_script_progression "Removing $app-project-history service integration..."
yunohost service remove "$app-project-history"
fi
if ynh_exec_warn_less yunohost service status "$app-real-time" >/dev/null
if ynh_hide_warnings yunohost service status "$app-real-time" >/dev/null
then
ynh_script_progression --message="Removing $app-real-time service integration..."
ynh_script_progression "Removing $app-real-time service integration..."
yunohost service remove "$app-real-time"
fi
if ynh_exec_warn_less yunohost service status "$app-spelling" >/dev/null
if ynh_hide_warnings yunohost service status "$app-spelling" >/dev/null
then
ynh_script_progression --message="Removing $app-spelling service integration..."
ynh_script_progression "Removing $app-spelling service integration..."
yunohost service remove "$app-spelling"
fi
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null
if ynh_hide_warnings yunohost service status "$app-web" >/dev/null
then
ynh_script_progression --message="Removing $app-web service integration..."
ynh_script_progression "Removing $app-web service integration..."
yunohost service remove "$app-web"
fi
@ -82,57 +76,57 @@ fi
# STOP AND REMOVE SERVICE
#=================================================
# Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-chat"
ynh_remove_systemd_config --service="$app-clsi"
ynh_remove_systemd_config --service="$app-contacts"
ynh_remove_systemd_config --service="$app-docstore"
ynh_remove_systemd_config --service="$app-document-updater"
ynh_remove_systemd_config --service="$app-filestore"
ynh_remove_systemd_config --service="$app-history-v1"
ynh_remove_systemd_config --service="$app-notifications"
ynh_remove_systemd_config --service="$app-project-history"
ynh_remove_systemd_config --service="$app-real-time"
ynh_remove_systemd_config --service="$app-spelling"
ynh_remove_systemd_config --service="$app-web"
ynh_config_remove_systemd"$app-chat"
ynh_config_remove_systemd"$app-clsi"
ynh_config_remove_systemd"$app-contacts"
ynh_config_remove_systemd"$app-docstore"
ynh_config_remove_systemd"$app-document-updater"
ynh_config_remove_systemd"$app-filestore"
ynh_config_remove_systemd"$app-history-v1"
ynh_config_remove_systemd"$app-notifications"
ynh_config_remove_systemd"$app-project-history"
ynh_config_remove_systemd"$app-real-time"
ynh_config_remove_systemd"$app-spelling"
ynh_config_remove_systemd"$app-web"
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
ynh_script_progression "Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate
#=================================================
# REMOVE THE MONGODB DATABASE
#=================================================
ynh_script_progression --message="Removing the MongoDB database..."
ynh_script_progression "Removing the MongoDB database..."
# Remove a database if it exists, along with the associated user
ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name
ynh_replace_string --match_string="replication:" --replace_string="#replication:" --target_file="/etc/mongod.conf"
ynh_replace_string --match_string=" replSetName: rs0" --replace_string="" --target_file="/etc/mongod.conf"
ynh_replace --match="replication:" --replace="#replication:" --file="/etc/mongod.conf"
ynh_replace --match=" replSetName: rs0" --replace="" --file="/etc/mongod.conf"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
ynh_script_progression "Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
ynh_script_progression "Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_mongo
ynh_remove_nodejs
ynh_nodejs_remove
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed"
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -14,17 +8,17 @@ source /usr/share/yunohost/helpers
# INSTALL DEPENDENCIES
#=================================================
ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_nodejs_install
ynh_install_mongo
#=================================================
# CREATE A MONGODB DATABASE
#=================================================
ynh_script_progression --message="Creating a MongoDB database..."
ynh_script_progression "Creating a MongoDB database..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --key=db_name --value=$db_name
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
@ -32,15 +26,15 @@ ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring MongoDB..." --weight=10
ynh_script_progression "Configuring MongoDB..."
ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs0" --target_file="/etc/mongod.conf"
ynh_replace --match="#replication:" --replace="replication:\n replSetName: rs0" --file="/etc/mongod.conf"
ynh_exec_warn_less systemctl enable mongod --quiet
ynh_systemd_action --service_name=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --line_match="Waiting for connections"
ynh_hide_warnings systemctl enable mongod --quiet
ynh_systemctl --service=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --wait_until="Waiting for connections"
if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
if ynh_hide_warnings ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_hide_warnings ynh_mongo_exec --command="printjson(rs.initiate())" --eval
fi
#=================================================
@ -48,16 +42,16 @@ fi
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_script_progression "Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
ynh_restore "$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
@ -66,9 +60,9 @@ chown -R $app:www-data "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..."
ynh_script_progression "Restoring the data directory..."
ynh_restore_file --origin_path="$data_dir" --not_mandatory
ynh_restore "$data_dir"
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
@ -77,55 +71,55 @@ chown -R $app:www-data "$data_dir"
#=================================================
# RESTORE THE MONGODB DATABASE
#=================================================
ynh_script_progression --message="Restoring the MongoDB database..."
ynh_script_progression "Restoring the MongoDB database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
db_pwd=$(ynh_app_setting_get --key=db_pwd)
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mongo_restore_db --database="$db_name" < ./dump.bson
ynh_mongo_restore_db < ./dump.bson
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_script_progression "Restoring $app's systemd service..."
ynh_restore_file --origin_path="/etc/systemd/system/$app-chat.service"
ynh_restore "/etc/systemd/system/$app-chat.service"
systemctl enable $app-chat.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-clsi.service"
ynh_restore "/etc/systemd/system/$app-clsi.service"
systemctl enable $app-clsi.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-contacts.service"
ynh_restore "/etc/systemd/system/$app-contacts.service"
systemctl enable $app-contacts.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-docstore.service"
ynh_restore "/etc/systemd/system/$app-docstore.service"
systemctl enable $app-docstore.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-document-updater.service"
ynh_restore "/etc/systemd/system/$app-document-updater.service"
systemctl enable $app-document-updater.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-filestore.service"
ynh_restore "/etc/systemd/system/$app-filestore.service"
systemctl enable $app-filestore.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-history-v1.service"
ynh_restore "/etc/systemd/system/$app-history-v1.service"
systemctl enable $app-history-v1.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-notifications.service"
ynh_restore "/etc/systemd/system/$app-notifications.service"
systemctl enable $app-notifications.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-project-history.service"
ynh_restore "/etc/systemd/system/$app-project-history.service"
systemctl enable $app-project-history.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-real-time.service"
ynh_restore "/etc/systemd/system/$app-real-time.service"
systemctl enable $app-real-time.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-spelling.service"
ynh_restore "/etc/systemd/system/$app-spelling.service"
systemctl enable $app-spelling.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
ynh_restore "/etc/systemd/system/$app-web.service"
systemctl enable $app-web.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_script_progression "Restoring the logrotate configuration..."
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add "$app-chat" --log="/var/log/$app/chat.log"
yunohost service add "$app-clsi" --log="/var/log/$app/clsi.log"
@ -143,32 +137,30 @@ yunohost service add "$app-web" --log="/var/log/$app/web.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --line_match="Loading backend"
ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="Using settings from"
ynh_systemctl --service="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --wait_until="Loading backend"
ynh_systemctl --service="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-web" --action="start" --log_path="/var/log/$app/web.log" --wait_until="listening on" --wait_until="Using settings from"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_script_progression "Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"
ynh_script_progression "Restoration completed for $app"

View file

@ -1,20 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
ynh_script_progression "Checking version..."
# Retrieve YunoHost main domain for mails to work
main_domain=$(cat /etc/yunohost/current_host)
@ -23,72 +12,78 @@ main_domain=$(cat /etc/yunohost/current_host)
# LOAD SETTINGS
#=================================================
if [ -z "${jwt_key:-}" ]; then
jwt_key=$(ynh_string_random --length=45 | base64)
ynh_app_setting_set --app=$app --key=jwt_key --value=$jwt_key
fi
ynh_app_setting_set_default --key=jwt_key --value=$(ynh_string_random --length=45 | base64)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app-chat" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-clsi" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-contacts" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-docstore" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-document-updater" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-filestore" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-history-v1" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-notifications" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-project-history" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-real-time" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-spelling" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app-chat" --action="stop"
if ynh_exec_warn_less yunohost service status "$app-track-changes" >/dev/null
ynh_systemctl --service="$app-clsi" --action="stop"
ynh_systemctl --service="$app-contacts" --action="stop"
ynh_systemctl --service="$app-docstore" --action="stop"
ynh_systemctl --service="$app-document-updater" --action="stop"
ynh_systemctl --service="$app-filestore" --action="stop"
ynh_systemctl --service="$app-history-v1" --action="stop"
ynh_systemctl --service="$app-notifications" --action="stop"
ynh_systemctl --service="$app-project-history" --action="stop"
ynh_systemctl --service="$app-real-time" --action="stop"
ynh_systemctl --service="$app-spelling" --action="stop"
ynh_systemctl --service="$app-web" --action="stop"
if ynh_hide_warnings yunohost service status "$app-track-changes" >/dev/null
then
ynh_script_progression --message="Removing $app-track-changes service integration..."
ynh_script_progression "Removing $app-track-changes service integration..."
yunohost service remove "$app-track-changes"
fi
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
ynh_script_progression "Ensuring downward compatibility..."
#=================================================
# SPECIFIC SETUP
#=================================================
# CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring MongoDB..." --weight=10
ynh_script_progression "Configuring MongoDB..."
ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs0" --target_file="/etc/mongod.conf"
ynh_replace --match="#replication:" --replace="replication:\n replSetName: rs0" --file="/etc/mongod.conf"
ynh_exec_warn_less systemctl enable mongod --quiet
ynh_systemd_action --service_name=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --line_match="Waiting for connections"
ynh_hide_warnings systemctl enable mongod --quiet
ynh_systemctl --service=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --wait_until="Waiting for connections"
if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
if ynh_hide_warnings ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_hide_warnings ynh_mongo_exec --command="printjson(rs.initiate())" --eval
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
if ynh_app_upstream_version_changed
then
ynh_script_progression --message="Upgrading source files..."
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir/build" --full_replace=1
ynh_setup_source --dest_dir="$install_dir/build" --full_replace
fi
# full replace on live dir
ynh_secure_remove "$install_dir/live"
ynh_safe_rm "$install_dir/live"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
@ -97,38 +92,36 @@ chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
ynh_script_progression "Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_script_progression "Upgrading dependencies..."
ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_nodejs_install
ynh_install_mongo
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_script_progression "Updating configuration..."
ynh_add_config --template="../conf/variables.env" --destination="$install_dir/variables.env"
ynh_config_add --template="variables.env" --destination="$install_dir/variables.env"
chmod 400 "$install_dir/variables.env"
chown $app:$app "$install_dir/variables.env"
ynh_add_config --template="../conf/settings.js" --destination="$install_dir/settings.js"
ynh_config_add --template="settings.js" --destination="$install_dir/settings.js"
chmod 400 "$install_dir/settings.js"
chown $app:$app "$install_dir/settings.js"
#=================================================
# BUILDING APP
#=================================================
ynh_script_progression --message="Preparing app..."
ynh_script_progression "Preparing app..."
mkdir -p "$install_dir/live"
cp "$install_dir/build/server-ce/genScript.js" "$install_dir/live/genScript.js"
@ -139,29 +132,29 @@ cp -r "$install_dir/build/libraries/" "$install_dir/live/libraries/"
cp -r "$install_dir/build/services/" "$install_dir/live/services/"
cp -r "$install_dir/build/patches/" "$install_dir/live/patches/"
cp -r "$install_dir/build/server-ce/config" "$install_dir/config/"
ynh_secure_remove --file="$install_dir/config/settings.js"
ynh_secure_remove --file="$install_dir/config/production.json"
ynh_secure_remove --file="$install_dir/live/services/history-v1/config/production.json"
ynh_safe_rm "$install_dir/config/settings.js"
ynh_safe_rm "$install_dir/config/production.json"
ynh_safe_rm "$install_dir/live/services/history-v1/config/production.json"
ynh_add_config --template="../conf/production.json" --destination="$install_dir/config/production.json"
ynh_add_config --template="../conf/production.json" --destination="$install_dir/live/services/history-v1/config/production.json"
ynh_config_add --template="production.json" --destination="$install_dir/config/production.json"
ynh_config_add --template="production.json" --destination="$install_dir/live/services/history-v1/config/production.json"
cp "$install_dir/build/server-ce/config/custom-environment-variables.json" "$install_dir/live/services/history-v1/config/"
ynh_script_progression --message="Building app... This may take a LOT of time depending of your CPU" --weight=25
ynh_script_progression "Building app... This may take a LOT of time depending of your CPU"
pushd "$install_dir/live"
ynh_use_nodejs
ynh_exec_warn_less npm cache clean --force
ynh_exec_warn_less npm install
ynh_exec_warn_less npm ci
ynh_hide_warnings npm cache clean --force
ynh_hide_warnings npm install
ynh_hide_warnings npm ci
popd
pushd "$install_dir/live/services/web"
ynh_exec_warn_less npm run webpack:production
ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache"
ynh_hide_warnings npm run webpack:production
ynh_safe_rm "$install_dir/live/services/web/node_modules/.cache"
popd
#remove build dir
ynh_secure_remove "$install_dir/build"
ynh_safe_rm "$install_dir/build"
chmod 750 "$install_dir/live"
chmod -R o-rwx "$install_dir/live"
@ -176,38 +169,36 @@ chown -R $app:www-data "$install_dir/tmp"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
ynh_script_progression "Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config --service="$app-chat" --template="overleaf-chat.service"
ynh_add_systemd_config --service="$app-clsi" --template="overleaf-clsi.service"
ynh_add_systemd_config --service="$app-contacts" --template="overleaf-contacts.service"
ynh_add_systemd_config --service="$app-docstore" --template="overleaf-docstore.service"
ynh_add_systemd_config --service="$app-document-updater" --template="overleaf-document-updater.service"
ynh_add_systemd_config --service="$app-filestore" --template="overleaf-filestore.service"
ynh_add_systemd_config --service="$app-history-v1" --template="overleaf-history-v1.service"
ynh_add_systemd_config --service="$app-notifications" --template="overleaf-notifications.service"
ynh_add_systemd_config --service="$app-project-history" --template="overleaf-project-history.service"
ynh_add_systemd_config --service="$app-real-time" --template="overleaf-real-time.service"
ynh_add_systemd_config --service="$app-spelling" --template="overleaf-spelling.service"
ynh_add_systemd_config --service="$app-web" --template="overleaf-web.service"
ynh_config_add_systemd --service="$app-chat" --template="overleaf-chat.service"
ynh_config_add_systemd --service="$app-clsi" --template="overleaf-clsi.service"
ynh_config_add_systemd --service="$app-contacts" --template="overleaf-contacts.service"
ynh_config_add_systemd --service="$app-docstore" --template="overleaf-docstore.service"
ynh_config_add_systemd --service="$app-document-updater" --template="overleaf-document-updater.service"
ynh_config_add_systemd --service="$app-filestore" --template="overleaf-filestore.service"
ynh_config_add_systemd --service="$app-history-v1" --template="overleaf-history-v1.service"
ynh_config_add_systemd --service="$app-notifications" --template="overleaf-notifications.service"
ynh_config_add_systemd --service="$app-project-history" --template="overleaf-project-history.service"
ynh_config_add_systemd --service="$app-real-time" --template="overleaf-real-time.service"
ynh_config_add_systemd --service="$app-spelling" --template="overleaf-spelling.service"
ynh_config_add_systemd --service="$app-web" --template="overleaf-web.service"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
ynh_script_progression "Upgrading logrotate configuration..."
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
ynh_config_add_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add "$app-chat" --log="/var/log/$app/chat.log"
yunohost service add "$app-clsi" --log="/var/log/$app/clsi.log"
@ -225,23 +216,23 @@ yunohost service add "$app-web" --log="/var/log/$app/web.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --line_match="Loading backend"
ynh_systemd_action --service_name="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --line_match="Using settings from"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="Using settings from"
ynh_systemctl --service="$app-chat" --action="start" --log_path="/var/log/$app/chat.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-clsi" --action="start" --log_path="/var/log/$app/clsi.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-contacts" --action="start" --log_path="/var/log/$app/contacts.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-docstore" --action="start" --log_path="/var/log/$app/docstore.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-document-updater" --action="start" --log_path="/var/log/$app/document-updater.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-filestore" --action="start" --log_path="/var/log/$app/filestore.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-history-v1" --action="start" --log_path="/var/log/$app/history-v1.log" --wait_until="Loading backend"
ynh_systemctl --service="$app-notifications" --action="start" --log_path="/var/log/$app/notifications.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-project-history" --action="start" --log_path="/var/log/$app/project-history.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-real-time" --action="start" --log_path="/var/log/$app/real-time.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-spelling" --action="start" --log_path="/var/log/$app/spelling.log" --wait_until="Using settings from"
ynh_systemctl --service="$app-web" --action="start" --log_path="/var/log/$app/web.log" --wait_until="listening on" --wait_until="Using settings from"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"
ynh_script_progression "Upgrade of $app completed"