Skip to content

Commit 29c3e98

Browse files
committed
add requestet changes
1 parent 09fbd4c commit 29c3e98

File tree

1 file changed

+103
-86
lines changed

1 file changed

+103
-86
lines changed

docs/bot/setup_debian.md

Lines changed: 103 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -14,92 +14,102 @@ This installation method is intended for experienced sysadmins.
1414

1515
:::
1616

17-
## 1. Prerequisites & System User
17+
## Prerequisites & System User
1818

19-
1. Ensure you have a user with `sudo` privileges.
20-
2. Create the `draupnir` system user (no login shell):
21-
22-
```bash
23-
sudo useradd --system --home-dir /opt/draupnir --shell /usr/sbin/nologin draupnir
24-
```
25-
26-
## 2. Install System Packages
19+
### Install System Packages
2720

2821
Update `apt` and install required tools **as your regular sudo user**:
2922

3023
```bash
31-
sudo apt update
32-
sudo apt install -y git curl sudo
24+
apt update
25+
apt install -y git curl sudo
3326
```
3427

3528
- `git` : version control
3629
- `curl` : data transfer
3730
- `sudo` : execute commands as root
3831

39-
## 3. Install Node.js (v20)
32+
### Create User
33+
34+
Create the `draupnir` system user (no login shell):
35+
36+
```bash
37+
useradd --system --home-dir /opt/draupnir draupnir
38+
```
39+
40+
### Install Node.js (v20)
4041

4142
Draupnir requires Node.js 20.x. Install via NodeSource:
4243

4344
```bash
4445
curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
45-
sudo bash nodesource_setup.sh
46-
sudo apt update
47-
sudo apt install -y nodejs
46+
bash nodesource_setup.sh
47+
apt update
48+
apt install -y nodejs
49+
```
50+
51+
Verify Node.js version:
52+
53+
```bash
54+
node --version
55+
# Should output v20.x.x
4856
```
49-
## 4. Install Yarn
57+
58+
## Install Yarn
5059

5160
Still as your sudo user:
5261

5362
```bash
54-
sudo npm install --global yarn
63+
npm install --global yarn
5564
yarn --version
5665
```
5766

58-
## 5. Prepare Directories & Permissions
67+
## Setup Directories & Permissions
5968

60-
1. Clone the repository:
69+
Clone the repository:
6170

62-
```bash
63-
git clone https://github.com/the-draupnir-project/Draupnir.git /opt/draupnir
64-
```
71+
```bash
72+
git clone https://github.com/the-draupnir-project/Draupnir.git /opt/draupnir
73+
```
6574

66-
2. Create the base directory and data directory:
75+
Create the data directory:
6776

68-
```bash
69-
sudo mkdir -p /opt/draupnir/datastorage
70-
```
77+
```bash
78+
mkdir -p /var/lib/draupnir
79+
```
7180

72-
3. Change ownership to `draupnir`:
81+
Change ownership to `draupnir`:
7382

74-
```bash
75-
sudo chown -R draupnir:draupnir /opt/mod-bot
76-
```
83+
```bash
84+
chown draupnir:draupnir /var/lib/draupnir
85+
chown -R draupnir:draupnir /opt/draupnir
86+
```
7787

78-
## 6. Clone Repository & Fetch Tags
88+
## Build Draupnir
7989

8090
Switch to the `draupnir` user:
8191

8292
```bash
83-
sudo -u draupnir -i
93+
su - draupnir
8494
```
8595

8696
Then within that shell:
8797

88-
1. Fetch all tags:
98+
Fetch all tags:
8999

90-
```bash
91-
cd /opt/draupnir
92-
git fetch --tags
93-
```
100+
```bash
101+
cd /opt/draupnir
102+
git fetch --tags
103+
```
94104

95-
2. Check out the latest tag:
105+
Check out the latest tag:
96106

97-
```bash
98-
latest_tag=$(git tag --sort=version:refname | tail -n1)
99-
git checkout "$latest_tag"
100-
```
107+
```bash
108+
latest_tag=$(git tag --sort=version:refname | tail -n1)
109+
git checkout "$latest_tag"
110+
```
101111

102-
## 7. Install Dependencies & Build
112+
### Install Dependencies & Build
103113

104114
Run as `draupnir`:
105115

@@ -111,36 +121,42 @@ yarn build
111121
- `yarn install` installs dependencies
112122
- `yarn build` compiles TypeScript into `lib/`
113123

114-
## 8. Configure Draupnir
124+
## Configure Draupnir
115125

116126
Still under `draupnir`:
117127

118-
1. Copy the default config:
128+
Copy the default config:
129+
130+
```bash
131+
cp /opt/draupnir/config/default.yaml /opt/draupnir/config/production.yaml
132+
```
133+
134+
Update the data path:
119135

120-
```bash
121-
cp /opt/draupnir/config/default.yaml /opt/draupnir/config/production.yaml
122-
```
136+
```bash
137+
sed -i 's|dataPath: "/data/storage"|dataPath: "/var/lib/draupnir"|' /opt/draupnir/config/production.yaml
138+
```
123139

124-
2. Update the data path:
140+
Edit production settings:
125141

126-
```bash
127-
sed -i 's|dataPath: "/data/storage"|dataPath: "/opt/draupnir/datastorage"|' /opt/draupnir/config/production.yaml
128-
```
142+
```bash
143+
nano /opt/draupnir/config/production.yaml
144+
```
129145

130-
3. Edit production settings:
146+
Set at least:
131147

132-
```bash
133-
nano /opt/draupnir/config/production.yaml
134-
```
148+
- `homeserverUrl:` (e.g., `https://matrix.example.com`)
149+
- `rawHomeserverUrl:` (e.g., `https://matrix.example.com`)
150+
- `accessToken:` (your bot's access token)
151+
- `managementRoom:` (e.g., `!roomid:example.com`)
135152

136-
Set at least:
153+
Exit the `draupnir` user shell:
137154

138-
- `homeserverUrl:`
139-
- `rawHomeserverUrl:`
140-
- `accessToken:`
141-
- `managementRoom:`
155+
```bash
156+
exit
157+
```
142158

143-
## 9. Create Systemd Service
159+
## Create Systemd Service
144160

145161
As your sudo user, create `/etc/systemd/system/draupnir.service`:
146162

@@ -160,6 +176,7 @@ Environment=NODE_ENV=production
160176
SyslogIdentifier=draupnir
161177

162178
ReadWritePaths=/opt/draupnir
179+
ReadWritePaths=/var/lib/draupnir
163180
NoNewPrivileges=yes
164181
PrivateDevices=yes
165182
PrivateTmp=yes
@@ -187,37 +204,37 @@ WantedBy=multi-user.target
187204
Reload systemd, enable and start:
188205

189206
```bash
190-
sudo systemctl daemon-reload
191-
sudo systemctl enable --now draupnir
192-
sudo systemctl status draupnir
207+
systemctl daemon-reload
208+
systemctl enable --now draupnir
209+
systemctl status draupnir
193210
```
194211

195-
## 10. Update Draupnir
212+
# Update Draupnir
196213

197214
When a new release is out:
198215

199-
1. Stop service:
216+
Stop service:
200217

201-
```bash
202-
sudo systemctl stop draupnir
203-
```
218+
```bash
219+
systemctl stop draupnir
220+
```
204221

205-
2. Pull updates & fetch tags as `draupnir`:
222+
Pull updates & fetch tags as `draupnir`:
206223

207-
```bash
208-
sudo -u draupnir -i bash <<'EOF'
209-
cd /opt/draupnir
210-
git pull
211-
git fetch --tags
212-
latest_tag=$(git tag --sort=version:refname | tail -n1)
213-
git checkout "$latest_tag"
214-
yarn install
215-
yarn build
216-
EOF
217-
```
224+
```bash
225+
sudo -u draupnir bash <<'EOF'
226+
cd /opt/draupnir
227+
git pull
228+
git fetch --tags
229+
latest_tag=$(git tag --sort=version:refname | tail -n1)
230+
git checkout "$latest_tag"
231+
yarn install
232+
yarn build
233+
EOF
234+
```
218235

219-
3. Restart service:
236+
Restart service:
220237

221-
```bash
222-
sudo systemctl restart draupnir
223-
```
238+
```bash
239+
systemctl restart draupnir
240+
```

0 commit comments

Comments
 (0)