2023-08-31 11:13:54 +04:00
|
|
|
# Self-Hosting
|
|
|
|
|
2023-09-01 16:43:15 +04:00
|
|
|
If you prefer hosting with Docker, see [Docker](docker.md) instead.
|
2023-08-31 11:13:54 +04:00
|
|
|
|
2023-09-01 16:43:15 +04:00
|
|
|
## Install nodejs and npm
|
2023-08-31 18:00:07 +04:00
|
|
|
|
|
|
|
For Debian, Ubuntu: packages in the repository are so old,
|
|
|
|
consider installing them with [NodeSource](https://github.com/nodesource/distributions#installation-instructions).
|
|
|
|
Minimal required version is NodeJS 18.
|
|
|
|
|
|
|
|
Other distros:
|
2023-08-31 11:13:54 +04:00
|
|
|
```bash
|
|
|
|
# CentOS
|
|
|
|
sudo yum install nodejs
|
|
|
|
# Arch
|
|
|
|
sudo pacman -S nodejs npm
|
|
|
|
# Alpine
|
|
|
|
doas apk add nodejs npm
|
|
|
|
```
|
|
|
|
|
2023-09-01 16:43:15 +04:00
|
|
|
## Create a user for txtdot
|
2023-08-31 18:00:07 +04:00
|
|
|
|
|
|
|
Almost all distros except Alpine:
|
2023-08-31 11:13:54 +04:00
|
|
|
```bash
|
|
|
|
sudo useradd -r -m -s /sbin/nologin -U txtdot
|
2023-08-31 17:41:42 +04:00
|
|
|
sudo -u txtdot bash
|
2023-08-31 18:00:07 +04:00
|
|
|
```
|
2023-08-31 11:13:54 +04:00
|
|
|
|
2023-09-01 16:43:15 +04:00
|
|
|
Alpine Linux with busybox and doas:
|
2023-08-31 18:00:07 +04:00
|
|
|
```bash
|
2023-08-31 11:13:54 +04:00
|
|
|
doas addgroup -S txtdot
|
|
|
|
doas adduser -h /home/txtdot -s /sbin/nologin -G txtdot -S -D txtdot
|
|
|
|
doas -u txtdot bash
|
|
|
|
```
|
|
|
|
|
2023-09-01 16:43:15 +04:00
|
|
|
## Build, config and launch
|
2023-08-31 18:00:07 +04:00
|
|
|
|
|
|
|
Clone the git repository, cd into it:
|
2023-08-31 11:13:54 +04:00
|
|
|
```bash
|
|
|
|
git clone https://github.com/txtdot/txtdot.git src
|
2023-08-31 18:00:07 +04:00
|
|
|
cd src
|
|
|
|
```
|
|
|
|
|
2023-09-01 16:43:15 +04:00
|
|
|
Copy and modify the sample config file (see the [Configuring](env.md) section):
|
2023-08-31 18:00:07 +04:00
|
|
|
```bash
|
|
|
|
cp .env.example .env
|
|
|
|
nano .env
|
2023-08-31 11:13:54 +04:00
|
|
|
```
|
|
|
|
|
|
|
|
Install packages, compile TS:
|
|
|
|
```bash
|
|
|
|
npm install
|
|
|
|
npm run build
|
|
|
|
```
|
|
|
|
|
|
|
|
Manually start the server to check if it works (Ctrl+C to exit):
|
|
|
|
```bash
|
|
|
|
npm run start
|
|
|
|
```
|
|
|
|
|
2023-08-31 18:00:07 +04:00
|
|
|
Log out from the txtdot account:
|
|
|
|
```bash
|
|
|
|
exit
|
|
|
|
```
|
2023-08-31 11:13:54 +04:00
|
|
|
|
2023-09-01 16:43:15 +04:00
|
|
|
## Add txtdot to autostart
|
2023-08-31 11:13:54 +04:00
|
|
|
Either using systemd unit file:
|
|
|
|
```bash
|
2023-08-31 17:41:42 +04:00
|
|
|
wget https://raw.githubusercontent.com/TxtDot/txtdot/main/config/txtdot.service
|
2023-08-31 11:13:54 +04:00
|
|
|
sudo chown root:root txtdot.service
|
2023-08-31 17:41:42 +04:00
|
|
|
sudo chmod 644 txtdot.service
|
2023-08-31 11:13:54 +04:00
|
|
|
sudo mv txtdot.service /etc/systemd/system/
|
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl enable txtdot
|
|
|
|
sudo systemctl start txtdot
|
|
|
|
```
|
|
|
|
|
|
|
|
Or using OpenRC script:
|
|
|
|
```bash
|
2023-08-31 17:41:42 +04:00
|
|
|
wget -O txtdot https://raw.githubusercontent.com/TxtDot/txtdot/main/config/txtdot.init
|
2023-08-31 11:13:54 +04:00
|
|
|
doas chown root:root txtdot
|
|
|
|
doas chmod 755 txtdot
|
|
|
|
doas mv txtdot /etc/init.d/
|
|
|
|
doas rc-update add txtdot
|
|
|
|
doas rc-service txtdot start
|
|
|
|
```
|
|
|
|
|
|
|
|
Or using crontab:
|
|
|
|
```bash
|
|
|
|
sudo crontab -u txtdot -e
|
|
|
|
# The command will open an editor
|
|
|
|
# Add this line to the end of the file:
|
|
|
|
@reboot sleep 10 && cd /home/txtdot/src && npm run start
|
|
|
|
# Save the file and exit
|
|
|
|
```
|