fix(install) : good order of creation

This commit is contained in:
mrflos 2023-02-03 22:15:42 +03:00
parent 5768569a2a
commit c8b6f72be4
2 changed files with 4 additions and 3 deletions

View file

@ -150,6 +150,7 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass)
throw new Exception('You need an username AND a password to add a herse.'); throw new Exception('You need an username AND a password to add a herse.');
} else { } else {
// add password file to domain // add password file to domain
exec('mkdir -p /home'.'/'.$user.'/'.$domain);
file_put_contents( file_put_contents(
'/home'.'/'.$user.'/'.$domain.'/.htpasswd', '/home'.'/'.$user.'/'.$domain.'/.htpasswd',
$herseUser.':'.password_hash($hersePass, PASSWORD_BCRYPT) $herseUser.':'.password_hash($hersePass, PASSWORD_BCRYPT)
@ -233,7 +234,7 @@ function copyYesWikiFiles($domain, $user, $dbUser, $herseUser = null, $hersePass
unlink($tmpFile); unlink($tmpFile);
$herse = ''; $herse = '';
if (!empty($herseUser) && !empty($hersePass)) { if (!empty($herseUser) && !empty($hersePass)) {
$herse = $herseUser.':'.$hersePass; $herse = $herseUser.':'.$hersePass.'@';
} }
$curl = 'curl -X POST --insecure --data-urlencode \'config[default_language]=fr\' --data-urlencode \'config[wakka_name]='.$domain.'\' --data-urlencode \'config[root_page]=PagePrincipale\' --data-urlencode \'config[mysql_host]=localhost\' --data-urlencode \'config[mysql_database]='.$dbUser['database'].'\' --data-urlencode \'config[mysql_user]='.$dbUser['user'].'\' --data-urlencode \'config[mysql_password]='.$dbUser['password'].'\' --data-urlencode \'config[table_prefix]=yeswiki_\' --data-urlencode \'admin_name='.$_SERVER['admin_id'].'\' --data-urlencode \'admin_password='.$_SERVER['admin_password'].'\' --data-urlencode \'admin_password_conf='.$_SERVER['admin_password'].'\' --data-urlencode \'admin_email='.$_SERVER['admin_email'].'\' --data-urlencode \'config[rewrite_mode]=0\' --data-urlencode \'config[allow_raw_html]=1\' --data-urlencode \'config[allow_robots]=1\' --data-urlencode \'submit=Continue\' \'https://'.$herse.$domain.'/?PagePrincipale&installAction=install\' 2>&1'; $curl = 'curl -X POST --insecure --data-urlencode \'config[default_language]=fr\' --data-urlencode \'config[wakka_name]='.$domain.'\' --data-urlencode \'config[root_page]=PagePrincipale\' --data-urlencode \'config[mysql_host]=localhost\' --data-urlencode \'config[mysql_database]='.$dbUser['database'].'\' --data-urlencode \'config[mysql_user]='.$dbUser['user'].'\' --data-urlencode \'config[mysql_password]='.$dbUser['password'].'\' --data-urlencode \'config[table_prefix]=yeswiki_\' --data-urlencode \'admin_name='.$_SERVER['admin_id'].'\' --data-urlencode \'admin_password='.$_SERVER['admin_password'].'\' --data-urlencode \'admin_password_conf='.$_SERVER['admin_password'].'\' --data-urlencode \'admin_email='.$_SERVER['admin_email'].'\' --data-urlencode \'config[rewrite_mode]=0\' --data-urlencode \'config[allow_raw_html]=1\' --data-urlencode \'config[allow_robots]=1\' --data-urlencode \'submit=Continue\' \'https://'.$herse.$domain.'/?PagePrincipale&installAction=install\' 2>&1';
$output = []; $output = [];

View file

@ -76,13 +76,13 @@ if (0 == posix_getuid()) {
if ($confirm || $input->confirmed()) { if ($confirm || $input->confirmed()) {
$unixUser = createUnixUserWithQuota($user, $quota); $unixUser = createUnixUserWithQuota($user, $quota);
$dbUser = createSQLUserAndDatabase($user, $type); $dbUser = createSQLUserAndDatabase($user, $type);
createNginxConfig($domain, $user, $herseUser, $hersePass);
createPhpFpmConfig($user);
if ($needHerse) { if ($needHerse) {
copyYesWikiFiles($domain, $user, $dbUser, $herseUser, $hersePass); copyYesWikiFiles($domain, $user, $dbUser, $herseUser, $hersePass);
} else { } else {
copyYesWikiFiles($domain, $user, $dbUser); copyYesWikiFiles($domain, $user, $dbUser);
} }
createNginxConfig($domain, $user, $herseUser, $hersePass);
createPhpFpmConfig($user);
$climate->shout( $climate->shout(
'The yeswiki was successfully installed on <bold>'.$domain.'</bold>, congrats ! 🎉'."\n" 'The yeswiki was successfully installed on <bold>'.$domain.'</bold>, congrats ! 🎉'."\n"
.' Unix user : <bold>'.$unixUser['user'].'</bold> with password : <bold>'.$unixUser['password'].'</bold> was created.'."\n" .' Unix user : <bold>'.$unixUser['user'].'</bold> with password : <bold>'.$unixUser['password'].'</bold> was created.'."\n"