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

Use ynh_add_config for env file

This commit is contained in:
tituspijean 2022-01-15 16:51:36 +01:00
parent a7899d32a3
commit 51023e7df5
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720
2 changed files with 10 additions and 9 deletions

3
conf/env Normal file
View file

@ -0,0 +1,3 @@
ZT_TOKEN=__ZT_TOKEN__
ZT_ADDR=__ZT_ADDR__
HTTP_PORT=__PORT__

View file

@ -120,19 +120,17 @@ 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
# 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)"
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
ynh_add_config --template="env" --destination="$final_path/.env"
chown $app:$app "$final_path/.env"
chmod 600 "$final_path/.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"
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