|
1 | | -import fs from "node:fs"; |
2 | | -import path from "node:path"; |
| 1 | +import fs from 'node:fs'; |
| 2 | +import path from 'node:path'; |
3 | 3 | import shell from 'shelljs'; |
4 | | -import inquirer from "inquirer"; |
5 | | -import { Sequelize, QueryTypes } from "sequelize"; |
6 | | -import wpHelper from "@/helpers/wp.helper.js"; |
7 | | -import { MySQLCredential } from "@/types/common.js"; |
| 4 | +import inquirer from 'inquirer'; |
| 5 | +import { Sequelize, QueryTypes } from 'sequelize'; |
| 6 | +import wpHelper from '@/helpers/wp.helper.js'; |
| 7 | +import { MySQLCredential } from '@/types/common.js'; |
8 | 8 |
|
9 | 9 | function random(length: number, { lower = true, upper = true, numeric = true, symbol = false } = {}) { |
10 | 10 | let mask = ''; |
@@ -56,30 +56,30 @@ async function configSetup(wpDir: string, domain: string, nickname: string, data |
56 | 56 | shell.cp(path.join(wpDir, 'wp-config-sample.php'), wpConfig); |
57 | 57 |
|
58 | 58 | // setup user for php runtime |
59 | | - if (shell.grep(nickname, "/etc/passwd").code !== 0) { |
| 59 | + if (shell.grep(nickname, '/etc/passwd').code !== 0) { |
60 | 60 | if (shell.exec(`adduser --system --no-create-home --group --disabled-login ${nickname}`).code !== 0) { |
61 | 61 | throw new Error(`Failed to create the user named ${nickname}`); |
62 | 62 | } |
63 | 63 | } |
64 | 64 |
|
65 | 65 | // setting wordpress config |
66 | | - shell.sed("-i", "put your unique phrase here", random(32, { symbol: true }), wpConfig); |
67 | | - shell.sed("-i", "database_name_here", wpDb, wpConfig); |
68 | | - shell.sed("-i", "username_here", nickname, wpConfig); |
69 | | - shell.sed("-i", "password_here", wpDbPassword, wpConfig); |
70 | | - shell.sed("-i", "localhost", port === 3306 ? host : `${host}:${port}`, wpConfig); |
| 66 | + shell.sed('-i', 'put your unique phrase here', random(32, { symbol: true }), wpConfig); |
| 67 | + shell.sed('-i', 'database_name_here', wpDb, wpConfig); |
| 68 | + shell.sed('-i', 'username_here', nickname, wpConfig); |
| 69 | + shell.sed('-i', 'password_here', wpDbPassword, wpConfig); |
| 70 | + shell.sed('-i', 'localhost', port === 3306 ? host : `${host}:${port}`, wpConfig); |
71 | 71 |
|
72 | 72 | const phpConfig = path.join(fpm, `pool.d/${domain}.conf`); |
73 | 73 | shell.cp(path.join(fpm, 'pool.d/www.conf'), phpConfig); |
74 | 74 |
|
75 | 75 | // setting host php config |
76 | | - shell.sed("-i", "[www]", `[${nickname}]`, phpConfig); |
77 | | - shell.sed("-i", "user = www-data", `user = ${nickname}`, phpConfig); |
78 | | - shell.sed("-i", "group = www-data", `group = ${nickname}`, phpConfig); |
79 | | - shell.sed("-i", `listen = /run/php/php${php}-fpm.sock`, `listen = /run/php/php${php}-fpm-$pool.sock`, phpConfig); |
80 | | - shell.sed("-i", `;slowlog = log/$pool.log.slow`, `slowlog = /var/log/php${php}-fpm-$pool.log.slow`, phpConfig); |
81 | | - shell.sed("-i", `;php_admin_value[error_log] = /var/log/fpm-php.www.log`, `php_admin_value[error_log] = /var/log/php${php}-fpm-$pool.log.error`, phpConfig); |
82 | | - shell.sed("-i", ";php_admin_flag[log_errors] = on", "php_admin_flag[log_errors] = on"); |
| 76 | + shell.sed('-i', '[www]', `[${nickname}]`, phpConfig); |
| 77 | + shell.sed('-i', 'user = www-data', `user = ${nickname}`, phpConfig); |
| 78 | + shell.sed('-i', 'group = www-data', `group = ${nickname}`, phpConfig); |
| 79 | + shell.sed('-i', `listen = /run/php/php${php}-fpm.sock`, `listen = /run/php/php${php}-fpm-$pool.sock`, phpConfig); |
| 80 | + shell.sed('-i', `;slowlog = log/$pool.log.slow`, `slowlog = /var/log/php${php}-fpm-$pool.log.slow`, phpConfig); |
| 81 | + shell.sed('-i', `;php_admin_value[error_log] = /var/log/fpm-php.www.log`, `php_admin_value[error_log] = /var/log/php${php}-fpm-$pool.log.error`, phpConfig); |
| 82 | + shell.sed('-i', ';php_admin_flag[log_errors] = on', 'php_admin_flag[log_errors] = on'); |
83 | 83 |
|
84 | 84 | shell.touch(`/var/log/php${php}-fpm-${nickname}.log.error`); |
85 | 85 | shell.exec(`chown ${nickname}:${nickname} /var/log/php${php}-fpm-${nickname}.log.error`); |
|
0 commit comments