mirror of
https://github.com/YunoHost-Apps/shellinabox_ynh.git
synced 2024-09-03 20:26:12 +02:00
Merge pull request #15 from YunoHost-Apps/package_upgrade
Normalization from example_ynh
This commit is contained in:
commit
3371a31f7f
9 changed files with 81 additions and 87 deletions
|
@ -29,9 +29,9 @@ Shell In A Box implements a web server that can export arbitrary command line to
|
|||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/shellinabox%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/shellinabox/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/shellinabox%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/shellinabox/)
|
||||
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/shellinabox%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/shellinabox/)
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/shellinabox%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/shellinabox/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/shellinabox%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/shellinabox/)
|
||||
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/shellinabox%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/shellinabox/)
|
||||
|
||||
## Limitations
|
||||
|
||||
|
@ -41,6 +41,7 @@ Shell In A Box implements a web server that can export arbitrary command line to
|
|||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/shellinabox_ynh/issues
|
||||
* Shell In A Box website: https://github.com/shellinabox/shellinabox
|
||||
* Shell In A Box repository: https://github.com/shellinabox/shellinabox
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
|
|
@ -17,17 +17,7 @@
|
|||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
Level 4=na
|
||||
# Level 5: https://github.com/YunoHost-Apps/shellinabox_ynh/issues/3
|
||||
Level 5=1
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
Level 5=auto
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
|
|
|
@ -14,7 +14,7 @@ location __PATH__/ {
|
|||
access_log off;
|
||||
|
||||
# Allow shellinabox to use 'eval' without blocking the execution. But keep a warning.
|
||||
add_header Content-Security-Policy-Report-Only "script-src https: 'unsafe-eval'";
|
||||
more_set_headers Content-Security-Policy-Report-Only "script-src https: 'unsafe-eval'";
|
||||
|
||||
more_clear_input_headers 'Accept-Encoding';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"email": "kload@kload.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.2.0"
|
||||
"yunohost": ">= 3.5.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -18,31 +18,31 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the main app directory..."
|
||||
ynh_script_progression --message="Backing up the main app directory..."
|
||||
|
||||
ynh_backup "/etc/shellinabox"
|
||||
ynh_backup "/etc/default/shellinabox"
|
||||
ynh_backup --src_path="/etc/shellinabox"
|
||||
ynh_backup --src_path="/etc/default/shellinabox"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up nginx web server configuration..."
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
|
|
|
@ -27,37 +27,34 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info "Validating installation parameters..."
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info "Storing installation settings..."
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_print_info "Looking for a free port..."
|
||||
ynh_script_progression --message="Configuring firewall..." --weight=2
|
||||
|
||||
# Find a free port
|
||||
port=$(ynh_find_port 4200)
|
||||
ynh_app_setting_set $app port $port
|
||||
port=$(ynh_find_port --port=4200)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
# INSTALL SHELLINABOX
|
||||
#=================================================
|
||||
ynh_print_info "Installing shellinabox..."
|
||||
ynh_script_progression --message="Installing shellinabox..." --weight=7
|
||||
|
||||
ynh_package_update
|
||||
ynh_package_install shellinabox
|
||||
|
@ -65,7 +62,7 @@ ynh_package_install shellinabox
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
ynh_script_progression --message="Configuring nginx web server..." --weight=2
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -75,23 +72,23 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# CONFIGURE SHELLINABOX
|
||||
#=================================================
|
||||
ynh_print_info "Configuring shellinabox..."
|
||||
ynh_script_progression --message="Configuring shellinabox..." --weight=2
|
||||
|
||||
cp ../conf/shellinabox /etc/default/shellinabox
|
||||
ynh_replace_string "__PORT__" "$port" "/etc/default/shellinabox"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/default/shellinabox"
|
||||
|
||||
# Allow the service to log in syslog
|
||||
ynh_replace_string " -- -q --background" " -- --background" "/etc/init.d/shellinabox"
|
||||
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
|
||||
systemctl daemon-reload
|
||||
|
||||
systemctl restart shellinabox
|
||||
ynh_systemd_action --service_name=shellinabox --action=restart
|
||||
|
||||
#=================================================
|
||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "/etc/default/shellinabox"
|
||||
ynh_store_file_checksum --file="/etc/default/shellinabox"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -104,12 +101,12 @@ yunohost service add $app
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Installation of $app completed"
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -11,12 +11,12 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -27,21 +27,27 @@ port=$(ynh_app_setting_get $app port)
|
|||
# Remove a service from the admin panel, added by `yunohost service add`
|
||||
if yunohost service status $app >/dev/null 2>&1
|
||||
then
|
||||
ynh_print_info "Removing $app service"
|
||||
ynh_script_progression --message="Removing $app service..."
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE SHELLINABOX
|
||||
#=================================================
|
||||
ynh_print_info "Removing shellinabox"
|
||||
ynh_script_progression --message="Removing shellinabox..." --weight=20
|
||||
|
||||
ynh_package_autopurge shellinabox
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing nginx web server configuration"
|
||||
ynh_script_progression --message="Removing nginx web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -18,21 +18,21 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading settings..."
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info "Validating restoration parameters..."
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -40,12 +40,12 @@ ynh_webpath_available $domain $path_url \
|
|||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# INSTALL SHELLINABOX
|
||||
#=================================================
|
||||
ynh_print_info "Installing shellinabox..."
|
||||
ynh_script_progression --message="Installing shellinabox..." --weight=7
|
||||
|
||||
ynh_package_update
|
||||
ynh_package_install shellinabox
|
||||
|
@ -53,16 +53,17 @@ ynh_package_install shellinabox
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the app main directory..."
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=3
|
||||
|
||||
ynh_restore_file "/etc/shellinabox"
|
||||
ynh_restore_file "/etc/default/shellinabox"
|
||||
ynh_restore_file --origin_path="/etc/shellinabox"
|
||||
ynh_restore_file --origin_path="/etc/default/shellinabox"
|
||||
|
||||
# Allow the service to log in syslog
|
||||
ynh_replace_string " -- -q --background" " -- --background" "/etc/init.d/shellinabox"
|
||||
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
systemctl restart shellinabox
|
||||
ynh_systemd_action --service_name=shellinabox --action=restart
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
|
@ -75,12 +76,12 @@ yunohost service add $app
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server and php-fpm..."
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoration completed for $app"
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
|
@ -11,29 +11,29 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_print_info "Ensuring downward compatibility..."
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
|
||||
|
||||
# If port doesn't exist, create it
|
||||
if [ -z "$port" ]; then
|
||||
port=4200
|
||||
ynh_app_setting_set $app port $port
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info "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=5
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -49,14 +49,14 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading nginx web server configuration..."
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -64,36 +64,35 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# CONFIGURE SHELLINABOX
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading shellinabox configuration..."
|
||||
ynh_script_progression --message="Upgrading shellinabox configuration..." --weight=4
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different "/etc/default/shellinabox"
|
||||
ynh_backup_if_checksum_is_different --file="/etc/default/shellinabox"
|
||||
|
||||
cp ../conf/shellinabox /etc/default/shellinabox
|
||||
ynh_replace_string "__PORT__" "$port" "/etc/default/shellinabox"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/default/shellinabox"
|
||||
|
||||
# Allow the service to log in syslog
|
||||
ynh_replace_string " -- -q --background" " -- --background" "/etc/init.d/shellinabox"
|
||||
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
|
||||
systemctl daemon-reload
|
||||
|
||||
systemctl restart shellinabox
|
||||
ynh_systemd_action --service_name=shellinabox --action=restart
|
||||
|
||||
#=================================================
|
||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "/etc/default/shellinabox"
|
||||
ynh_store_file_checksum --file="/etc/default/shellinabox"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Upgrade of $app completed"
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue