1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/shellinabox_ynh.git synced 2024-09-03 20:26:12 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2022-06-29 03:45:27 +02:00
parent 83014f5745
commit 3800b43a68
13 changed files with 192 additions and 121 deletions

View file

@ -10,14 +10,14 @@
setup_private=0
setup_public=0
upgrade=1
# 1.1.0
upgrade=1 from_commit=a94b50de8b68501148fa90419ad3ea8e24c675e1
#2.21~ynh2
upgrade=1 from_commit=83014f57450daf58746e7fb79003f52ad8d2da1e
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=a94b50de8b68501148fa90419ad3ea8e24c675e1
name=Refactoring
manifest_arg=domain=DOMAIN&path=PATH&

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Shell In A Box implements a web server that can export arbitrary command line tools to a web based terminal emulator. This emulator is accessible to any JavaScript and CSS enabled web browser and does not require any additional browser plugins.

0
doc/DISCLAIMER.md Normal file
View file

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 KiB

View file

@ -1,37 +1,44 @@
{
"name": "Shell In A Box",
"id": "shellinabox",
"packaging_format": 1,
"description": {
"en": "Web based AJAX terminal emulator",
"fr": "Émulateur de terminal web"
},
"version": "2.21~ynh2",
"url": "https://github.com/shellinabox/shellinabox",
"license": "GPL-2.0",
"maintainer": {
"name": "kload",
"email": "kload@kload.fr"
},
"requirements": {
"name": "Shell In A Box",
"id": "shellinabox",
"packaging_format": 1,
"description": {
"en": "Web based AJAX terminal emulator",
"fr": "Émulateur de terminal web"
},
"version": "2.21~ynh3",
"url": "https://github.com/shellinabox/shellinabox",
"upstream": {
"license": "GPL-2.0",
"website": "https://code.google.com/archive/p/shellinabox/",
"admindoc": "https://github.com/shellinabox/shellinabox/wiki/shellinaboxd_man",
"userdoc": "https://code.google.com/p/shellinabox/wiki/shellinaboxd_man",
"code": "https://github.com/shellinabox/shellinabox"
},
"license": "GPL-2.0",
"maintainer": {
"name": "kload",
"email": "kload@kload.fr"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/ssh",
"default": "/ssh"
}
]
}
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/ssh",
"default": "/ssh"
}
]
}
}

View file

@ -6,12 +6,17 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -29,19 +34,19 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="/etc/shellinabox"
ynh_backup --src_path="/etc/default/shellinabox"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/shellinabox"
ynh_backup --src_path="/etc/default/shellinabox"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -31,13 +31,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
@ -68,30 +69,30 @@ fi
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping shellinabox..." --weight=1
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=shellinabox --action=stop
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --weight=2
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for nginx
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
@ -106,9 +107,9 @@ fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting shellinabox..." --weight=2
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=shellinabox --action=start
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# RELOAD NGINX

View file

@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -48,14 +51,14 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=2
# Find a free port
# Find an available port
port=$(ynh_find_port --port=4200)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL SHELLINABOX
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing shellinabox..." --weight=7
ynh_script_progression --message="Installing dependencies..." --weight=7
ynh_package_update
ynh_install_app_dependencies $pkg_dependencies
@ -65,33 +68,44 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# CONFIGURE SHELLINABOX
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring shellinabox..." --weight=2
ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="../conf/shellinabox" --destination="/etc/default/shellinabox"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Allow the service to log in syslog
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
systemctl daemon-reload
ynh_systemd_action --service_name=shellinabox --action=restart
#=================================================
# GENERIC FINALIZATION
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Web based AJAX terminal emulator"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=shellinabox --action=restart
#=================================================
# RELOAD NGINX
#=================================================

View file

@ -22,31 +22,32 @@ port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status $app >/dev/null 2>&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..."
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
fi
#=================================================
# REMOVE SHELLINABOX
#=================================================
ynh_script_progression --message="Removing shellinabox..." --weight=20
ynh_package_autopurge shellinabox
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated nginx config
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_package_autopurge shellinabox
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,6 +14,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -28,44 +32,55 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# STANDARD RESTORATION STEPS
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_package_update
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# INSTALL SHELLINABOX
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Installing shellinabox..." --weight=7
ynh_package_update
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=3
ynh_script_progression --message="Restoring various files..." --weight=3
ynh_restore_file --origin_path="/etc/shellinabox"
ynh_restore_file --origin_path="/etc/default/shellinabox"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
# Allow the service to log in syslog
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
systemctl daemon-reload
ynh_systemd_action --service_name=shellinabox --action=restart
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Web based AJAX terminal emulator"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=shellinabox --action=restart
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -20,6 +20,37 @@ 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 VERSION
#=================================================
ynh_script_progression --message="Checking version..."
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=5
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -31,30 +62,6 @@ if [ -z "$port" ]; then
ynh_app_setting_set --app=$app --key=port --value=$port
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
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
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
@ -63,24 +70,44 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CONFIGURE SHELLINABOX
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading shellinabox configuration..." --weight=4
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=4
ynh_add_config --template="../conf/shellinabox" --destination="/etc/default/shellinabox"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
systemctl daemon-reload
ynh_systemd_action --service_name=shellinabox --action=restart
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Web based AJAX terminal emulator"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=shellinabox --action=restart
#=================================================
# RELOAD NGINX
#=================================================