Monorepo for Aesthetic.Computer
aesthetic.computer
1#!/usr/bin/env node
2/**
3 * cPanel automation helpers for thomaslawson.com
4 */
5
6import { PageController, listPages } from "../browser.mjs";
7
8const CPANEL_HOST = "p3plzcpnl502855.prod.phx3.secureserver.net:2083";
9
10export async function getCPanelPage() {
11 const pages = await listPages();
12 const cpanelPage = pages.find(p => p.url.includes(CPANEL_HOST));
13 if (!cpanelPage) throw new Error("No cPanel page found - open it in Chrome first");
14 return PageController.connect(CPANEL_HOST);
15}
16
17export async function gotoSSLStatus(ctrl) {
18 await ctrl.goto(`https://${CPANEL_HOST}/frontend/jupiter/ssl/ssl_tls_status.html`);
19 return ctrl;
20}
21
22export async function gotoSSLInstall(ctrl) {
23 await ctrl.goto(`https://${CPANEL_HOST}/frontend/jupiter/ssl/install.html`);
24 return ctrl;
25}
26
27export async function installSSL(certData, keyData, cabundleData) {
28 const ctrl = await getCPanelPage();
29 await gotoSSLInstall(ctrl);
30 await ctrl.wait(2000);
31
32 // Fill in the certificate
33 await ctrl.fill("textarea[name=\"crt\"]", certData);
34 await ctrl.fill("textarea[name=\"key\"]", keyData);
35 if (cabundleData) {
36 await ctrl.fill("textarea[name=\"cabundle\"]", cabundleData);
37 }
38
39 console.log("SSL cert data filled - review and submit manually");
40 return ctrl;
41}
42
43if (import.meta.url === `file://${process.argv[1]}`) {
44 const cmd = process.argv[2];
45
46 if (cmd === "status") {
47 const ctrl = await getCPanelPage();
48 await gotoSSLStatus(ctrl);
49 console.log("Navigated to SSL status page");
50 await ctrl.close();
51 } else if (cmd === "install") {
52 const ctrl = await getCPanelPage();
53 await gotoSSLInstall(ctrl);
54 console.log("Navigated to SSL install page");
55 await ctrl.close();
56 } else if (cmd === "content") {
57 const ctrl = await getCPanelPage();
58 console.log(await ctrl.getContent());
59 await ctrl.close();
60 } else {
61 console.log("Usage: node cpanel.mjs status|install|content");
62 }
63}