1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ztncui_ynh.git synced 2024-09-03 18:06:05 +02:00

[add] setting user and password

This commit is contained in:
tituspijean 2020-04-18 14:53:52 +02:00
parent 600ccede11
commit ea93407686
3 changed files with 87 additions and 51 deletions

View file

@ -19,7 +19,7 @@
"services": [],
"multi_instance": false,
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain",
@ -41,10 +41,32 @@
"fr": "Est-ce une application publique ?"
},
"help": {
"en": "It does not really matter, since ztncui has its own login system.",
"fr": "Cela n'a pas trop d'importance, puisque ztncui a son propre système de connection."
"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",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez ladministrateur"
},
"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"
}
]
}

View file

@ -27,6 +27,8 @@ ynh_abort_if_errors
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
### 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
@ -156,6 +158,7 @@ chown -R $app: $final_path
pushd $final_path/src
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 argon-cli
exec_as $app $nodejs_path/npm --loglevel=error audit fix
popd
@ -173,7 +176,13 @@ 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
cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd
# Setup user credentials file
hashedpassword=$(echo -n "$password" | 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
#=================================================
# LINK CERTIFICATES

View file

@ -21,6 +21,8 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
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
@ -136,6 +138,7 @@ chown -R $app: $final_path
pushd $final_path/src
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 argon-cli
exec_as $app $nodejs_path/npm --loglevel=error audit fix
popd
@ -153,7 +156,9 @@ 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
cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd
# Setup user credentials file
hashedpassword=$(echo -n "$password" | argon2-cli -e)
echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" >> "$final_path/src/etc/passwd"
#=================================================
# LINK CERTIFICATES