feat(yeswiki-installer) : nossl option
This commit is contained in:
parent
2b76cdc7e6
commit
792e4489ff
3 changed files with 99 additions and 32 deletions
|
@ -163,7 +163,7 @@ function removeUnixUser($user)
|
|||
return;
|
||||
}
|
||||
|
||||
function createNginxConfig($domain, $user, $herseUser, $hersePass)
|
||||
function createNginxConfig($domain, $user, $herseUser, $hersePass, $nossl)
|
||||
{
|
||||
// create folder if not exists
|
||||
exec('sudo -u '.$user.' mkdir -p /home'.'/'.$user.'/'.$domain);
|
||||
|
@ -182,40 +182,56 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass)
|
|||
}
|
||||
$templates = new League\Plates\Engine(dirname(__FILE__).'/templates');
|
||||
$subDomain = preg_match('/.'.$_SERVER['maindomain'].'$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0);
|
||||
if (!$subDomain) {
|
||||
if (!$nossl) {
|
||||
if (!$subDomain) {
|
||||
file_put_contents(
|
||||
$nginxFile,
|
||||
$templates->render(
|
||||
'nginx-for-ssl-certificate',
|
||||
[
|
||||
'domain' => $domain,
|
||||
'user' => $user,
|
||||
]
|
||||
)
|
||||
);
|
||||
exec('service nginx force-reload', $output);
|
||||
exec('/root/.acme.sh/acme.sh --issue -d '.$domain.' -d www.'.$domain.' -k ec-384 -w /home/'.$user.'/'.$domain.'/', $output);
|
||||
exec('mkdir -p /etc/letsencrypt/live/'.$domain, $output);
|
||||
exec('/root/.acme.sh/acme.sh --install-cert -d '.$domain.' --ecc \
|
||||
--cert-file /etc/letsencrypt/live/'.$domain.'/cert.pem \
|
||||
--key-file /etc/letsencrypt/live/'.$domain.'/key.pem \
|
||||
--fullchain-file /etc/letsencrypt/live/'.$domain.'/fullchain.pem \
|
||||
--ca-file /etc/letsencrypt/live/'.$domain.'/ca.pem \
|
||||
--reloadcmd "systemctl restart nginx.service"', $output);
|
||||
}
|
||||
file_put_contents(
|
||||
$nginxFile,
|
||||
$templates->render(
|
||||
'nginx-for-ssl-certificate',
|
||||
'nginx-maindomain',
|
||||
[
|
||||
'domain' => $domain,
|
||||
'user' => $user,
|
||||
'herseUser' => $herseUser,
|
||||
'hersePass' => $hersePass,
|
||||
'subDomain' => $subDomain,
|
||||
]
|
||||
)
|
||||
);
|
||||
} else {
|
||||
file_put_contents(
|
||||
$nginxFile,
|
||||
$templates->render(
|
||||
'nginx-nossl',
|
||||
[
|
||||
'domain' => $domain,
|
||||
'user' => $user,
|
||||
'herseUser' => $herseUser,
|
||||
'hersePass' => $hersePass,
|
||||
'subDomain' => $subDomain,
|
||||
]
|
||||
)
|
||||
);
|
||||
exec('service nginx force-reload', $output);
|
||||
exec('/root/.acme.sh/acme.sh --issue -d '.$domain.' -d www.'.$domain.' -k ec-384 -w /home/'.$user.'/'.$domain.'/', $output);
|
||||
exec('mkdir -p /etc/letsencrypt/live/'.$domain, $output);
|
||||
exec('/root/.acme.sh/acme.sh --install-cert -d '.$domain.' --ecc \
|
||||
--cert-file /etc/letsencrypt/live/'.$domain.'/cert.pem \
|
||||
--key-file /etc/letsencrypt/live/'.$domain.'/key.pem \
|
||||
--fullchain-file /etc/letsencrypt/live/'.$domain.'/fullchain.pem \
|
||||
--ca-file /etc/letsencrypt/live/'.$domain.'/ca.pem \
|
||||
--reloadcmd "systemctl restart nginx.service"', $output);
|
||||
}
|
||||
file_put_contents(
|
||||
$nginxFile,
|
||||
$templates->render(
|
||||
'nginx-maindomain',
|
||||
[
|
||||
'domain' => $domain,
|
||||
'user' => $user,
|
||||
'herseUser' => $herseUser,
|
||||
'hersePass' => $hersePass,
|
||||
'subDomain' => $subDomain,
|
||||
]
|
||||
)
|
||||
);
|
||||
exec('service nginx force-reload', $output);
|
||||
}
|
||||
|
||||
|
@ -243,7 +259,7 @@ function removePhpFpmConfig($user)
|
|||
exec('service '.$_SERVER['phpservice'].' reload', $output);
|
||||
}
|
||||
|
||||
function copyYesWikiFiles($domain, $user, $dbUser, $herseUser = null, $hersePass = null)
|
||||
function copyYesWikiFiles($domain, $user, $dbUser, $herseUser = null, $hersePass = null, $nossl = null)
|
||||
{
|
||||
$tmpFile = '/tmp/yeswiki.zip';
|
||||
$destDir = '/home'.'/'.$user.'/'.$domain;
|
||||
|
@ -262,7 +278,7 @@ function copyYesWikiFiles($domain, $user, $dbUser, $herseUser = null, $hersePass
|
|||
if (!empty($herseUser) && !empty($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\' \'http'.($nossl ? '' : 's').'://'.$herse.$domain.'/?PagePrincipale&installAction=install\' 2>&1';
|
||||
$output = [];
|
||||
exec($curl, $output);
|
||||
//echo implode("\n", $output);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue