From 71a5dd8b45b1e421eab90a79bb790f8048e660a0 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 24 Aug 2023 15:30:41 +1000 Subject: [PATCH] docs: Cleaned up the readme and master install --- README.md | 37 ++++++++++++++++++++++++++++++------- master/install.sh | 46 +--------------------------------------------- 2 files changed, 31 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 8f46255..e00aad3 100644 --- a/README.md +++ b/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 | 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 | Creates a wordpress site on a random worker server (uses up 1 licence key) +/siteinfo | 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= -e DISCORD_TOKEN= -e LICENCE_KEY=your-api-key -e WORKER_KEY=your-api-key --name hnshosting-bot git.woodburn.au/nathanwoodburn/hnshosting-bot:latest ``` \ No newline at end of file diff --git a/master/install.sh b/master/install.sh index 16a289a..e7811f0 100644 --- a/master/install.sh +++ b/master/install.sh @@ -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 \ No newline at end of file