mirror of
https://github.com/YunoHost-Apps/wetty_ynh.git
synced 2024-09-03 18:16:29 +02:00
Manifest v2 port
This commit is contained in:
parent
f381760def
commit
b7f0114af1
11 changed files with 88 additions and 394 deletions
|
@ -1,6 +0,0 @@
|
||||||
SOURCE_URL=https://github.com/butlerx/wetty/archive/refs/tags/v2.5.0.tar.gz
|
|
||||||
SOURCE_SUM=a6f7e3687619c29b2b8cc04b502fd8207c53a895527849557d3d3ed7f362cbac
|
|
||||||
SOURCE_SUM_PRG=sha256sum
|
|
||||||
SOURCE_FORMAT=tar.gz
|
|
||||||
SOURCE_IN_SUBDIR=true
|
|
||||||
SOURCE_EXTRACT=true
|
|
|
@ -12,7 +12,7 @@
|
||||||
// config: '/home/user/.wetty_ssh_config', // alternative ssh configuration file, see "-F" option in ssh(1)
|
// config: '/home/user/.wetty_ssh_config', // alternative ssh configuration file, see "-F" option in ssh(1)
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
base: '__PATH_URL__', // URL base to serve resources from
|
base: '__PATH__', // URL base to serve resources from
|
||||||
port: __PORT__, // Port to listen on
|
port: __PORT__, // Port to listen on
|
||||||
host: '127.0.0.1', // address to listen on
|
host: '127.0.0.1', // address to listen on
|
||||||
title: 'WeTTy - The Web Terminal Emulator', // Page title
|
title: 'WeTTy - The Web Terminal Emulator', // Page title
|
||||||
|
|
|
@ -7,7 +7,7 @@ Type=simple
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/
|
WorkingDirectory=__INSTALL_DIR__/
|
||||||
ExecStart=__YNH_NODE__ . --conf ./config.json5
|
ExecStart=__YNH_NODE__ . --conf ./config.json5
|
||||||
TimeoutStopSec=20
|
TimeoutStopSec=20
|
||||||
KillMode=mixed
|
KillMode=mixed
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Wetty",
|
|
||||||
"id": "wetty",
|
|
||||||
"packaging_format": 1,
|
|
||||||
"description": {
|
|
||||||
"en": "Terminal in browser over HTTP/HTTPS",
|
|
||||||
"fr": "Un terminal dans le navigateur sur HTTP/HTTPS"
|
|
||||||
},
|
|
||||||
"version": "2.5.0~ynh2",
|
|
||||||
"url": "https://github.com/butlerx/wetty/",
|
|
||||||
"license": "MIT",
|
|
||||||
"upstream": {
|
|
||||||
"license": "MIT",
|
|
||||||
"admindoc": "https://github.com/butlerx/wetty/tree/main/docs",
|
|
||||||
"code": "https://github.com/butlerx/wetty",
|
|
||||||
"screenshots": [
|
|
||||||
"https://raw.githubusercontent.com/butlerx/wetty/main/docs/terminal.png"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"maintainer": {
|
|
||||||
"name": "Salamandar",
|
|
||||||
"email": "salamandar@salamandar.fr"
|
|
||||||
},
|
|
||||||
"requirements": {
|
|
||||||
"yunohost": ">= 11.0.9"
|
|
||||||
},
|
|
||||||
"multi_instance": true,
|
|
||||||
"services": [
|
|
||||||
"nginx"
|
|
||||||
],
|
|
||||||
"arguments": {
|
|
||||||
"install": [
|
|
||||||
{
|
|
||||||
"name": "domain",
|
|
||||||
"type": "domain"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "path",
|
|
||||||
"type": "path",
|
|
||||||
"example": "/wetty",
|
|
||||||
"default": "/wetty"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is_public",
|
|
||||||
"type": "boolean",
|
|
||||||
"help": {
|
|
||||||
"en": "Even if public, it still requires authentication.",
|
|
||||||
"fr": "Même publique, vous devrez vous authentifier"
|
|
||||||
},
|
|
||||||
"default": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
54
manifest.toml
Normal file
54
manifest.toml
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "wetty"
|
||||||
|
name = "Wetty"
|
||||||
|
description.en = "Terminal in browser over http/https. (Ajaxterm/Anyterm alternative, but much better)"
|
||||||
|
description.fr = "Un terminal dans le navigateur sur http/https. (Alternative à Ajaxterm/Anyterm, mais bien meilleur)"
|
||||||
|
|
||||||
|
version = "2.5.0~ynh3"
|
||||||
|
|
||||||
|
maintainers = ["Salamandar"]
|
||||||
|
|
||||||
|
[upstream]
|
||||||
|
license = "free"
|
||||||
|
website = "https://github.com/butlerx/wetty/"
|
||||||
|
|
||||||
|
[integration]
|
||||||
|
yunohost = ">=11.1.0"
|
||||||
|
architectures = "all"
|
||||||
|
multi_instance = true
|
||||||
|
ldap = "not_relevant"
|
||||||
|
sso = false
|
||||||
|
# disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
|
||||||
|
# ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||||
|
# ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||||
|
|
||||||
|
[install]
|
||||||
|
[install.domain]
|
||||||
|
type = "domain"
|
||||||
|
|
||||||
|
[install.path]
|
||||||
|
type = "path"
|
||||||
|
default = "/wetty"
|
||||||
|
|
||||||
|
[install.init_main_permission]
|
||||||
|
help.en = "Even if public, it still requires authentication."
|
||||||
|
help.fr = "Même publique, vous devrez vous authentifier"
|
||||||
|
type = "group"
|
||||||
|
default = false
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
[resources.sources.main]
|
||||||
|
url = "https://github.com/butlerx/wetty/archive/refs/tags/v2.5.0.tar.gz"
|
||||||
|
sha256 = "a6f7e3687619c29b2b8cc04b502fd8207c53a895527849557d3d3ed7f362cbac"
|
||||||
|
autoupdate.strategy = "latest_github_release"
|
||||||
|
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
main.url = "/"
|
||||||
|
|
||||||
|
[resources.ports]
|
||||||
|
main.default = 8095
|
|
@ -10,26 +10,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Loading installation settings..."
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -39,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
|
|
@ -9,60 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
|
||||||
old_path=$YNH_APP_OLD_PATH
|
|
||||||
|
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
|
||||||
new_path=$YNH_APP_NEW_PATH
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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 () {
|
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Restore it if the upgrade fails
|
|
||||||
ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
change_domain=0
|
|
||||||
if [ "$old_domain" != "$new_domain" ]
|
|
||||||
then
|
|
||||||
change_domain=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
change_path=0
|
|
||||||
if [ "$old_path" != "$new_path" ]
|
|
||||||
then
|
|
||||||
change_path=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -77,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
# 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
|
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
|
||||||
# Set global variables for NGINX helper
|
|
||||||
domain="$old_domain"
|
|
||||||
path_url="$new_path"
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change the domain for NGINX
|
|
||||||
if [ $change_domain -eq 1 ]
|
|
||||||
then
|
|
||||||
# Delete file checksum for the old conf file location
|
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
|
||||||
# Store file checksum for the new config file location
|
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
|
@ -112,10 +36,10 @@ domain="$new_domain"
|
||||||
path_url="$new_path"
|
path_url="$new_path"
|
||||||
# port is already defined in this file
|
# port is already defined in this file
|
||||||
|
|
||||||
ynh_add_config --template="config.json5" --destination="$final_path/config.json5"
|
ynh_add_config --template="config.json5" --destination="$install_dir/config.json5"
|
||||||
|
|
||||||
chmod 400 "$final_path/config.json5"
|
chmod 400 "$install_dir/config.json5"
|
||||||
chown $app:$app "$final_path/config.json5"
|
chown $app:$app "$install_dir/config.json5"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
|
103
scripts/install
103
scripts/install
|
@ -9,57 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
|
||||||
path_url=$YNH_APP_ARG_PATH
|
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
||||||
#=================================================
|
|
||||||
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"
|
|
||||||
|
|
||||||
# Register (book) web path
|
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STORE SETTINGS FROM MANIFEST
|
|
||||||
#=================================================
|
|
||||||
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
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
|
||||||
# FIND AND OPEN A PORT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Finding an available port..." --weight=1
|
|
||||||
|
|
||||||
# Find an available port
|
|
||||||
port=$(ynh_find_port --port=8095)
|
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
|
||||||
|
|
||||||
# DO NOT OPEN THIS PORT
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -71,34 +20,22 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
# Install Yarn
|
# Install Yarn
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" \
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" \
|
||||||
--package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
--package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
--package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
|
||||||
chmod -R o-rwx "$final_path"
|
|
||||||
chown -R $app:$app "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
ynh_script_progression --message="Configuring nginx web server..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -108,22 +45,22 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||||
|
|
||||||
ynh_add_config --template="config.json5" --destination="$final_path/config.json5"
|
ynh_add_config --template="config.json5" --destination="$install_dir/config.json5"
|
||||||
|
|
||||||
chmod 400 "$final_path/config.json5"
|
chmod 400 "$install_dir/config.json5"
|
||||||
chown $app:$app "$final_path/config.json5"
|
chown $app:$app "$install_dir/config.json5"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD YARN DEPENDENCIES
|
# BUILD YARN DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building Yarn dependencies... This may take several minutes for a first install." --weight=6
|
ynh_script_progression --message="Building Yarn dependencies... This may take several minutes for a first install." --weight=6
|
||||||
|
|
||||||
pushd "$final_path" || return 1
|
pushd "$install_dir" || return 1
|
||||||
ynh_use_nodejs ; set "${ynh_node_load_PATH:?}"
|
ynh_use_nodejs ; set "${ynh_node_load_PATH:?}"
|
||||||
sudo -u $app env "$ynh_node_load_PATH" yarn
|
sudo -u $app env "$ynh_node_load_PATH" yarn
|
||||||
sudo -u $app env "$ynh_node_load_PATH" yarn build
|
sudo -u $app env "$ynh_node_load_PATH" yarn build
|
||||||
sudo -u $app env "$ynh_node_load_PATH" yarn install --production --ignore-scripts --prefer-offline
|
sudo -u $app env "$ynh_node_load_PATH" yarn install --production --ignore-scripts --prefer-offline
|
||||||
ynh_secure_remove --file="$final_path/.cache"
|
ynh_secure_remove --file="$install_dir/.cache"
|
||||||
popd || return 1
|
popd || return 1
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -159,28 +96,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
# Start 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 started"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server started"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SSOWAT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
|
||||||
|
|
||||||
# Make app public if necessary
|
|
||||||
if [ $is_public -eq 1 ]
|
|
||||||
then
|
|
||||||
# Everyone can access the app.
|
|
||||||
# The "main" permission is automatically created before the install script.
|
|
||||||
ynh_permission_update --permission="main" --add="visitors"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_permission_url --permission="main" --auth_header=false
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -9,16 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -40,22 +30,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing dependencies..." --weight=3
|
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
|
||||||
ynh_remove_app_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE APP MAIN DIR
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
|
||||||
|
|
||||||
# Remove the app directory securely
|
|
||||||
ynh_secure_remove --file="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -72,16 +46,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
|
||||||
|
|
||||||
# Delete a system user
|
|
||||||
ynh_system_user_delete --username=$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -10,35 +10,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
|
||||||
|
|
||||||
test ! -d $final_path \
|
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -48,24 +19,19 @@ ynh_script_progression --message="Restoring the NGINX configuration..." --weight
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
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..." --weight=1
|
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# 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=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
#=================================================
|
||||||
chmod -R o-rwx "$final_path"
|
# RESTORE USER RIGHTS
|
||||||
chown -R $app:$app "$final_path"
|
#=================================================
|
||||||
|
|
||||||
|
# Restore permissions on app files
|
||||||
|
chown -R root: "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
|
|
@ -9,18 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -28,18 +16,9 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
|
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||||
|
|
||||||
# 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
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -55,30 +34,9 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
|
||||||
if [ -z "$final_path" ]; then
|
|
||||||
final_path="/var/www/$app"
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value="$final_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cleaning legacy permissions
|
|
||||||
if ynh_legacy_permissions_exists; then
|
|
||||||
ynh_legacy_permissions_delete_all
|
|
||||||
|
|
||||||
ynh_app_setting_delete --app=$app --key=is_public
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Disable auth_header
|
# Disable auth_header
|
||||||
ynh_permission_url --permission="main" --auth_header=false
|
ynh_permission_url --permission="main" --auth_header=false
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -88,11 +46,11 @@ then
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
ynh_script_progression --message="Upgrading source files..."
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod -R u=rwX,g=rX,o= "$final_path"
|
chmod -R u=rwX,g=rX,o= "$install_dir"
|
||||||
chown -R $app:$app "$final_path"
|
chown -R $app:$app "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -121,24 +79,24 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..."
|
ynh_script_progression --message="Updating a configuration file..."
|
||||||
|
|
||||||
ynh_add_config --template="config.json5" --destination="$final_path/config.json5"
|
ynh_add_config --template="config.json5" --destination="$install_dir/config.json5"
|
||||||
|
|
||||||
chmod 400 "$final_path/config.json5"
|
chmod 400 "$install_dir/config.json5"
|
||||||
chown $app:$app "$final_path/config.json5"
|
chown $app:$app "$install_dir/config.json5"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD YARN DEPENDENCIES
|
# BUILD YARN DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Rebuilding Yarn dependencies..." --weight=2
|
ynh_script_progression --message="Rebuilding Yarn dependencies..." --weight=2
|
||||||
|
|
||||||
chown -R $app:$app "$final_path"
|
chown -R $app:$app "$install_dir"
|
||||||
|
|
||||||
pushd "$final_path" || return 1
|
pushd "$install_dir" || return 1
|
||||||
ynh_use_nodejs ; set "${ynh_node_load_PATH:?}"
|
ynh_use_nodejs ; set "${ynh_node_load_PATH:?}"
|
||||||
sudo -u $app env "$ynh_node_load_PATH" yarn
|
sudo -u $app env "$ynh_node_load_PATH" yarn
|
||||||
sudo -u $app env "$ynh_node_load_PATH" yarn build
|
sudo -u $app env "$ynh_node_load_PATH" yarn build
|
||||||
sudo -u $app env "$ynh_node_load_PATH" yarn install --production --ignore-scripts --prefer-offline
|
sudo -u $app env "$ynh_node_load_PATH" yarn install --production --ignore-scripts --prefer-offline
|
||||||
ynh_secure_remove --file="$final_path/.cache"
|
ynh_secure_remove --file="$install_dir/.cache"
|
||||||
popd || return 1
|
popd || return 1
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -173,13 +131,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server started"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server started"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue