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

Cleanup packaging v2

This commit is contained in:
Salamandar 2024-02-06 10:30:28 +01:00
parent b505172122
commit f541a94c00
6 changed files with 81 additions and 95 deletions

View file

@ -22,24 +22,20 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP SYSTEMD
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/var/log/$app/"
#=================================================
# END OF SCRIPT

View file

@ -33,7 +33,7 @@ ynh_change_url_nginx_config
ynh_script_progression --message="Starting 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_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on"
#=================================================
# END OF SCRIPT

View file

@ -10,9 +10,9 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_script_progression --message="Installing NodeJS..."
ynh_install_nodejs --nodejs_version=$nodejs_version
@ -24,24 +24,7 @@ ynh_script_progression --message="Setting up source files..."
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
ynh_add_nginx_config
ynh_add_systemd_config
mkdir -p "/var/log/$app"
chown $app:$app "/var/log/$app"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
yunohost service add $app --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log"
chown -R "$app:$app" "$install_dir"
#=================================================
# SPECIFIC SETUP
@ -53,29 +36,42 @@ ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="client.config.js" --destination="$install_dir/src/client/config.js"
chmod 400 "$install_dir/src/client/config.js"
chown $app:$app "$install_dir/src/client/config.js"
chown "$app:$app" "$install_dir/src/client/config.js"
ynh_add_config --template="server.index.js" --destination="$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"
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="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_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run package:discover
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_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_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run package:discover
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run build
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install --save --production @osjs/pam-auth
popd
ynh_replace_string --match_string="8000" --replace_string="$port" --target_file="$install_dir/src/server/config.js"
chown -R $app:$app "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_add_nginx_config
ynh_add_systemd_config
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)
ynh_use_logrotate
#=================================================
# START SYSTEMD SERVICE
@ -83,7 +79,7 @@ chown -R $app:$app "$install_dir"
ynh_script_progression --message="Starting 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_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on"
#=================================================
# END OF SCRIPT

View file

@ -10,16 +10,13 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# 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
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
ynh_remove_systemd_config

View file

@ -10,9 +10,9 @@ source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# REINSTALL DEPENDENCIES
# REINSTALL NODEJS
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
ynh_script_progression --message="Reinstalling NodeJS..."
ynh_install_nodejs --nodejs_version=$nodejs_version
@ -24,30 +24,33 @@ ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# RESTORE SYSTEMD
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/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"
mkdir -p "/var/log/$app"
chown $app:$app "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
yunohost service add $app --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_restore_file --origin_path="/var/log/$app/"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on"
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on"
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -9,12 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -22,36 +16,24 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Updating NodeJS..."
ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..."
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
ynh_setup_source --dest_dir="$install_dir" --keep="src/client/config.js src/server/index.js"
fi
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="src/client/config.js src/server/index.js"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
ynh_add_nginx_config
ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_add_systemd_config
ynh_use_logrotate --non-append
yunohost service add $app --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log"
chown -R "$app:$app" "$install_dir"
#=================================================
# SPECIFIC UPGRADE
@ -63,29 +45,41 @@ ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="client.config.js" --destination="$install_dir/src/client/config.js"
chmod 400 "$install_dir/src/client/config.js"
chown $app:$app "$install_dir/src/client/config.js"
chown "$app:$app" "$install_dir/src/client/config.js"
ynh_add_config --template="server.index.js" --destination="$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"
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="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_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run package:discover
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_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_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run package:discover
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run build
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install --save --production @osjs/pam-auth
popd
ynh_replace_string --match_string="8000" --replace_string="$port" --target_file="$install_dir/src/server/config.js"
chown -R $app:$app "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_add_nginx_config
ynh_add_systemd_config
yunohost service add "$app" --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log"
ynh_use_logrotate --non-append
#=================================================
# START SYSTEMD SERVICE
@ -93,7 +87,7 @@ chown -R $app:$app "$install_dir"
ynh_script_progression --message="Starting 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_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on"
#=================================================
# END OF SCRIPT