Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules Bertholet committed Sep 17, 2021
1 parent 53dbf71 commit f86e0b2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
24 changes: 12 additions & 12 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
ynh_script_progression --message="Validating installation parameters..." --weight=10

final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
Expand All @@ -56,7 +56,7 @@ test ! -e "$data_path" || ynh_die --message="This path already contains a folder
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_script_progression --message="Storing installation settings..." --weight=10

ynh_app_setting_set --app=$app --key=server_name --value=$server_name
ynh_app_setting_set --app=$app --key=description --value=$description
Expand All @@ -81,7 +81,7 @@ ynh_app_setting_set --app=$app --key=allow_inter_site_trade --value=$allow_inter
#=================================================
# FIND AND OPEN PORTS
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
ynh_script_progression --message="Finding an available port..." --weight=10

# Find an available port
port=$(ynh_find_port --port=14004)
Expand All @@ -95,7 +95,7 @@ ynh_app_setting_set --app=$app --key=metrics_port --value=$metrics_port
# Expose port publicly

# Open the port
ynh_script_progression --message="Configuring firewall..." --weight=1
ynh_script_progression --message="Configuring firewall..." --weight=10
ynh_exec_warn_less yunohost firewall allow --no-upnp Both $port

#=================================================
Expand All @@ -108,15 +108,15 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
ynh_script_progression --message="Configuring system user..." --weight=10

# Create a system user
ynh_system_user_create --username=$app --home_dir="$data_path"

#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=155
ynh_script_progression --message="Setting up source files..." --weight=100

ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
Expand All @@ -128,7 +128,7 @@ setup_source
#=================================================
# COMPILE SERVER
#=================================================
ynh_script_progression --message="Compiling server..." --weight=135
ynh_script_progression --message="Compiling server..." --weight=100

compile_server

Expand All @@ -139,7 +139,7 @@ compile_server
map_generated=0

if [ $generate_custom_world -eq 1 ]; then
ynh_script_progression --message="Generating custom world..." --weight=730
ynh_script_progression --message="Generating custom world..." --weight=100

generate_custom_world
fi
Expand All @@ -153,25 +153,25 @@ add_configuration_files
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_script_progression --message="Configuring a systemd service..." --weight=10

# Create a dedicated systemd config
ynh_add_systemd_config --others_var="data_path"
ynh_add_systemd_config

#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_script_progression --message="Configuring log rotation..." --weight=10

# Use logrotate to manage application logfile(s)
ynh_use_logrotate

#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
ynh_script_progression --message="Integrating service in YunoHost..." --weight=10

yunohost service add $app --description="Veloren game server" --needs_exposed_ports "$port" --log="/var/log/$app/$app.log"

Expand Down
16 changes: 8 additions & 8 deletions scripts/remove
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=10

app=$YNH_APP_INSTANCE_NAME

Expand All @@ -27,14 +27,14 @@ get_app_settings
# 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..." --weight=1
ynh_script_progression --message="Removing $app service integration..." --weight=10
yunohost service remove $app
fi

#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=120
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=100

# Remove the dedicated systemd config
ynh_remove_systemd_config
Expand All @@ -50,23 +50,23 @@ ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
ynh_script_progression --message="Removing app main directory..." --weight=10

# Remove the app directory securely
ynh_secure_remove --file="$final_path"

#=================================================
# REMOVE APP DATA DIR
#=================================================
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_script_progression --message="Removing app data directory..." --weight=10

# Remove the data directory securely
ynh_secure_remove --file="$data_path"

#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
ynh_script_progression --message="Removing logrotate configuration..." --weight=10

# Remove the app-specific logrotate config
ynh_remove_logrotate
Expand All @@ -77,7 +77,7 @@ ynh_remove_logrotate

if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..." --weight=1
ynh_script_progression --message="Closing port $port..." --weight=10
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi

Expand All @@ -95,7 +95,7 @@ ynh_secure_remove --file="/var/log/$app"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
ynh_script_progression --message="Removing the dedicated system user..." --weight=10

# Delete a system user
ynh_system_user_delete --username=$app
Expand Down
14 changes: 7 additions & 7 deletions scripts/restore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=10

app=$YNH_APP_INSTANCE_NAME

Expand All @@ -32,7 +32,7 @@ get_app_settings
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_script_progression --message="Validating restoration parameters..." --weight=10

test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
Expand All @@ -44,7 +44,7 @@ test ! -d $data_path \
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
ynh_script_progression --message="Recreating the dedicated system user..." --weight=10

# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$data_path"
Expand All @@ -60,7 +60,7 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_script_progression --message="Restoring the app main directory..." --weight=10

ynh_restore_file --origin_path="$final_path"

Expand All @@ -79,22 +79,22 @@ ynh_restore_file --origin_path="/var/log/$app"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_script_progression --message="Restoring the systemd configuration..." --weight=10

ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet

#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
ynh_script_progression --message="Integrating service in YunoHost..." --weight=10

yunohost service add $app --description="Veloren game server" --needs_exposed_ports "$port" --log="/var/log/$app/$app.log"

#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression --message="Starting a systemd service..." --weight=10

ynh_systemd_action --service_name=$app --action="start" --line_match="Server is ready to accept connections." --log_path="/var/log/$app/$app.log"

Expand Down
22 changes: 11 additions & 11 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=10

app=$YNH_APP_INSTANCE_NAME

Expand All @@ -27,7 +27,7 @@ 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)..." --weight=1
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10

# Backup the current version of the app
ynh_backup_before_upgrade
Expand All @@ -45,14 +45,14 @@ ynh_abort_if_errors
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression --message="Stopping a systemd service..." --weight=10

ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"

#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=10

# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$data_path"
Expand All @@ -70,7 +70,7 @@ ynh_install_app_dependencies $pkg_dependencies

if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=155
ynh_script_progression --message="Upgrading source files..." --weight=100

# Download, check integrity, uncompress and patch the source from app.src
setup_source
Expand All @@ -81,7 +81,7 @@ fi
#=================================================
# COMPILE SERVER
#=================================================
ynh_script_progression --message="Compiling server..." --weight=135
ynh_script_progression --message="Compiling server..." --weight=100

compile_server

Expand All @@ -92,7 +92,7 @@ compile_server
map_generated=0

if [ $generate_custom_world -eq 1 ]; then
ynh_script_progression --message="Generating custom world..." --weight=730
ynh_script_progression --message="Generating custom world..." --weight=100

generate_custom_world
fi
Expand All @@ -106,25 +106,25 @@ add_configuration_files
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_script_progression --message="Upgrading systemd configuration..." --weight=10

# Create a dedicated systemd config
ynh_add_systemd_config --others_var="data_path"
ynh_add_systemd_config

#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=10

# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append

#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
ynh_script_progression --message="Integrating service in YunoHost..." --weight=10

yunohost service add $app --description="Veloren game server" --needs_exposed_ports "$port" --log="/var/log/$app/$app.log"

Expand Down

0 comments on commit f86e0b2

Please sign in to comment.