mirror of
https://github.com/YunoHost-Apps/ztncui_ynh.git
synced 2024-09-03 18:06:05 +02:00
Merge pull request #23 from YunoHost-Apps/testing
Testing - packaging v2
This commit is contained in:
commit
159059e092
20 changed files with 219 additions and 729 deletions
13
README.md
13
README.md
|
@ -21,23 +21,12 @@ It allows you to take control of your own ZeroTier network without relying on th
|
|||
|
||||
|
||||
|
||||
**Shipped version:** 20230311~ynh1
|
||||
**Shipped version:** 20230311~ynh2
|
||||
|
||||
## Screenshots
|
||||
|
||||
![Screenshot of Zerotier UI](./doc/screenshots/screenshot.jpg)
|
||||
|
||||
## Disclaimers / important information
|
||||
|
||||
### Dependency
|
||||
|
||||
* [ZeroTier for YunoHost](https://github.com/YunoHost-Apps/zerotier_ynh) has to be installed beforehand.
|
||||
|
||||
### Multi-users support
|
||||
|
||||
* LDAP and HTTP auth are not supported.
|
||||
* Multiple users can use the app, you have to add them manually in `/opt/key-networks/ztncui/src/etc/passwd`, see ztncui's documentation.
|
||||
|
||||
## :red_circle: Antifeatures
|
||||
|
||||
- **Non-free dependencies**: Relies on software dependencies that are not free in order to run.
|
||||
|
|
13
README_fr.md
13
README_fr.md
|
@ -21,23 +21,12 @@ It allows you to take control of your own ZeroTier network without relying on th
|
|||
|
||||
|
||||
|
||||
**Version incluse :** 20230311~ynh1
|
||||
**Version incluse :** 20230311~ynh2
|
||||
|
||||
## Captures d’écran
|
||||
|
||||
![Capture d’écran de Zerotier UI](./doc/screenshots/screenshot.jpg)
|
||||
|
||||
## Avertissements / informations importantes
|
||||
|
||||
### Dependency
|
||||
|
||||
* [ZeroTier for YunoHost](https://github.com/YunoHost-Apps/zerotier_ynh) has to be installed beforehand.
|
||||
|
||||
### Multi-users support
|
||||
|
||||
* LDAP and HTTP auth are not supported.
|
||||
* Multiple users can use the app, you have to add them manually in `/opt/key-networks/ztncui/src/etc/passwd`, see ztncui's documentation.
|
||||
|
||||
## :red_circle: Anti-fonctionnalités
|
||||
|
||||
- **Dépendances non libres**: Dépend pour fonctionner de dépendances logicielles non libres.
|
||||
|
|
13
README_gl.md
13
README_gl.md
|
@ -21,23 +21,12 @@ It allows you to take control of your own ZeroTier network without relying on th
|
|||
|
||||
|
||||
|
||||
**Versión proporcionada:** 20230311~ynh1
|
||||
**Versión proporcionada:** 20230311~ynh2
|
||||
|
||||
## Capturas de pantalla
|
||||
|
||||
![Captura de pantalla de Zerotier UI](./doc/screenshots/screenshot.jpg)
|
||||
|
||||
## Avisos / información importante
|
||||
|
||||
### Dependency
|
||||
|
||||
* [ZeroTier for YunoHost](https://github.com/YunoHost-Apps/zerotier_ynh) has to be installed beforehand.
|
||||
|
||||
### Multi-users support
|
||||
|
||||
* LDAP and HTTP auth are not supported.
|
||||
* Multiple users can use the app, you have to add them manually in `/opt/key-networks/ztncui/src/etc/passwd`, see ztncui's documentation.
|
||||
|
||||
## :red_circle: Caraterísticas cuestionables
|
||||
|
||||
- **Non-free dependencies**: Relies on software dependencies that are not free in order to run.
|
||||
|
|
13
README_it.md
13
README_it.md
|
@ -21,23 +21,12 @@ It allows you to take control of your own ZeroTier network without relying on th
|
|||
|
||||
|
||||
|
||||
**Versione pubblicata:** 20230311~ynh1
|
||||
**Versione pubblicata:** 20230311~ynh2
|
||||
|
||||
## Screenshot
|
||||
|
||||
![Screenshot di Zerotier UI](./doc/screenshots/screenshot.jpg)
|
||||
|
||||
## Attenzione/informazioni importanti
|
||||
|
||||
### Dependency
|
||||
|
||||
* [ZeroTier for YunoHost](https://github.com/YunoHost-Apps/zerotier_ynh) has to be installed beforehand.
|
||||
|
||||
### Multi-users support
|
||||
|
||||
* LDAP and HTTP auth are not supported.
|
||||
* Multiple users can use the app, you have to add them manually in `/opt/key-networks/ztncui/src/etc/passwd`, see ztncui's documentation.
|
||||
|
||||
## :red_circle: Anti-funzionalità
|
||||
|
||||
- **Dipendenze non libere**: Per funzionare, si basa su dipendenze software non libere.
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
# See here for more information
|
||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||
|
||||
;; Test complet
|
||||
; pre-install
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/zerotier_ynh --force
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/"
|
||||
admin="john"
|
||||
is_public=1
|
||||
password="DaB3estPassw0rd"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=0
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
;upgrade=1 from_commit=CommitHash
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=DaB3estPassw0rd&port=666&
|
|
@ -1,5 +0,0 @@
|
|||
SOURCE_URL=https://github.com/key-networks/ztncui/archive/42248c13593e90f62238ee79ea5708a54eacf753.zip
|
||||
SOURCE_SUM=596450AF9F567D64EBDD488F0F379E3BFC0BB569EDEA6C832ADF0DC3DA693F0F
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -7,7 +7,7 @@ Type=simple
|
|||
User=__APP__
|
||||
Group=__APP__
|
||||
Environment="__YNH_NODE_LOAD_PATH__"
|
||||
WorkingDirectory=__FINALPATH__/src/
|
||||
WorkingDirectory=__INSTALL_DIR__/src/
|
||||
ExecStart=__YNH_NPM__ start
|
||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||
StandardError=inherit
|
||||
|
|
1
doc/ADMIN.md
Normal file
1
doc/ADMIN.md
Normal file
|
@ -0,0 +1 @@
|
|||
Multiple users can use the app, you have to add them manually in `/opt/key-networks/ztncui/src/etc/passwd`, see ztncui's documentation.
|
|
@ -1,8 +0,0 @@
|
|||
### Dependency
|
||||
|
||||
* [ZeroTier for YunoHost](https://github.com/YunoHost-Apps/zerotier_ynh) has to be installed beforehand.
|
||||
|
||||
### Multi-users support
|
||||
|
||||
* LDAP and HTTP auth are not supported.
|
||||
* Multiple users can use the app, you have to add them manually in `/opt/key-networks/ztncui/src/etc/passwd`, see ztncui's documentation.
|
1
doc/PRE_INSTALL.md
Normal file
1
doc/PRE_INSTALL.md
Normal file
|
@ -0,0 +1 @@
|
|||
[ZeroTier for YunoHost](https://github.com/YunoHost-Apps/zerotier_ynh) has to be installed beforehand if it's not already installed.
|
|
@ -1,67 +0,0 @@
|
|||
{
|
||||
"name": "Zerotier UI",
|
||||
"id": "ztncui",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "ZeroTier network controller user interface",
|
||||
"fr": "Interface utilisateur pour le contrôleur de réseau ZeroTier"
|
||||
},
|
||||
"version": "20230311~ynh1",
|
||||
"url": "https://key-networks.com/ztncui",
|
||||
"upstream": {
|
||||
"license": "GPL-3.0-only",
|
||||
"website": "https://key-networks.com/ztncui/",
|
||||
"code": "https://github.com/key-networks/ztncui"
|
||||
},
|
||||
"license": "GPL-3.0-only",
|
||||
"maintainer": {
|
||||
"name": "tituspijean",
|
||||
"email": "tituspijean@outlook.com"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.3"
|
||||
},
|
||||
"services": [],
|
||||
"multi_instance": false,
|
||||
"arguments": {
|
||||
"install": [
|
||||
{
|
||||
"name": "warning",
|
||||
"type": "alert",
|
||||
"ask": {
|
||||
"en": "REMINDER: ztncui needs the ZeroTier app to be already installed.",
|
||||
"fr": "RAPPEL: ztncui nécessite que l'app ZeroTier soit déjà installée."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"help": {
|
||||
"en": "Ztncui can only be installed at the root of a domain.",
|
||||
"fr": "Ztncui ne peut être installée qu'à la racine d'un domaine."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"help": {
|
||||
"en": "Ztncui has its own login system, but setting it as private is advised.",
|
||||
"fr": "Ztncui a son propre système de connexion, mais la rendre privée est conseillé."
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password",
|
||||
"help": {
|
||||
"en": "It will always be asked by Ztncui, in addition to your YunoHost credentials if set to private.",
|
||||
"fr": "Il sera toujours demandé par Ztncui, en plus des identifiants YunoHost si l'app est privée."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
67
manifest.toml
Normal file
67
manifest.toml
Normal file
|
@ -0,0 +1,67 @@
|
|||
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
|
||||
|
||||
packaging_format = 2
|
||||
|
||||
id = "ztncui"
|
||||
name = "Zerotier UI"
|
||||
description.en = "ZeroTier network controller user interface"
|
||||
description.fr = "Interface utilisateur pour le contrôleur de réseau ZeroTier"
|
||||
|
||||
version = "20230311~ynh2"
|
||||
|
||||
maintainers = ["tituspijean"]
|
||||
|
||||
[upstream]
|
||||
license = "GPL-3.0-only"
|
||||
website = "https://key-networks.com/ztncui/"
|
||||
code = "https://github.com/key-networks/ztncui"
|
||||
|
||||
[integration]
|
||||
yunohost = ">=11.2"
|
||||
architectures = "all"
|
||||
multi_instance = false
|
||||
ldap = false
|
||||
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]
|
||||
help.en = "Ztncui can only be installed at the root of a domain."
|
||||
help.fr = "Ztncui ne peut être installée qu'à la racine d'un domaine."
|
||||
type = "domain"
|
||||
|
||||
[install.init_main_permission]
|
||||
help.en = "Ztncui has its own login system, but setting it as private is advised."
|
||||
help.fr = "Ztncui a son propre système de connexion, mais la rendre privée est conseillé."
|
||||
type = "group"
|
||||
default = false
|
||||
|
||||
[install.admin]
|
||||
type = "user"
|
||||
|
||||
[install.password]
|
||||
help.en = "It will always be asked by Ztncui, in addition to your YunoHost credentials if set to private."
|
||||
help.fr = "Il sera toujours demandé par Ztncui, en plus des identifiants YunoHost si l'app est privée."
|
||||
type = "password"
|
||||
|
||||
[resources]
|
||||
[resources.sources.main]
|
||||
url = "https://github.com/key-networks/ztncui/archive/42248c13593e90f62238ee79ea5708a54eacf753.zip"
|
||||
sha256 = "596450af9f567d64ebdd488f0f379e3bfc0bb569edea6c832adf0dc3da693f0f"
|
||||
|
||||
autoupdate.strategy = "latest_github_commit"
|
||||
|
||||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
||||
[resources.ports]
|
||||
main.default = 8095
|
||||
|
||||
[resources.apt]
|
||||
packages = ["g++"]
|
|
@ -6,9 +6,6 @@
|
|||
|
||||
nodejs_version=14
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="g++"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,26 +7,6 @@
|
|||
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
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
@ -38,27 +16,23 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
# BACKUP THE SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup --src_path="/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,61 +7,6 @@
|
|||
source _common.sh
|
||||
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..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||
|
||||
# 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
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
@ -76,45 +19,14 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
183
scripts/install
183
scripts/install
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -10,69 +8,24 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
# INITIALIZE AND STORE SETTINGS
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
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
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
# Testing if ZeroTier is installed
|
||||
yunohost app list | grep -q "id: zerotier" || ynh_die "ZeroTier is needed, but it is not installed. There is a package for that!"
|
||||
if ! yunohost app list | grep -q "id: zerotier"; then
|
||||
ynh_die "ZeroTier is needed, but it is not installed. There is a package for that!"
|
||||
fi
|
||||
|
||||
final_path=/opt/yunohost/$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=final_path --value=$final_path
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
# Let's retrieve information on the ZeroTier installation
|
||||
zt_token="$(</var/lib/zerotier-one/authtoken.secret)"
|
||||
zt_addr="localhost:$(</var/lib/zerotier-one/zerotier-one.port)"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=2
|
||||
ynh_script_progression --message="Installing NodeJS..." --weight=2
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
||||
ynh_use_nodejs
|
||||
|
||||
#=================================================
|
||||
|
@ -80,130 +33,68 @@ ynh_use_nodejs
|
|||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=2
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# 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 -R o-rwx "$install_dir"
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
# APP INITIAL CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring nginx web server..." --weight=1
|
||||
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
ynh_add_config --template="env" --destination="$install_dir/src/.env"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
chown "$app:$app" "$install_dir/src/.env"
|
||||
chmod 600 "$install_dir/src/.env"
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create $app $final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# NPM INSTALL
|
||||
#=================================================
|
||||
ynh_script_progression --message="Performing Node app installation..." --weight=3
|
||||
ynh_script_progression --message="Building $app..." --weight=3
|
||||
|
||||
chown -R $app: $final_path
|
||||
|
||||
pushd $final_path/src
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install node-gyp
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install argon2-cli
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm audit fix
|
||||
pushd "$install_dir/src"
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install node-gyp
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install argon2-cli
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" audit fix
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
# Let's retrieve information on the ZeroTier installation
|
||||
zt_token="$(</var/lib/zerotier-one/authtoken.secret)"
|
||||
zt_addr="localhost:$(</var/lib/zerotier-one/zerotier-one.port)"
|
||||
|
||||
ynh_add_config --template="env" --destination="$final_path/src/.env"
|
||||
chown $app:$app "$final_path/src/.env"
|
||||
chmod 600 "$final_path/src/.env"
|
||||
|
||||
# Setup user credentials file
|
||||
hashedpassword=$(echo -n "$password" | $final_path/src/node_modules/.bin/argon2-cli -e)
|
||||
echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" > "$final_path/src/etc/passwd"
|
||||
|
||||
# Store user settings
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=hashedpassword --value=$hashedpassword
|
||||
hashedpassword=$(echo -n "$password" | $install_dir/src/node_modules/.bin/argon2-cli -e)
|
||||
echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" > "$install_dir/src/etc/passwd"
|
||||
|
||||
#=================================================
|
||||
# LINK CERTIFICATES
|
||||
#=================================================
|
||||
|
||||
# Even though one can stay in HTTP mode, the ztncui requires SSL certificates
|
||||
# let's use the ones of the domain
|
||||
pushd $final_path/src/etc/tls
|
||||
cp /etc/yunohost/certs/$domain/key.pem privkey.pem
|
||||
cp /etc/yunohost/certs/$domain/crt.pem fullchain.pem
|
||||
popd
|
||||
# let's use the ones of the domain
|
||||
cp "/etc/yunohost/certs/$domain/key.pem" "$install_dir/src/etc/tls/privkey.pem"
|
||||
cp "/etc/yunohost/certs/$domain/crt.pem" "$install_dir/src/etc/tls/fullchain.pem"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
yunohost service add "$app" --description "ZeroTier network controller user interface" --log "/var/log/$app/$app.log"
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description "ZeroTier network controller user interface" --log "/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting the systemd service..." --weight=1
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring SSOwat..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_permission_update --permission "main" --add visitors
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -10,73 +8,24 @@ source _common.sh
|
|||
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)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=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..." --weight=1
|
||||
yunohost service remove $app
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=2
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
ynh_remove_nodejs
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
|
@ -86,14 +35,11 @@ ynh_script_progression --message="Removing various files..." --weight=1
|
|||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
ynh_script_progression --message="Removing NodeJS..." --weight=2
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
ynh_remove_nodejs
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
110
scripts/restore
110
scripts/restore
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -10,112 +8,48 @@ source ../settings/scripts/_common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing NodeJS..." --weight=2
|
||||
|
||||
ynh_clean_setup () {
|
||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading 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)
|
||||
nodejs_version=$(ynh_app_setting_get --app=$app --key=nodejs_version)
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
||||
ynh_use_nodejs
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
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 -R o-rwx "$install_dir"
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=2
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
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
|
||||
|
||||
yunohost service add $app --description "ZeroTier network controller user interface" --log "/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
systemctl enable "$app.service" --quiet
|
||||
yunohost service add "$app" --description "ZeroTier network controller user interface" --log "/var/log/$app/$app.log"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
mkdir -p "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
|
||||
ynh_restore_file --origin_path="/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
211
scripts/upgrade
211
scripts/upgrade
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -10,206 +8,115 @@ source _common.sh
|
|||
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)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
hashedpassword=$(ynh_app_setting_get --app=$app --key=hashedpassword)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
# INITIALIZE AND STORE SETTINGS
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
# Testing if ZeroTier is installed
|
||||
if ! yunohost app list | grep -q "id: zerotier"; then
|
||||
ynh_die "ZeroTier is needed, but it is not installed. There is a package for that!"
|
||||
fi
|
||||
|
||||
# Let's retrieve information on the ZeroTier installation
|
||||
zt_token="$(</var/lib/zerotier-one/authtoken.secret)"
|
||||
zt_addr="localhost:$(</var/lib/zerotier-one/zerotier-one.port)"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
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
|
||||
|
||||
# If admin or password do not exist, assign the standard ones and have them replaced upon first login
|
||||
if [ -z "$admin" ] || [ -z "$hashedpassword" ]; then
|
||||
admin="admin"
|
||||
hashedpassword='$argon2i$v=19$m=4096,t=3,p=1$/VYxjWHBzbkuCEO6Hh0AUw$nJaTJtth57vCAyYvg+UbtnscilR0UcE02AfLOhERe3A'
|
||||
pass_set="false"
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$hashedpassword --key=hashedpassword --value=$hashedpassword
|
||||
if [ -z "${admin:-}" ] || [ -z "${hashedpassword:-}" ]; then
|
||||
admin="admin"
|
||||
hashedpassword='$argon2i$v=19$m=4096,t=3,p=1$/VYxjWHBzbkuCEO6Hh0AUw$nJaTJtth57vCAyYvg+UbtnscilR0UcE02AfLOhERe3A'
|
||||
pass_set="false"
|
||||
ynh_app_setting_set --app="$app" --key="admin" --value="$admin"
|
||||
ynh_app_setting_set --app="$app" --key="hashedpassword" --value="$hashedpassword"
|
||||
|
||||
# Setup user credentials file
|
||||
echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":$pass_set,\"hash\":\"$hashedpassword\"}}" > "$final_path/src/etc/passwd"
|
||||
# Setup user credentials file
|
||||
echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":$pass_set,\"hash\":\"$hashedpassword\"}}" > "$install_dir/src/etc/passwd"
|
||||
else
|
||||
pass_set="true"
|
||||
pass_set="true"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
|
||||
|
||||
# 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
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NodeJS..." --weight=2
|
||||
|
||||
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
||||
ynh_use_nodejs
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="src/.env"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
fi
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1
|
||||
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
ynh_add_config --template="env" --destination="$install_dir/src/.env"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=2
|
||||
chown "$app:$app" "$install_dir/src/.env"
|
||||
chmod 600 "$install_dir/src/.env"
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
if [ $nodejs_version != $(ynh_app_setting_get --app=$app --key=nodejs_version) ]; then
|
||||
ynh_remove_nodejs
|
||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# 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 $app $final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# NPM INSTALL
|
||||
#=================================================
|
||||
ynh_script_progression --message="Performing Node app installation..." --weight=3
|
||||
ynh_script_progression --message="Building $app..." --weight=3
|
||||
|
||||
chown -R $app: $final_path
|
||||
|
||||
ynh_use_nodejs
|
||||
|
||||
pushd $final_path/src
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME=$final_path $ynh_npm install node-gyp
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME=$final_path $ynh_npm install argon2-cli
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME=$final_path $ynh_npm install
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME=$final_path $ynh_npm audit fix
|
||||
pushd "$install_dir/src"
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "HOME=$install_dir" "$ynh_npm" install node-gyp
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "HOME=$install_dir" "$ynh_npm" install argon2-cli
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "HOME=$install_dir" "$ynh_npm" install
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "HOME=$install_dir" "$ynh_npm" audit fix
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
# Let's retrieve information on the ZeroTier installation
|
||||
zt_token="$(</var/lib/zerotier-one/authtoken.secret)"
|
||||
zt_addr="localhost:$(</var/lib/zerotier-one/zerotier-one.port)"
|
||||
|
||||
ynh_add_config --template="env" --destination="$final_path/src/.env"
|
||||
chown $app:$app "$final_path/src/.env"
|
||||
chmod 600 "$final_path/src/.env"
|
||||
|
||||
#=================================================
|
||||
# LINK CERTIFICATES
|
||||
#=================================================
|
||||
|
||||
# Even though one can stay in HTTP mode, the ztncui requires SSL certificates
|
||||
# let's use the ones of the domain
|
||||
pushd $final_path/src/etc/tls
|
||||
cp -f /etc/yunohost/certs/$domain/key.pem privkey.pem
|
||||
cp -f /etc/yunohost/certs/$domain/crt.pem fullchain.pem
|
||||
popd
|
||||
# let's use the ones of the domain
|
||||
cp "/etc/yunohost/certs/$domain/key.pem" "$install_dir/src/etc/tls/privkey.pem"
|
||||
cp "/etc/yunohost/certs/$domain/crt.pem" "$install_dir/src/etc/tls/fullchain.pem"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
yunohost service add "$app" --description "ZeroTier network controller user interface" --log "/var/log/$app/$app.log"
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description "ZeroTier network controller user interface" --log "/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
@ -218,5 +125,5 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
||||
if [ $pass_set = "false" ]; then
|
||||
ynh_print_warn --message="Default ztncui credentials were reset: admin/password"
|
||||
ynh_print_warn --message="Default ztncui credentials were reset: admin/password"
|
||||
fi
|
||||
|
|
13
tests.toml
Normal file
13
tests.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
|
||||
|
||||
test_format = 1.0
|
||||
|
||||
[default]
|
||||
|
||||
preinstall = """
|
||||
sudo yunohost tools update apps
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/zerotier_ynh --force
|
||||
"""
|
||||
|
||||
|
||||
test_upgrade_from.3678d9bb24cc8ec74eff31ea255a1f38b031f2c8.name = "Packaging v1"
|
Loading…
Reference in a new issue