UserVM Handbook: Difference between revisions

no edit summary
No edit summary
 
== Compiling the server<br> ==
=== Install GitDependencies ===
First up make sure you have git installed:
{{code|lang=bash|
$ sudo pacman -S --needed git # Arch
$ sudo apt-get install -y git # Debian
}}
Next, we need to install Node.js, as well as the server dependencies.
=== Prepare the server ===
Now let's clone the source. It's recommended that you do this somewhere like /srv/collabvm or /home/collabvm. For the purposes of this guide we'll use the former.
{{code|
sudo mkdir -p /srv/collabvm
sudo chown -R $USER /srv/collabvm # Temporary, we'll change this to a dedicated CollabVM user later
git clone https://github.com/computernewb/collabvm-1.2.ts.git /srv/collabvm/collabvm-1.2.ts
cd /srv/collabvm/collabvm-1.2.ts
}}
Next, we need to install Node.js, as well as the server dependencies.
First, we'll install node. On arch, you can just run the following command:
{{code|
$ sudo pacman --needed -S npm nodejs
}}
On Debian, the packaged node version is too old to run CollabVM, so we'll add the nodesource repository.
{{code|<nowiki>
$ sudo apt-get install -y curl
$ curl -fsSL https://deb.nodesource.com/setup_21.x | sudo bash -
$ sudo apt-get install nodejs -y
</nowiki>}}
=== Prepare the server ===
Now let's get the server ready. First, we'll create a dedicated CollabVM user to run the server from <code>/srv/collabvm</code>:
{{code|
$ sudo mkdiruseradd -prmd /srv/collabvm collabvm
$ sudo usermod -aG kvm collabvm # Give the CollabVM user permission to use KVM hypervision
}}
Now, we can shell in as the CollabVM user. For the remainder of this guide, any line that starts with <code>(collabvm) $</code> indicates that this should be run as the <code>collabvm</code> user.
{{code|
$ sudo -iu collabvm
(collabvm) $ pwd # This should output /srv/collabvm
}}
Now, we can clone the CollabVM Server source code:
{{code|
(collabvm) $ git clone https://github.com/computernewb/collabvm-1.2.ts.git /srv/collabvm/collabvm-1.2.ts
(collabvm) $ cd /srv/collabvm/collabvm-1.2.ts
}}
 
Then install dependencies
{{code|
(collabvm) $ npm i
}}
Finally, build the server
{{code|
(collabvm) $ npm run build
}}
 
*Some games
*Some harmless malware (for the love of god no GDI rapists)
 
We recommend setting up your VM as the collabvm user to make sure permissions are set correctly, but this is not a requirement.
== Setting up a Virtual Network ==
QEMU's user-mode networking used by default isn't very customizable and lacks the ability to block certain abuse vectors. For this reason we very strongly recommend setting up a Virtual Network using the [[CollabNet Guide]]. Depending on the full situation we may refuse to add VMs that use QEMU user-mode networking.
First, you'll want to save [https://computernewb.com/~elijah/wsproxy_params wsproxy_params] to your Nginx directory, which enables WebSocket proxying. Here's a one-liner to do that:
{{code|
$ sudo curl https://computernewb.com/~elijah/wsproxy_params -o /etc/nginx/wsproxy_params
}}
Next, you can add the following to your Nginx server block:
{{code|
location /collab-vm/vm1 {
include wsproxy_params;
proxy_pass http://127.0.0.1:6004/; # Replace 6004 if you changed the HTTP port in the config file.
Now that everything is set up, you can bring your VM online. To run the server right from your terminal, run the following command:
{{code|
(collabvm) $ npm run serve
}}
Or alternatively, to run it directly:
{{code|
(collabvm) $ node build/index.js
}}
=== Setting up a service ===
While it's useful and convenient to run your VM from the console while debugging, we <b>strongly</b> recommend you set it up as a service once you're ready to leave it on for extended periods of time. This is done differently depending on what init system your distro uses (Probably systemd, if you're not sure)
 
First, we highly recommend you create a separate user for CollabVM, to maximize security
{{code|
sudo useradd -rM -d /srv/collabvm collabvm
sudo chown -R collabvm:collabvm /srv/collabvm/ # Set the collabvm user as the owner of the server files
sudo usermod -aG kvm collabvm # Give the CollabVM user permission to use KVM hypervision
}}
 
==== Systemd ====
To make your VM a systemd service, you can put the following into <code>/etc/systemd/system/collabvm.service</code> (Change the filename accordingly)
 
{{code|<nowiki>
Reload the daemon cache:
{{code|
$ sudo systemctl daemon-reload
}}
Then you can start your VM with:
{{code|
$ sudo systemctl start collabvm
}}
And make it automatically run on startup with:
{{code|
$ sudo systemctl enable collabvm
}}
 
Make it executable:
{{code|
$ sudo chmod +x /etc/init.d/collabvm
}}
Now you can start your VM with:
{{code|
$ sudo rc-service collabvm start
}}
And make it run on startup with:
{{code|
$ sudo rc-update add collabvm
}}
== Running a local webapp ==
Before you put your VM on the UserVM roster, you'll probably want to test it out for yourself. For that, we'll throw up a test webapp. Start by cloning the source:
{{code|
$ git clone https://github.com/computernewb/collab-vm-1.2-webapp.git
$ cd collab-vm-1.2-webapp
}}
Then, editcopy src<code>config.example.json</commoncode> to <code>config.jsjson</code>, and replace serverAddressesServerAddresses with your server address:
{{code|
serverAddresses"ServerAddresses": [
"ws://127.0.0.1:6004", # If you're not using proxying
"wss://yoursiteexample.xyzcom/collab-vm/vm1", # If you are using proxying. Remove one of these lines.
],
}}
Now you can build the webapp, and serve it:
{{code|
$ npm run build
$ npm run serve
}}
This will run the webapp at <code>127.0.0.1:30001234</code>, which you can navigate to in your browser. If all went well, your VM should show up. If not, and you don't know why, join our discord and ask for help there!
== Permanently host the webapp ==
If you want to host the webapp on your website, you can build it as follows:
{{code|
$ npm run build
}}
Then, copy the contents of the <code>dist</code> directory to your website. For example, if your webroot is at <code>/var/www/example.com</code>, and you want your webapp at example.com/collab-vm/:
{{code|
$ cp -r dist/. /var/www/example.com/collab-vm/
}}
The webapp should now be accessible at your website.
This will run the webapp at <code>127.0.0.1:3000</code>, which you can navigate to in your browser. If all went well, your VM should show up. If not, and you don't know why, join our discord and ask for help there!
=== Logging in as an admin (or mod) ===
Logging in is very simple. Just join the VM, and double click your username. Enter your admin or mod password into the prompt, and you should be authenticated and able to use staff actions.