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

Simplify the admin password mess, it looks like at no point it is explained that the password is autogenerated and should be found in the app setting, and anyway there's no reason to not ask for the admin to chose one during the app install ...

This commit is contained in:
Alexandre Aubin 2023-12-04 22:43:13 +01:00
parent 7c41c6b6c1
commit d81a1af619
4 changed files with 10 additions and 50 deletions

View file

@ -1,9 +0,0 @@
<?php
define('PHPWG_ROOT_PATH','./');
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
print $conf['password_hash']($argv[1]);
?>

View file

@ -48,6 +48,9 @@ ram.runtime = "50M"
[install.admin]
type = "user"
[install.password]
type = "password"
[resources]
[resources.sources]
[resources.sources.ldap_plugin]

View file

@ -74,9 +74,6 @@ ynh_script_progression --message="Setuping application with CURL..." --weight=5
ynh_systemd_action --service_name=nginx --action=reload
# Generate random password for admin
adm_pwd=$(ynh_string_random --length=24)
ynh_app_setting_set --app=$app --key=admin_pwd --value="$adm_pwd"
if [ "$language" = "fr" ]; then
applanguage="fr_FR"
else
@ -87,7 +84,7 @@ fi
mail="$(ynh_user_get_info --username=$admin --key=mail)"
# Installation with cURL
ynh_local_curl "/install.php?language=$applanguage" "install=true" "dbhost=127.0.0.1" "dbuser=$db_user" "dbpasswd=$db_pwd" "dbname=$db_name" "prefix=" "admin_name=$admin" "admin_pass1=$adm_pwd" "admin_pass2=$adm_pwd" "admin_mail=$mail"
ynh_local_curl "/install.php?language=$applanguage" "install=true" "dbhost=127.0.0.1" "dbuser=$db_user" "dbpasswd=$db_pwd" "dbname=$db_name" "prefix=" "admin_name=$admin" "admin_pass1=$password" "admin_pass2=$password" "admin_mail=$mail"
#=================================================
# CONFIGURE PIWIGO
@ -112,7 +109,7 @@ ynh_script_progression --message="Configuring LDAP plugin..."
# Activate the LDAP plugin using the WS API
# Login with admin account
ynh_local_curl "/ws.php?format=json" "method=pwg.session.login" "username=$admin" "password=$adm_pwd"
ynh_local_curl "/ws.php?format=json" "method=pwg.session.login" "username=$admin" "password=$password"
# Get session token
status=$(ynh_local_curl "/ws.php?format=json" "method=pwg.session.getStatus")
pwg_token=$(jq --raw-output .result.pwg_token <<< $status)

View file

@ -15,40 +15,6 @@ source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then
fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
# If fpm_free_footprint doesn't exist, create it
if [ -z "$fpm_free_footprint" ]; then
fpm_free_footprint=0
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
fi
# If fpm_usage doesn't exist, create it
if [ -z "$fpm_usage" ]; then
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
# Compatibility with previous version; password was not set
if [ -z "$admin_pwd" ] ; then
# Generate a new password
admin_pwd=$(ynh_string_random --length=24)
# Compute password hash with the Piwigo function
cp ../conf/hash_password.php $install_dir
hashed_password=$(cd $install_dir ; php hash_password.php $admin_pwd)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -127,7 +93,8 @@ else
fi
# Upgrade Piwigo via cURL
ynh_local_curl "/upgrade.php?language=$applanguage&now=true" "language=$applanguage" "username=$admin" "password=$admin_pwd"
# FIXME : Why Curl ... Why can't we trigger the migration from the command line somehow ...
#ynh_local_curl "/upgrade.php?language=$applanguage&now=true" "language=$applanguage" "username=$admin" "password=$admin_pwd"
#=================================================
# CONFIGURE PIWIGO
@ -155,7 +122,9 @@ ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<<
# Activate the LDAP plugin using the WS API
# Login with admin account
ynh_local_curl "/ws.php?format=json" "method=pwg.session.login" "username=$admin" "password=$admin_pwd"
# FIXME: Is this stuff really needed ... isn't there a way to enable the damn LDAP login plugin from the command line or something ...
#ynh_local_curl "/ws.php?format=json" "method=pwg.session.login" "username=$admin" "password=$admin_pwd"
# Get session token
status=$(ynh_local_curl "/ws.php?format=json" "method=pwg.session.getStatus")
pwg_token=$(jq --raw-output .result.pwg_token <<< $status)