mirror of
https://github.com/YunoHost-Apps/lstu_ynh.git
synced 2024-09-03 19:36:12 +02:00
add admin
This commit is contained in:
parent
910740418c
commit
7987a544c4
4 changed files with 28 additions and 1 deletions
|
@ -29,7 +29,7 @@
|
|||
# secret hashed passphrase to access some admin features
|
||||
# Hash your password by issuing `echo -n s3cr3T | sha256sum` on your terminal
|
||||
# optional, but you won't have access to admin /stats if not set and if adminpwd is not set either
|
||||
#hashed_adminpwd => '94b2feede6ea5e2eec62f457ecb7d3f719b24d19c29d4e5466246a31908fc23b',
|
||||
hashed_adminpwd => '__PASSWORD_HASHED__',
|
||||
|
||||
# choose a theme. See the available themes in `themes` directory
|
||||
# optional, default is 'default'
|
||||
|
|
|
@ -49,6 +49,14 @@
|
|||
"fr": "Est-ce une application publique ?"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password",
|
||||
"ask": {
|
||||
"en": "Choose a password",
|
||||
"fr": "Choisissez un mot de passe"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ ynh_abort_if_errors
|
|||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -67,6 +68,8 @@ ynh_app_setting_set $app domain $domain
|
|||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_set $app port $port
|
||||
ynh_app_setting_set $app path $path_url
|
||||
hashed_password=$(echo $password | sha256sum $password)
|
||||
ynh_app_setting_set $app hashed_password $hashed_password
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
|
@ -122,6 +125,7 @@ ynh_replace_string "__PORT__" "$port" "${final_path}/lstu.conf"
|
|||
ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__PASSWORD_HASHED__" "$hashed_password" "${final_path}/lstu.conf"
|
||||
|
||||
secret=$(ynh_string_random 24)
|
||||
ynh_app_setting_set $app secret $secret
|
||||
|
|
|
@ -35,6 +35,7 @@ secret=$(ynh_app_setting_get $app secret)
|
|||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get $app psqlpwd)
|
||||
hashed_password=$(ynh_app_setting_get $app hashed_password)
|
||||
|
||||
#=================================================
|
||||
# FIX OLD THINGS
|
||||
|
@ -68,6 +69,19 @@ if [ -z "$db_pwd" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$hashed_password" ]; then
|
||||
# Generate random password
|
||||
password=$(openssl rand -hex 15)
|
||||
hashed_password=$(echo $password | sha256sum $password)
|
||||
ynh_app_setting_set $app hashed_password $hashed_password
|
||||
|
||||
echo "The new version of LSTU provide an admin and a stats area which required a password.
|
||||
|
||||
This password is: $password" > mail_to_send
|
||||
|
||||
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="admin" --type="upgrade"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -97,6 +111,7 @@ ynh_replace_string "__PORT__" "$port" "${final_path}/lstu.conf"
|
|||
ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__PASSWORD_HASHED__" "$hashed_password" "${final_path}/lstu.conf"
|
||||
|
||||
ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf"
|
||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
||||
|
|
Loading…
Add table
Reference in a new issue