0

Sorry for the noob question, but I just can't figure it out.

I'm used to working with Virtualmin and setting up new site-accounts is as easy as "Create Virtual Server."

Where can I do this in Cockpit? My setup is Nginx and CentOS 8, if that matters.

I can find ZERO information about this on Google or on SF, so posting this while realizing I'm probably not asking the right question.

Thank you.

Trace DeCoy
  • 153
  • 1
  • 6
  • 1
    I have never heard of Cockpit having any such functionality, and indeed, it is not something we would want anyway. – Michael Hampton Nov 03 '20 at 20:47
  • Thanks @MichaelHampton - that's helpful. – Trace DeCoy Nov 04 '20 at 07:04
  • Well you can create a [Cockpit Package](https://cockpit-project.org/guide/222.1/packages.html) under `/usr/share/cockpit/nginx` for example. @MichaelHampton Why wouldn't we want it exactly? – OpSocket Nov 28 '20 at 04:05

1 Answers1

0

Take a look at Cockpit.js.

Given you've included <script src="../base1/cockpit.js"></script> somewhere inside your package's index.html, a cockpit object will be available inside your package's index.js.

There might be better solutions for sure, but something along the lines of this should work:

let myvhost = `server {
   // ... server block configuration ...
}`

cockpit.spawn([ "sudo", "echo", myvhost, ">", "/etc/nginx/conf.d/myvhost.conf" ]).then(data => {
  console.log("vhost created")
})

You should also check if nginx is installed so that when you install your package, it is only visible if nginx is available. And don't forget to reload nginx in order to activate your new server block configuration.

Another way would be to use Cockpit.js: File Access API

There are some examples in the cockpit repo

OpSocket
  • 101
  • 1