docs: Cleaned up the readme and master install
This commit is contained in:
parent
3a9f8a8844
commit
71a5dd8b45
37
README.md
37
README.md
@ -13,24 +13,41 @@ The bot will be used to provide an easier way to manage the master server.
|
||||
|
||||
## Usage
|
||||
|
||||
!TODO
|
||||
After installing the master and discord bot you can use the following commands (as bot owner).
|
||||
|
||||
```
|
||||
/addworker <ip> <name> | add a worker to the master server pool (Make sure the master can access port 5000 on the worker, and don't allow anyone else to access it)
|
||||
/listworkers | list all workers
|
||||
/licence | Creates a licence key (valid for 1 wp site)
|
||||
```
|
||||
|
||||
General commands (as anyone)
|
||||
|
||||
```
|
||||
/createsite <domain> <licence key> | Creates a wordpress site on a random worker server (uses up 1 licence key)
|
||||
/siteinfo <domain> | Get info about a site (use after creating site to get TLSA and IP of the server)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Master server install
|
||||
|
||||
Docker is the easiest way to install the master server.
|
||||
|
||||
```
|
||||
```sh
|
||||
docker run -d -p 5000:5000 -e LICENCE-API=your-api-key -e WORKER_KEY=your-api-key --name hnshosting-master git.woodburn.au/nathanwoodburn/hnshosting-master:latest -v ./data:/data
|
||||
```
|
||||
You can also mount a docker volume to /data to store the files instead of mounting a host directory.
|
||||
|
||||
Alternatively you can install it manually.
|
||||
Set your .env file.
|
||||
```
|
||||
```sh
|
||||
cd master
|
||||
python3 -m pip install -r requirements.txt
|
||||
python3 main.py
|
||||
```
|
||||
Then to start the master api server
|
||||
```sh
|
||||
screen -dmS hnshosting-master python3 main.py
|
||||
```
|
||||
|
||||
|
||||
@ -38,20 +55,26 @@ python3 main.py
|
||||
|
||||
Install prerequisites:
|
||||
|
||||
```
|
||||
```sh
|
||||
git clone https://git.woodburn.au/nathanwoodburn/hnshosting-wp.git
|
||||
cd hnshosting-wp/worker
|
||||
chmod +x install.sh
|
||||
./install.sh
|
||||
```
|
||||
Then to start the worker api server
|
||||
```sh
|
||||
screen -dmS hnshosting-worker python3 main.py
|
||||
```
|
||||
|
||||
Add worker to master server:
|
||||
|
||||
```
|
||||
```sh
|
||||
curl -X POST http://master-server-ip:5000/add-worker?worker=worker-name&ip=worker-server-ip -H "key: api-key"
|
||||
```
|
||||
|
||||
## Discord bot install
|
||||
|
||||
Docker install
|
||||
```
|
||||
```sh
|
||||
docker run -d -e MASTER_IP=<MASTER SERVER IP> -e DISCORD_TOKEN=<YOUR-BOT-TOKEN> -e LICENCE_KEY=your-api-key -e WORKER_KEY=your-api-key --name hnshosting-bot git.woodburn.au/nathanwoodburn/hnshosting-bot:latest
|
||||
```
|
@ -1,49 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Initial install for all prerequisites for the project.
|
||||
|
||||
# Update the system
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
# Install python prerequisites
|
||||
python3 -m pip install -r requirements.txt
|
||||
|
||||
# Create a service to run the python web server
|
||||
|
||||
# Flask app directory and file
|
||||
APP_DIR=$(pwd)
|
||||
APP_FILE=main.py
|
||||
|
||||
# Name for your systemd service
|
||||
SERVICE_NAME=HNSHosting-Main
|
||||
|
||||
# Create a user and group to run the service
|
||||
|
||||
SERVICE_USER=hnshosting
|
||||
SERVICE_GROUP=hnshosting
|
||||
|
||||
sudo groupadd $SERVICE_GROUP
|
||||
sudo useradd -g $SERVICE_GROUP $SERVICE_USER
|
||||
|
||||
# Create a systemd service unit file
|
||||
echo "[Unit]
|
||||
Description=HNSHosting Main Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=$SERVICE_USER
|
||||
Group=$SERVICE_GROUP
|
||||
WorkingDirectory=$APP_DIR
|
||||
ExecStart=/usr/bin/python3 $APP_DIR/$APP_FILE
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/$SERVICE_NAME.service
|
||||
|
||||
# Reload systemd to pick up the new unit file
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# Enable and start the service
|
||||
sudo systemctl enable $SERVICE_NAME
|
||||
sudo systemctl start $SERVICE_NAME
|
||||
|
||||
echo "Service created and started."
|
||||
python3 -m pip install -r requirements.txt
|
Loading…
Reference in New Issue
Block a user