mirror of
https://github.com/YunoHost-Apps/dato_ynh.git
synced 2024-09-03 18:16:33 +02:00
Merge c34e13701e
into 7d80cb82c6
This commit is contained in:
commit
9ab22cce44
10 changed files with 94 additions and 135 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
*~
|
||||
*.sw[op]
|
||||
.DS_Store
|
||||
|
|
|
@ -9,8 +9,8 @@ Group=__APP__
|
|||
WorkingDirectory=__INSTALL_DIR__/sources/
|
||||
Environment=NODE_ENV=production
|
||||
Environment=NODE_CONFIG_DIR=__INSTALL_DIR__/sources/config/
|
||||
Environment="__YNH_NODE_LOAD_PATH__"
|
||||
ExecStart=__YNH_NPM__ start
|
||||
Environment="PATH=__PATH_WITH_NODEJS__"
|
||||
ExecStart=__NODEJS_DIR__/npm start
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=__APP__
|
||||
|
|
|
@ -19,7 +19,8 @@ code = "https://framagit.org/squeak/dato"
|
|||
website = "https://squeak.eauchat.org/dato"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2.10"
|
||||
yunohost = ">= 11.2.29"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = false
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
# nodejs version
|
||||
nodejs_version=12
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
bool_to_str() {
|
||||
bool_str=(false true)
|
||||
echo "${bool_str[$1]}"
|
||||
|
@ -20,24 +16,16 @@ dato_setup_config_files() {
|
|||
mkdir -p "$install_dir/sources/config/"
|
||||
|
||||
# setup public dato config
|
||||
ynh_add_config --template="public.js" --destination="$install_dir/sources/config/public.js"
|
||||
chmod 400 "$install_dir/sources/config/public.js"
|
||||
chown "$app:$app" "$install_dir/sources/config/public.js"
|
||||
ynh_config_add --template="public.js" --destination="$install_dir/sources/config/public.js"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/sources/config/public.js"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/sources/config/public.js"
|
||||
|
||||
# setup private dato config
|
||||
if [[ $autosynchronize == true ]]; then
|
||||
ynh_add_config --template="private-autosync.js" --destination="$install_dir/sources/config/private.js"
|
||||
ynh_config_add --template="private-autosync.js" --destination="$install_dir/sources/config/private.js"
|
||||
else
|
||||
ynh_add_config --template="private.js" --destination="$install_dir/sources/config/private.js"
|
||||
ynh_config_add --template="private.js" --destination="$install_dir/sources/config/private.js"
|
||||
fi
|
||||
chmod 400 "$install_dir/sources/config/private.js"
|
||||
chown "$app:$app" "$install_dir/sources/config/private.js"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/sources/config/private.js"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/sources/config/private.js"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -4,47 +4,43 @@
|
|||
# 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 SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/var/log/$app/"
|
||||
ynh_backup "/var/log/$app/"
|
||||
|
||||
if [[ "$autosynchronize" == true ]]; then
|
||||
# backup dato.ini config in couch
|
||||
ynh_backup --src_path="/opt/couchdb/etc/local.d/$app.ini"
|
||||
ynh_backup "/opt/couchdb/etc/local.d/$app.ini"
|
||||
|
||||
# notify that couchdb users and dbs are left
|
||||
ynh_print_warn --message="Please note that backing up dato doesn't backup the databases you created through it. To backup your data, you should backup the couchdb app."
|
||||
ynh_print_warn "Please note that backing up dato doesn't backup the databases you created through it. To backup your data, you should backup the couchdb app."
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# 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)."
|
||||
|
|
|
@ -10,27 +10,27 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
|
||||
ynh_systemctl --service="$app" --action="stop" --log_path="systemd"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=60
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
|
||||
ynh_systemctl --service="$app" --action="start" --log_path="systemd" --wait_until="electrode server listening on port" --timeout=600
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -13,21 +13,20 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
# Convert to true/false
|
||||
autosynchronize=$(bool_to_str "$autosynchronize")
|
||||
ynh_app_setting_set --app="$app" --key=autosynchronize --value="$autosynchronize"
|
||||
ynh_app_setting_set --key=autosynchronize --value="$autosynchronize"
|
||||
|
||||
#=================================================
|
||||
# INSTALL NODEJS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing NodeJS..." --weight=6
|
||||
ynh_script_progression "Installing NodeJS..."
|
||||
|
||||
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
||||
ynh_nodejs_install
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=2
|
||||
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/sources"
|
||||
|
||||
chmod -R o-rwx "$install_dir/sources"
|
||||
|
@ -36,17 +35,16 @@ chown -R "$app:www-data" "$install_dir/sources"
|
|||
#=================================================
|
||||
# BUILD NODE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building node dependencies..." --weight=90
|
||||
ynh_script_progression "Building node dependencies..."
|
||||
|
||||
pushd "$install_dir/sources"
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install --loglevel warn
|
||||
ynh_hide_warnings ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --loglevel warn
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding $app's configuration file..." --weight=3
|
||||
ynh_script_progression "Adding $app's configuration file..."
|
||||
|
||||
dato_setup_config_files
|
||||
|
||||
|
@ -59,10 +57,10 @@ if [[ $autosynchronize == true ]]; then
|
|||
#=================================================
|
||||
# CUSTOMIZE COUCHDB SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Customizing couch config..." --weight=2
|
||||
ynh_script_progression "Customizing couch config..."
|
||||
|
||||
# make sure that couchdb has CORS enabled and that it accepts requests from dato domain
|
||||
ynh_add_config --template="couch.ini" --destination="/opt/couchdb/etc/local.d/$app.ini"
|
||||
ynh_config_add --template="couch.ini" --destination="/opt/couchdb/etc/local.d/$app.ini"
|
||||
|
||||
# restart couchdb service so that it takes into consideration the changes
|
||||
yunohost service restart couchdb
|
||||
|
@ -70,7 +68,7 @@ if [[ $autosynchronize == true ]]; then
|
|||
#=================================================
|
||||
# SETUP A COUCHDB DATO ADMIN USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up admin user in couch..." --weight=2
|
||||
ynh_script_progression "Setting up admin user in couch..."
|
||||
|
||||
# figure out couch url with password
|
||||
couch_pw_url=$(echo "$couch_url" | sed -En "s+^https?://+https://$couch_admin_name:$couch_admin_password@+p")
|
||||
|
@ -83,10 +81,10 @@ if [[ $autosynchronize == true ]]; then
|
|||
|
||||
# display error message if there was an error creating dato admin user in couch
|
||||
if [[ $addDatoAdmin_curlResult != '{"ok":true'* ]]; then
|
||||
ynh_print_err --message="There was an error creating the dato admin user for in couch. You will probably have to do it manually (check the last section of this page for instructions: https://squeak.eauchat.org/apps/dato/?setups)."
|
||||
ynh_print_err --message="Here is the error message from couchdb:"
|
||||
ynh_print_err --message="$addDatoAdmin_curlResult"
|
||||
ynh_print_err --message="Please make sure that your couchdb instance is accessible from the url you provided, with a proper SSL certificate (not a self-signed one), otherwise you will not be able to login to dato!"
|
||||
ynh_print_warn "There was an error creating the dato admin user for in couch. You will probably have to do it manually (check the last section of this page for instructions: https://squeak.eauchat.org/apps/dato/?setups)."
|
||||
ynh_print_warn "Here is the error message from couchdb:"
|
||||
ynh_print_warn "$addDatoAdmin_curlResult"
|
||||
ynh_print_warn "Please make sure that your couchdb instance is accessible from the url you provided, with a proper SSL certificate (not a self-signed one), otherwise you will not be able to login to dato!"
|
||||
fi
|
||||
|
||||
# modify _users db _security document
|
||||
|
@ -99,9 +97,9 @@ if [[ $autosynchronize == true ]]; then
|
|||
|
||||
# display error message if there was an error modifying _users db _security document
|
||||
if [[ $usersSecDocChange_curlResult != '{"ok":true'* ]]; then
|
||||
ynh_print_err --message="There was an error enabling dato users to access their user profile in couch. You will have to do it manually (check the 'Configure couchdb so that it accepts requests from dato' section in the following page for instructions: https://squeak.eauchat.org/apps/dato/?setups)."
|
||||
ynh_print_err --message="Here is the error message from couchdb:"
|
||||
ynh_print_err --message="$usersSecDocChange_curlResult"
|
||||
ynh_print_warn "There was an error enabling dato users to access their user profile in couch. You will have to do it manually (check the 'Configure couchdb so that it accepts requests from dato' section in the following page for instructions: https://squeak.eauchat.org/apps/dato/?setups)."
|
||||
ynh_print_warn "Here is the error message from couchdb:"
|
||||
ynh_print_warn "$usersSecDocChange_curlResult"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
@ -116,28 +114,28 @@ chown -R "$app:$app" "$install_dir/sources/dist" "$install_dir/sources/config"
|
|||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
ynh_config_add_logrotate
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=60
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
|
||||
ynh_systemctl --service="$app" --action="start" --log_path="systemd" --wait_until="electrode server listening on port" --timeout=600
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -10,29 +10,19 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
|
||||
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
ynh_config_remove_systemd
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
ynh_config_remove_logrotate
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
#=================================================
|
||||
# REMOVE NODEJS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NodeJS..." --weight=13
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_nodejs
|
||||
ynh_nodejs_remove
|
||||
|
||||
#=================================================
|
||||
# AUTOSYNCHRONIZED SPECIFICS
|
||||
|
@ -40,14 +30,14 @@ ynh_remove_nodejs
|
|||
|
||||
if [[ $autosynchronize == true ]]; then
|
||||
# Remove dato specific config added to couch
|
||||
ynh_secure_remove --file="/opt/couchdb/etc/local.d/$app.ini"
|
||||
ynh_safe_rm "/opt/couchdb/etc/local.d/$app.ini"
|
||||
|
||||
# notify that couchdb users and dbs are left
|
||||
ynh_print_warn --message="Please note that dbs and users in the attached couchdb instance haven't been modified. If you want them removed, you should do that manually, for example from the couchdb web interface."
|
||||
ynh_print_warn "Please note that dbs and users in the attached couchdb instance haven't been modified. If you want them removed, you should do that manually, for example from the couchdb web interface."
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -4,27 +4,22 @@
|
|||
# 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
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling NodeJS..." --weight=5
|
||||
ynh_script_progression "Reinstalling NodeJS..."
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
||||
ynh_nodejs_install
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
ynh_restore "$install_dir"
|
||||
|
||||
mkdir -p "$install_dir/sources/dist"
|
||||
chown -R "$app:$app" "$install_dir/sources/dist" "$install_dir/sources/global" "$install_dir/sources/config"
|
||||
|
@ -35,33 +30,33 @@ chown -R "$app:$app" "$install_dir/sources/dist" "$install_dir/sources/global" "
|
|||
|
||||
# restore dato.ini config in couch
|
||||
if [[ $autosynchronize == true ]]; then
|
||||
ynh_restore_file --origin_path="/opt/couchdb/etc/local.d/$app.ini"
|
||||
ynh_restore "/opt/couchdb/etc/local.d/$app.ini"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Restoring system configurations related to $app..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
ynh_restore "/etc/systemd/system/$app.service"
|
||||
systemctl enable "$app.service" --quiet
|
||||
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
ynh_restore "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
|
||||
ynh_systemctl --service="$app" --action="start" --log_path="systemd" --wait_until="electrode server listening on port" --timeout=600
|
||||
|
||||
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" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -10,14 +10,14 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
|
||||
ynh_systemctl --service="$app" --action="stop" --log_path="systemd"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
# Cleanup legacy install dir
|
||||
if [ ! -d "$install_dir/sources" ]; then
|
||||
|
@ -28,66 +28,56 @@ fi
|
|||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NodeJS..." --weight=5
|
||||
ynh_script_progression "Upgrading NodeJS..."
|
||||
|
||||
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
||||
ynh_nodejs_install
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=3
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 --keep="config"
|
||||
ynh_setup_source --dest_dir="$install_dir/sources" --full_replace --keep="config"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# BUILD NODE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building node dependencies..." --weight=20
|
||||
ynh_script_progression "Building node dependencies..."
|
||||
|
||||
pushd "$install_dir/sources"
|
||||
ynh_use_nodejs
|
||||
ynh_secure_remove --file="$install_dir/node_modules/"
|
||||
ynh_secure_remove --file="$install_dir/package-lock.json"
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install --loglevel warn
|
||||
ynh_safe_rm "$install_dir/node_modules/"
|
||||
ynh_safe_rm "$install_dir/package-lock.json"
|
||||
ynh_hide_warnings ynh_hide_warnings ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --loglevel warn
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating $app's configuration file..." --weight=3
|
||||
ynh_script_progression "Updating $app's configuration file..."
|
||||
|
||||
dato_setup_config_files
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
ynh_config_add_logrotate
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
|
||||
ynh_systemctl --service="$app" --action="start" --log_path="systemd" --wait_until="electrode server listening on port" --timeout=600
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue