mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
Better progression description
This commit is contained in:
parent
63aff67675
commit
66200be6f4
4 changed files with 103 additions and 94 deletions
|
@ -35,7 +35,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
@ -46,7 +46,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
|
@ -58,7 +58,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language
|
|||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..."
|
||||
ynh_script_progression --message="Finding an available port..." --weight=1
|
||||
|
||||
# Find an available port
|
||||
port_web=$(ynh_find_port --port=3000)
|
||||
|
@ -70,7 +70,7 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=600
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
|
@ -80,7 +80,7 @@ ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
@ -88,7 +88,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=14
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
# Create PostgreSQL database
|
||||
|
@ -104,7 +104,7 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
ynh_script_progression --message="Setting up source files..." --weight=5
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
|
@ -117,7 +117,7 @@ chown -R $app:www-data "$final_path"
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
@ -127,7 +127,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap if needed..."
|
||||
ynh_script_progression --message="Adding swap if needed..." --weight=1
|
||||
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
@ -137,24 +137,24 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
|||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..."
|
||||
ynh_script_progression --message="Installing Ruby dependencies..." --weight=6
|
||||
|
||||
pushd "$final_path/live"
|
||||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem update --system --no-document
|
||||
ynh_gem install bundler --no-document
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
config="$final_path/live/.env.production"
|
||||
|
||||
|
@ -188,7 +188,7 @@ chown $app:$app "$final_path/live/config/settings.yml"
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service"
|
||||
|
@ -198,7 +198,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streamin
|
|||
#=================================================
|
||||
# INSTALLING GLITCH-SOC
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Glitch-Soc..."
|
||||
ynh_script_progression --message="Installing Glitch-Soc..." --weight=300
|
||||
|
||||
pushd "$final_path/live"
|
||||
ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true'
|
||||
|
@ -232,7 +232,7 @@ chown $app:$app "$config"
|
|||
#=================================================
|
||||
# SETUP THE CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setuping the cron file..."
|
||||
ynh_script_progression --message="Setuping the cron file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||
|
||||
|
@ -241,7 +241,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add "$app-web" --description="$app web service"
|
||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||
|
@ -250,7 +250,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||
|
@ -259,7 +259,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
|
@ -273,7 +273,7 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -281,4 +281,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
ynh_script_progression --message="Installation of $app completed" --weight=1
|
||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -30,26 +30,26 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
# 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-web" >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-web service integration..."
|
||||
ynh_script_progression --message="Removing $app-web service integration..." --weight=1
|
||||
yunohost service remove "$app-web"
|
||||
fi
|
||||
|
||||
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-sidekiq service integration..."
|
||||
ynh_script_progression --message="Removing $app-sidekiq service integration..." --weight=1
|
||||
yunohost service remove "$app-sidekiq"
|
||||
fi
|
||||
|
||||
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-streaming service integration..."
|
||||
ynh_script_progression --message="Removing $app-streaming service integration..." --weight=1
|
||||
yunohost service remove "$app-streaming"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config --service="$app-web"
|
||||
|
@ -59,7 +59,7 @@ ynh_remove_systemd_config --service="$app-streaming"
|
|||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=10
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
@ -67,7 +67,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=10
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
@ -75,7 +75,7 @@ ynh_secure_remove --file="$final_path"
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -83,7 +83,7 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=300
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_ruby
|
||||
|
@ -96,7 +96,7 @@ ynh_remove_extra_repo
|
|||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
ynh_script_progression --message="Removing various files..." --weight=1
|
||||
|
||||
# Remove a cron file
|
||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||
|
@ -109,7 +109,7 @@ ynh_del_swap
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
@ -118,4 +118,4 @@ ynh_system_user_delete --username=$app
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
ynh_script_progression --message="Removal of $app completed" --weight=1
|
||||
|
|
|
@ -23,7 +23,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -37,7 +37,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
@ -47,14 +47,14 @@ test ! -d $final_path \
|
|||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
@ -62,7 +62,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=10
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
|
@ -75,7 +75,7 @@ chown -R $app:www-data "$final_path"
|
|||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=600
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
@ -86,7 +86,7 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION
|
|||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=10
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
|
@ -96,7 +96,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
|||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap if needed..."
|
||||
ynh_script_progression --message="Adding swap if needed..." --weight=1
|
||||
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
@ -106,31 +106,31 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
|||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..."
|
||||
ynh_script_progression --message="Installing Ruby dependencies..." --weight=300
|
||||
|
||||
pushd "$final_path/live"
|
||||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem update --system --no-document
|
||||
ynh_gem install bundler --no-document
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..."
|
||||
ynh_script_progression --message="Restoring various files..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
||||
|
@ -140,7 +140,7 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
|
|||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add "$app-web" --description="$app web service"
|
||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||
|
@ -149,7 +149,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||
|
@ -160,7 +160,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -168,4 +168,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
ynh_script_progression --message="Restoration completed for $app" --weight=1
|
||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -39,14 +39,14 @@ config="$final_path/live/.env.production"
|
|||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
ynh_script_progression --message="Checking version..." --weight=1
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -63,7 +63,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
|
@ -72,7 +72,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy
|
|||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
|
@ -154,7 +154,7 @@ ynh_remove_extra_repo
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
@ -165,7 +165,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
# Download Glitch-Soc
|
||||
tmpdir="$(mktemp -d)"
|
||||
|
@ -187,16 +187,16 @@ then
|
|||
|
||||
# Clean files which are not needed anymore
|
||||
ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb"
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
@ -204,19 +204,22 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=600
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap if needed..."
|
||||
ynh_script_progression --message="Adding swap if needed..." --weight=1
|
||||
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
@ -226,24 +229,27 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
|||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..."
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Installing Ruby dependencies..." --weight=6
|
||||
|
||||
pushd "$final_path/live"
|
||||
pushd "$final_path/live"
|
||||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem update --system --no-document
|
||||
ynh_gem install bundler --no-document
|
||||
popd
|
||||
popd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a config file..."
|
||||
ynh_script_progression --message="Updating a config file..." --weight=1
|
||||
|
||||
language="$(echo $language | head -c 2)"
|
||||
|
||||
|
@ -255,7 +261,7 @@ chown $app:$app "$config"
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service"
|
||||
|
@ -265,9 +271,11 @@ ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streamin
|
|||
#=================================================
|
||||
# UPGRADE GLITCH-SOC
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading Glitch-Soc..."
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading Glitch-Soc..." --weight=300
|
||||
|
||||
pushd "$final_path/live"
|
||||
pushd "$final_path/live"
|
||||
ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true'
|
||||
ynh_exec_as $app $ynh_ruby_load_path bin/bundle config without 'development test'
|
||||
ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||
|
@ -277,12 +285,13 @@ pushd "$final_path/live"
|
|||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile
|
||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate
|
||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear
|
||||
popd
|
||||
popd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SETUP THE CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setuping the cron file..."
|
||||
ynh_script_progression --message="Setuping the cron file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||
|
||||
|
@ -291,7 +300,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add "$app-web" --description="$app web service"
|
||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||
|
@ -300,7 +309,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||
|
@ -309,7 +318,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -317,4 +326,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
ynh_script_progression --message="Upgrade of $app completed" --weight=1
|
||||
|
|
Loading…
Reference in a new issue