mirror of
https://github.com/YunoHost-Apps/ztncui_ynh.git
synced 2024-09-03 18:06:05 +02:00
Merge branch 'master' into better-name
This commit is contained in:
commit
07da25eda4
9 changed files with 214 additions and 108 deletions
10
README.md
10
README.md
|
@ -19,19 +19,19 @@ ztncui is a web user interface for a standalone ZeroTier network controller. It
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
How to configure this app: by an admin panel, a plain file with SSH, or any other way.
|
No particular configuration is needed after initial installation.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
* Official documentation: Link to the official documentation of this app
|
* [Official documentation](https://key-networks.com/ztncui/)
|
||||||
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
|
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
|
||||||
|
|
||||||
## YunoHost specific features
|
## YunoHost specific features
|
||||||
|
|
||||||
#### Multi-users support
|
#### Multi-users support
|
||||||
|
|
||||||
* No LDAP and HTTP auth supported. ztncui implements its own `passwd` file.
|
* No LDAP and HTTP auth supported.
|
||||||
* Can the app be used by multiple users? Yes. See `/opt/key-networks/ztncui/src/etc/passwd`
|
* Can the app be used by multiple users? Yes, you have to add them manually in `/opt/key-networks/ztncui/src/etc/passwd`, see ztncui documentation.
|
||||||
|
|
||||||
#### Supported architectures
|
#### Supported architectures
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ How to configure this app: by an admin panel, a plain file with SSH, or any othe
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
* [ZeroTier for YunoHost](https://github.com/tituspijean/zerotier_ynh) has to be installed beforehand.
|
* [ZeroTier for YunoHost](https://github.com/YunoHost-Apps/zerotier_ynh) has to be installed beforehand.
|
||||||
|
|
||||||
## Additional information
|
## Additional information
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
password="pass"
|
password="pass"
|
||||||
port="666" (PORT)
|
port="666" (PORT)
|
||||||
|
; pre-install
|
||||||
|
sudo yunohost app fetchlist
|
||||||
|
sudo yunohost app install zerotier
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
@ -20,9 +23,9 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
upgrade=1 from_commit=CommitHash
|
;upgrade=1 from_commit=CommitHash
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=0
|
||||||
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||||
# incorrect_path=1
|
# incorrect_path=1
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
|
@ -37,4 +40,3 @@ Notification=none
|
||||||
; commit=CommitHash
|
; commit=CommitHash
|
||||||
name=Name and date of the commit.
|
name=Name and date of the commit.
|
||||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
pushd __FINALPATH__/src/
|
|
||||||
npm start
|
|
||||||
popd
|
|
|
@ -4,11 +4,11 @@ After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=ztncui
|
||||||
Group=root
|
Group=ztncui
|
||||||
Environment="PATH=__ENV_PATH__"
|
Environment="PATH=__PATH__"
|
||||||
WorkingDirectory=__FINALPATH__/src/
|
WorkingDirectory=__FINAL_PATH__/src/
|
||||||
ExecStart=/bin/bash __FINALPATH__/src/start.sh >> /var/log/__APP__/__APP__.log 2>&1
|
ExecStart=__NODEJS_PATH__/npm start
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -3,23 +3,21 @@
|
||||||
"id": "ztncui",
|
"id": "ztncui",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "A user interface for the ZeroTier network controller",
|
"en": "ZeroTier network controller user interface",
|
||||||
"fr": "Une interface utilisateur pour le contrôleur réseau ZeroTier"
|
"fr": "Interface utilisateur pour le contrôleur de réseau ZeroTier"
|
||||||
},
|
},
|
||||||
"version": "0.5.8~ynh1",
|
"version": "0.5.8~ynh1",
|
||||||
"url": "https://key-networks.com/ztncui",
|
"url": "https://key-networks.com/ztncui",
|
||||||
"license": "gpl",
|
"license": "GPL-3.0-only",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "tituspijean",
|
"name": "tituspijean",
|
||||||
"email": "tituspijean@outlook.com"
|
"email": "tituspijean@outlook.com"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.5"
|
"yunohost": ">= 3.7"
|
||||||
},
|
},
|
||||||
|
"services": [],
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
|
||||||
"zerotier-one"
|
|
||||||
],
|
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install": [
|
"install": [
|
||||||
{
|
{
|
||||||
|
@ -29,7 +27,11 @@
|
||||||
"en": "Choose a domain name for ztncui",
|
"en": "Choose a domain name for ztncui",
|
||||||
"fr": "Choisissez un nom de domaine pour ztncui"
|
"fr": "Choisissez un nom de domaine pour ztncui"
|
||||||
},
|
},
|
||||||
"example": "example.com"
|
"help": {
|
||||||
|
"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."
|
||||||
|
},
|
||||||
|
"example": "zt.example.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
|
@ -38,7 +40,33 @@
|
||||||
"en": "Is it a public application?",
|
"en": "Is it a public application?",
|
||||||
"fr": "Est-ce une application publique ?"
|
"fr": "Est-ce une application publique ?"
|
||||||
},
|
},
|
||||||
|
"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
|
"default": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"type": "user",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose an admin user",
|
||||||
|
"fr": "Choisissez l’administrateur"
|
||||||
|
},
|
||||||
|
"example": "johndoe"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "password",
|
||||||
|
"type": "password",
|
||||||
|
"ask": {
|
||||||
|
"en": "Set the administrator password",
|
||||||
|
"fr": "Définissez le mot de passe administrateur"
|
||||||
|
},
|
||||||
|
"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."
|
||||||
|
},
|
||||||
|
"example": "Choose a password"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
nodejs_version=10
|
nodejs_version=12
|
||||||
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="g++"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
@ -14,6 +17,21 @@ nodejs_version=10
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Execute a command as another user
|
||||||
|
# usage: exec_as USER COMMAND [ARG ...]
|
||||||
|
exec_as() {
|
||||||
|
local USER=$1
|
||||||
|
shift 1
|
||||||
|
|
||||||
|
if [[ $USER = $(whoami) ]]; then
|
||||||
|
eval "$@"
|
||||||
|
else
|
||||||
|
sudo PATH=$PATH -u "$USER" "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FUTURE OFFICIAL HELPERS
|
# FUTURE OFFICIAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -27,6 +27,8 @@ ynh_abort_if_errors
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/" #$YNH_APP_ARG_PATH
|
path_url="/" #$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
|
password=$YNH_APP_ARG_PASSWORD
|
||||||
|
|
||||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
@ -53,9 +55,12 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
|
### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
|
||||||
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
ynh_script_progression --message="Validating installation parameters..." --time --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 the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||||
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
||||||
final_path=/opt/key-networks/ztncui
|
final_path=/opt/yunohost/$app
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
|
@ -105,6 +110,8 @@ ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
|
|
||||||
|
@ -137,7 +144,7 @@ ynh_add_nginx_config
|
||||||
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create $app $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
|
@ -146,8 +153,13 @@ ynh_system_user_create --username=$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Performing Node app installation..." --time --weight=1
|
ynh_script_progression --message="Performing Node app installation..." --time --weight=1
|
||||||
|
|
||||||
|
chown -R $app: $final_path
|
||||||
|
|
||||||
pushd $final_path/src
|
pushd $final_path/src
|
||||||
npm install
|
exec_as $app $nodejs_path/npm --loglevel=error install node-gyp
|
||||||
|
exec_as $app $nodejs_path/npm --loglevel=error install
|
||||||
|
exec_as $app $nodejs_path/npm --loglevel=error install argon2-cli
|
||||||
|
exec_as $app $nodejs_path/npm --loglevel=error audit fix
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -158,15 +170,19 @@ popd
|
||||||
mkdir -p $final_path
|
mkdir -p $final_path
|
||||||
env_file=$final_path/src/.env
|
env_file=$final_path/src/.env
|
||||||
touch $env_file
|
touch $env_file
|
||||||
|
chmod 600 $env_file
|
||||||
|
|
||||||
echo "ZT_TOKEN=$(</var/lib/zerotier-one/authtoken.secret)" >> $env_file
|
echo "ZT_TOKEN=$(</var/lib/zerotier-one/authtoken.secret)" >> $env_file
|
||||||
|
echo "ZT_ADDR=localhost:$(</var/lib/zerotier-one/zerotier-one.port)" >> $env_file
|
||||||
echo "HTTP_PORT=$port" >> $env_file
|
echo "HTTP_PORT=$port" >> $env_file
|
||||||
|
|
||||||
cp ../conf/start.sh $final_path/src/
|
# Setup user credentials file
|
||||||
ynh_replace_string "__APP__" "$app" "$final_path/src/start.sh"
|
hashedpassword=$(echo -n "$password" | $final_path/src/node_modules/.bin/argon2-cli -e)
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/src/start.sh"
|
echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" >> "$final_path/src/etc/passwd"
|
||||||
|
|
||||||
cp $final_path/src/etc/default.passwd $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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LINK CERTIFICATES
|
# LINK CERTIFICATES
|
||||||
|
@ -175,8 +191,8 @@ cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd
|
||||||
# Even though one can stay in HTTP mode, the ztncui requires SSL certificates
|
# Even though one can stay in HTTP mode, the ztncui requires SSL certificates
|
||||||
# let's use the ones of the domain
|
# let's use the ones of the domain
|
||||||
pushd $final_path/src/etc/tls
|
pushd $final_path/src/etc/tls
|
||||||
ln -s /etc/yunohost/certs/$domain/key.pem privkey.pem
|
cp /etc/yunohost/certs/$domain/key.pem privkey.pem
|
||||||
ln -s /etc/yunohost/certs/$domain/crt.pem fullchain.pem
|
cp /etc/yunohost/certs/$domain/crt.pem fullchain.pem
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -195,10 +211,13 @@ ynh_script_progression --message="Configuring a systemd service..." --time --wei
|
||||||
### - As well as the section "RESTORE SYSTEMD" in the restore script
|
### - As well as the section "RESTORE SYSTEMD" in the restore script
|
||||||
### - And the section "SETUP SYSTEMD" in the upgrade script
|
### - And the section "SETUP SYSTEMD" in the upgrade script
|
||||||
|
|
||||||
|
# Set the systemd service settings
|
||||||
|
ynh_replace_string "__PATH__" "$PATH" "../conf/systemd.service"
|
||||||
|
ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service"
|
||||||
|
ynh_replace_string "__FINAL_PATH__" "$final_path" "../conf/systemd.service"
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
ynh_replace_string "__ENV_PATH__" "$PATH" "/etc/systemd/system/$app.service"
|
|
||||||
systemctl daemon-reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -270,13 +289,12 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
|
ynh_script_progression --message="Configuring SSOwat..."
|
||||||
|
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ $is_public -eq 1 ]
|
if [ $is_public -eq 1 ]
|
||||||
then
|
then
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
ynh_permission_update --permission "main" --add visitors
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -33,11 +33,21 @@ then
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STOP AND REMOVE SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated systemd config
|
||||||
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove metapackage and its dependencies
|
||||||
|
ynh_remove_app_dependencies
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -20,6 +20,9 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_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
|
# CHECK VERSION
|
||||||
|
@ -38,15 +41,6 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||||
|
|
||||||
# Fix is_public as a boolean value
|
|
||||||
if [ "$is_public" = "Yes" ]; then
|
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
|
||||||
is_public=1
|
|
||||||
elif [ "$is_public" = "No" ]; then
|
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
|
||||||
is_public=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If db_name doesn't exist, create it
|
# If db_name doesn't exist, create it
|
||||||
if [ -z "$db_name" ]; then
|
if [ -z "$db_name" ]; then
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
|
@ -119,7 +113,10 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
#ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
|
ynh_use_nodejs
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -127,7 +124,7 @@ ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create $app $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
@ -136,8 +133,41 @@ ynh_system_user_create --username=$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Performing Node app installation..." --time --weight=1
|
ynh_script_progression --message="Performing Node app installation..." --time --weight=1
|
||||||
|
|
||||||
|
chown -R $app: $final_path
|
||||||
|
|
||||||
pushd $final_path/src
|
pushd $final_path/src
|
||||||
npm install
|
exec_as $app $nodejs_path/npm --loglevel=error install node-gyp
|
||||||
|
exec_as $app $nodejs_path/npm --loglevel=error install
|
||||||
|
exec_as $app $nodejs_path/npm --loglevel=error install argon2-cli
|
||||||
|
exec_as $app $nodejs_path/npm --loglevel=error audit fix
|
||||||
|
popd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Setup env file
|
||||||
|
mkdir -p $final_path
|
||||||
|
env_file=$final_path/src/.env
|
||||||
|
touch $env_file
|
||||||
|
chmod 600 $env_file
|
||||||
|
|
||||||
|
echo "ZT_TOKEN=$(</var/lib/zerotier-one/authtoken.secret)" >> $env_file
|
||||||
|
echo "ZT_ADDR=localhost:$(</var/lib/zerotier-one/zerotier-one.port)" >> $env_file
|
||||||
|
echo "HTTP_PORT=$port" >> $env_file
|
||||||
|
|
||||||
|
# Setup user credentials file
|
||||||
|
echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" >> "$final_path/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
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -153,6 +183,11 @@ ynh_use_logrotate --non-append
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Set the systemd service settings
|
||||||
|
ynh_replace_string "__PATH__" "$PATH" "../conf/systemd.service"
|
||||||
|
ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service"
|
||||||
|
ynh_replace_string "__FINAL_PATH__" "$final_path" "../conf/systemd.service"
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
|
@ -163,7 +198,7 @@ ynh_add_systemd_config
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set permissions on app files
|
# Set permissions on app files
|
||||||
chown -R root: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
Loading…
Add table
Reference in a new issue