1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/osjs_ynh.git synced 2024-09-03 19:56:11 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:27:13 +02:00 committed by GitHub
commit 62fc3bdf9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 95 additions and 158 deletions

View file

@ -7,8 +7,8 @@ Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__INSTALL_DIR__/ WorkingDirectory=__INSTALL_DIR__/
Environment="__YNH_NODE_LOAD_PATH__" Environment="PATH=__PATH_WITH_NODEJS__"
ExecStart=__YNH_NPM__ run serve ExecStart=__NODEJS_DIR__/npm run serve
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=syslog StandardError=syslog
Restart=always Restart=always

View file

@ -17,7 +17,8 @@ admindoc = "https://manual.os-js.org/"
code = "https://github.com/os-js/OS.js" code = "https://github.com/os-js/OS.js"
[integration] [integration]
yunohost = ">= 11.2" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = false multi_instance = false

View file

@ -1,19 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
nodejs_version=10 nodejs_version=10
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,44 +1,35 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$install_dir" ynh_backup "$install_dir"
#================================================= #=================================================
# SYSTEM CONFIGURATION # 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 # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/var/log/$app/" ynh_backup "/var/log/$app/"
#================================================= #=================================================
# END OF SCRIPT # 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,42 +1,32 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # 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 --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="stop"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # 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
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on" ynh_systemctl --service="$app" --action="start" --wait_until="Server listening on"
#================================================= #=================================================
# END OF SCRIPT # 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,44 +1,37 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# INSTALL NODEJS # INSTALL NODEJS
#================================================= #=================================================
ynh_script_progression --message="Installing NodeJS..." ynh_script_progression "Installing NodeJS..."
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_nodejs_install
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression "Setting up source files..."
ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression "Adding $app's configuration..."
ynh_add_config --template="client.config.js" --destination="$install_dir/src/client/config.js" ynh_config_add --template="client.config.js" --destination="$install_dir/src/client/config.js"
chmod 400 "$install_dir/src/client/config.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/src/client/config.js"
chown "$app:$app" "$install_dir/src/client/config.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/src/client/config.js"
ynh_add_config --template="server.index.js" --destination="$install_dir/src/server/index.js" ynh_config_add --template="server.index.js" --destination="$install_dir/src/server/index.js"
chmod 400 "$install_dir/src/server/index.js" chmod 400 "$install_dir/src/server/index.js"
chown "$app:$app" "$install_dir/src/server/index.js" chown "$app:$app" "$install_dir/src/server/index.js"
@ -46,43 +39,42 @@ chown "$app:$app" "$install_dir/src/server/index.js"
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building $app..." ynh_script_progression "Building $app..."
pushd "$install_dir" pushd "$install_dir"
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm install
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run package:discover ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm run package:discover
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run build ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm run build
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install --save --production @osjs/pam-auth ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm install --save --production @osjs/pam-auth
popd popd
ynh_replace_string --match_string="8000" --replace_string="$port" --target_file="$install_dir/src/server/config.js" ynh_replace --match="8000" --replace="$port" --file="$install_dir/src/server/config.js"
chown -R "$app:$app" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 ynh_script_progression "Adding system configurations related to $app..."
ynh_add_nginx_config ynh_config_add_nginx
ynh_add_systemd_config ynh_config_add_systemd
yunohost service add "$app" --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on" ynh_systemctl --service="$app" --action="start" --wait_until="Server listening on"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" ynh_script_progression "Installation of $app completed"

View file

@ -1,36 +1,30 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # 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`) # 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" yunohost service remove "$app"
fi fi
ynh_remove_systemd_config ynh_config_remove_systemd
ynh_remove_logrotate ynh_config_remove_logrotate
ynh_remove_nginx_config ynh_config_remove_nginx
ynh_remove_nodejs ynh_nodejs_remove
ynh_secure_remove --file="/var/log/$app" #REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" ynh_script_progression "Removal of $app completed"

View file

@ -1,61 +1,54 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REINSTALL NODEJS # REINSTALL NODEJS
#================================================= #=================================================
ynh_script_progression --message="Reinstalling NodeJS..." ynh_script_progression "Reinstalling NodeJS..."
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_nodejs_install
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # 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 -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # 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 systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore "/etc/logrotate.d/$app"
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_restore_file --origin_path="/var/log/$app/" ynh_restore "/var/log/$app/"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD 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="/var/log/$app/$app.log" --line_match="Server listening on" ynh_systemctl --service="$app" --action="start" --wait_until="Server listening on"
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" ynh_script_progression "Restoration completed for $app"

View file

@ -1,53 +1,42 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # 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" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemctl --service="$app" --action="stop"
#================================================= #=================================================
# INSTALL NODEJS # INSTALL NODEJS
#================================================= #=================================================
ynh_script_progression --message="Updating NodeJS..." ynh_script_progression "Updating NodeJS..."
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_nodejs_install
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..." ynh_script_progression "Upgrading source files..."
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="src/client/config.js src/server/index.js" ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="src/client/config.js src/server/index.js"
chmod -R o-rwx "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression "Updating configuration..."
ynh_add_config --template="client.config.js" --destination="$install_dir/src/client/config.js" ynh_config_add --template="client.config.js" --destination="$install_dir/src/client/config.js"
chmod 400 "$install_dir/src/client/config.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/src/client/config.js"
chown "$app:$app" "$install_dir/src/client/config.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/src/client/config.js"
ynh_add_config --template="server.index.js" --destination="$install_dir/src/server/index.js" ynh_config_add --template="server.index.js" --destination="$install_dir/src/server/index.js"
chmod 400 "$install_dir/src/server/index.js" chmod 400 "$install_dir/src/server/index.js"
chown "$app:$app" "$install_dir/src/server/index.js" chown "$app:$app" "$install_dir/src/server/index.js"
@ -55,42 +44,41 @@ chown "$app:$app" "$install_dir/src/server/index.js"
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression "Building app..."
pushd "$install_dir" pushd "$install_dir"
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm install
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run package:discover ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm run package:discover
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run build ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm run build
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install --save --production @osjs/pam-auth ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm install --save --production @osjs/pam-auth
popd popd
ynh_replace_string --match_string="8000" --replace_string="$port" --target_file="$install_dir/src/server/config.js" ynh_replace --match="8000" --replace="$port" --file="$install_dir/src/server/config.js"
chown -R "$app:$app" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 ynh_script_progression "Upgrading system configurations related to $app..."
ynh_add_nginx_config ynh_config_add_nginx
ynh_add_systemd_config ynh_config_add_systemd
yunohost service add "$app" --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log"
ynh_use_logrotate --non-append ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on" ynh_systemctl --service="$app" --action="start" --wait_until="Server listening on"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" ynh_script_progression "Upgrade of $app completed"