-
Notifications
You must be signed in to change notification settings - Fork 8
Refactor and clarify setup_selfbuild.md and setup_debian.md #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tealk
wants to merge
6
commits into
the-draupnir-project:main
Choose a base branch
from
Tealk:feature/version_pinning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f21b29a
restructure and enhance setup_selfbuild.md
Tealk 09fbd4c
restructure and enhance setup_debian.md
Tealk 29c3e98
add requestet changes
Tealk 96d6650
change description
Tealk 8f9f7aa
more detailed update documentation
Tealk fad8446
pin yarn to v1.x
Tealk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ sidebar_label: Installation on Debian | |
|
|
||
| <!-- cspell:ignore SUIDSGID, EPERM, tunables --> | ||
|
|
||
| # Installation on Debian | ||
| # Installation | ||
|
|
||
| :::tip | ||
|
|
||
|
|
@@ -14,106 +14,149 @@ This installation method is intended for experienced sysadmins. | |
|
|
||
| ::: | ||
|
|
||
| ## Installation | ||
| ## Prerequisites & System User | ||
|
|
||
| install git curl and sudo | ||
| ### Install System Packages | ||
|
|
||
| ```shell | ||
| apt update && apt install -y git curl sudo | ||
| Update `apt` and install required tools **as your root user**: | ||
|
|
||
| ```bash | ||
| apt update | ||
| apt install -y git curl sudo | ||
| ``` | ||
|
|
||
| install node 20 from the node source repo, the full instructions can be found at https://nodesource.com/products/distributions | ||
| - `git` : version control | ||
| - `curl` : data transfer | ||
| - `sudo` : execute commands as root | ||
|
|
||
| ### Create User | ||
|
|
||
| Create the `draupnir` system user (no login shell): | ||
|
|
||
| ```bash | ||
| useradd --system --home-dir /opt/draupnir draupnir | ||
| ``` | ||
|
|
||
| ```shell | ||
| ### Install Node.js (v20) | ||
|
|
||
| Draupnir requires Node.js 20.x. Install via NodeSource: | ||
|
|
||
| ```bash | ||
| curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh | ||
| bash nodesource_setup.sh | ||
| apt update && apt install nodejs -y | ||
| apt update | ||
| apt install -y nodejs | ||
| ``` | ||
|
|
||
| install yarn via npm | ||
| Verify Node.js version: | ||
|
|
||
| ```shell | ||
| npm install --global yarn | ||
| ```bash | ||
| node --version | ||
| # Should output v20.x.x | ||
| ``` | ||
|
|
||
| create the directory to clone the repo | ||
| ## Install Yarn | ||
|
|
||
| ```shell | ||
| mkdir /opt/mod-bot | ||
| ```bash | ||
| npm install --global [email protected] | ||
| yarn --version | ||
| ``` | ||
|
|
||
| clone the repo and fetch the tags | ||
| ## Setup Directories & Permissions | ||
|
|
||
| ```shell | ||
| git clone https://github.com/the-draupnir-project/Draupnir.git /opt/mod-bot/Draupnir | ||
| Clone the repository: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/the-draupnir-project/Draupnir.git /opt/draupnir | ||
| ``` | ||
|
|
||
| ```shell | ||
| git -C /opt/mod-bot/Draupnir fetch --tags | ||
| Create the data directory: | ||
|
|
||
| ```bash | ||
| mkdir -p /var/lib/draupnir | ||
| ``` | ||
|
|
||
| create the directory for draupnirs datastorage | ||
| Change ownership to `draupnir`: | ||
|
|
||
| ```shell | ||
| mkdir /opt/mod-bot/Draupnir/datastorage | ||
| ```bash | ||
| chown draupnir:draupnir /var/lib/draupnir | ||
| chown -R draupnir:draupnir /opt/draupnir | ||
| ``` | ||
|
|
||
| add corepack | ||
| ## Build Draupnir | ||
|
|
||
| ```shell | ||
| yarn global add corepack | ||
| Switch to the `draupnir` user: | ||
|
|
||
| ```bash | ||
| su - draupnir | ||
| ``` | ||
|
|
||
| add a user to run the bot | ||
| this user will be used by systemd to run the bot since there is no need to run it with root permissions | ||
| Then within that shell: | ||
|
|
||
| Fetch all tags: | ||
|
|
||
| ```shell | ||
| useradd -m draupnir | ||
| ```bash | ||
| cd /opt/draupnir | ||
| git fetch --tags | ||
| ``` | ||
|
|
||
| give ownership of the draupnir directory to the bot user | ||
| Check out the latest tag: | ||
|
|
||
| ```shell | ||
| chown -R draupnir:draupnir /opt/mod-bot/Draupnir | ||
| ```bash | ||
| latest_tag=$(git tag --sort=version:refname | tail -n1) | ||
| git checkout "$latest_tag" | ||
| ``` | ||
|
|
||
| build the bot with yarn | ||
| ### Install Dependencies & Build | ||
|
|
||
| ```shell | ||
| sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && yarn install" | ||
| sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && yarn build" | ||
| Run as `draupnir`: | ||
|
|
||
| ```bash | ||
| yarn install | ||
| yarn build | ||
| ``` | ||
|
|
||
| ## Edit the config | ||
| - `yarn install` installs dependencies | ||
| - `yarn build` compiles TypeScript into `lib/` | ||
|
|
||
| ## Configure Draupnir | ||
|
|
||
| copy the default config to production.yaml | ||
| Still under `draupnir`: | ||
|
|
||
| ```shell | ||
| cp /opt/mod-bot/Draupnir/config/default.yaml /opt/mod-bot/Draupnir/config/production.yaml | ||
| Copy the default config: | ||
|
|
||
| ```bash | ||
| cp /opt/draupnir/config/default.yaml /opt/draupnir/config/production.yaml | ||
| ``` | ||
|
|
||
| change the path of the datadirectory from the default to the directory we created earlier since the default dir is for the docker setup | ||
| Update the data path: | ||
|
|
||
| ```shell | ||
| sed -i 's|dataPath: "/data/storage"|dataPath: "/opt/mod-bot/Draupnir/datastorage"|' /opt/mod-bot/Draupnir/config/production.yaml | ||
| ```bash | ||
| sed -i 's|dataPath: "/data/storage"|dataPath: "/var/lib/draupnir"|' /opt/draupnir/config/production.yaml | ||
| ``` | ||
|
|
||
| edit the production config: | ||
| the most important things to configure are the `homeserverUrl:`, the `rawHomeserverUrl:`, the `accessToken:` and the `managementRoom:` | ||
| Edit production settings: | ||
|
|
||
| ```shell | ||
| nano /opt/mod-bot/Draupnir/config/production.yaml | ||
| ```bash | ||
| nano /opt/draupnir/config/production.yaml | ||
| ``` | ||
|
|
||
| ## Example systemd service | ||
| Set at least: | ||
|
|
||
| copy this to `/etc/systemd/system/draupnir.service` and enable with `systemctl enable draupnir`, then simply start with `systemctl start draupnir` | ||
| - `homeserverUrl:` (e.g., `https://matrix.example.com`) | ||
| - `rawHomeserverUrl:` (e.g., `https://matrix.example.com`) | ||
| - `accessToken:` (your bot's access token) | ||
| - `managementRoom:` (e.g., `!roomid:example.com`) | ||
|
|
||
| :::tip | ||
| Exit the `draupnir` user shell: | ||
|
|
||
| before you attempt to start the service, make sure that the management room for draupnir exists on your homeserver and is joinable by draupnir (either public room or invite the bot account in advance) | ||
| ```bash | ||
| exit | ||
| ``` | ||
|
|
||
| ::: | ||
| ## Create Systemd Service | ||
|
|
||
| As your root user, create `/etc/systemd/system/draupnir.service`: | ||
|
|
||
| ```ini | ||
| [Unit] | ||
|
|
@@ -122,15 +165,16 @@ Description=Draupnir | |
| #After=matrix-synapse.target # You can enable this if your matrix server is synapse and you have installed workers via the official instructions | ||
|
|
||
| [Service] | ||
| ExecStart=/usr/bin/node /opt/mod-bot/Draupnir/lib/index.js --draupnir-config /opt/mod-bot/Draupnir/config/production.yaml | ||
| WorkingDirectory=/opt/mod-bot/Draupnir | ||
| ExecStart=/usr/bin/node /opt/draupnir/lib/index.js --draupnir-config /opt/draupnir/config/production.yaml | ||
| WorkingDirectory=/opt/draupnir | ||
| Restart=always | ||
| User=draupnir | ||
| Environment=PATH=/usr/bin:/usr/local/bin | ||
| Environment=NODE_ENV=production | ||
| SyslogIdentifier=draupnir | ||
|
|
||
| ReadWritePaths=/opt/mod-bot/Draupnir | ||
| ReadWritePaths=/opt/draupnir | ||
| ReadWritePaths=/var/lib/draupnir | ||
| NoNewPrivileges=yes | ||
| PrivateDevices=yes | ||
| PrivateTmp=yes | ||
|
|
@@ -155,36 +199,71 @@ SystemCallFilter=@system-service | |
| WantedBy=multi-user.target | ||
| ``` | ||
|
|
||
| ## Updating the bot | ||
| Reload systemd, enable and start: | ||
|
|
||
| ```bash | ||
| systemctl daemon-reload | ||
| systemctl enable --now draupnir | ||
| systemctl status draupnir | ||
| ``` | ||
|
|
||
| # Update | ||
|
|
||
| if you want to update && upgrade everything, use the draupnir useraccount in order to not create conflicts with filepermissions/ownerships | ||
| When a new release is out: | ||
|
|
||
| stop the bot | ||
| ### Stop Service | ||
|
|
||
| ```shell | ||
| ```bash | ||
| systemctl stop draupnir | ||
| ``` | ||
|
|
||
| pull updates from github with | ||
| ### Update Source Code | ||
|
|
||
| Switch to the `draupnir` user: | ||
|
|
||
| ```bash | ||
| sudo -u draupnir -i | ||
| ``` | ||
|
|
||
| Then within that shell: | ||
|
|
||
| ```shell | ||
| sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && git pull && git fetch --tags" | ||
| Pull latest changes: | ||
|
|
||
| ```bash | ||
| cd /opt/draupnir | ||
| git pull | ||
| ``` | ||
|
|
||
| Fetch all tags: | ||
|
|
||
| ```bash | ||
| git fetch --tags | ||
| ``` | ||
|
|
||
| install/update yarn | ||
| Check out the latest tag: | ||
|
|
||
| ```bash | ||
| latest_tag=$(git tag --sort=version:refname | tail -n1) | ||
| git checkout "$latest_tag" | ||
| ``` | ||
|
Comment on lines
+245
to
+248
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea 👍 |
||
|
|
||
| ### Rebuild Application | ||
|
|
||
| Run as `draupnir`: | ||
|
|
||
| ```shell | ||
| sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && yarn install" | ||
| ```bash | ||
| yarn install | ||
| yarn build | ||
| ``` | ||
|
|
||
| build the bot | ||
| Exit the `draupnir` user shell: | ||
|
|
||
| ```shell | ||
| sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && yarn build" | ||
| ```bash | ||
| exit | ||
| ``` | ||
|
|
||
| then simply start the bot again with | ||
| ### Restart Service | ||
|
|
||
| ```shell | ||
| systemctl restart draupnir | ||
| ```bash | ||
| systemctl start draupnir | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably ok, what alternative do we have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't really like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Their website is absolutely crazy and screams untrustworthyness https://nodesource.com/. This may be normal for corporate foss but at the same time i will need to do some investigating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok looking at various github profiles this is legit it's just however owns the company is the one who must not be trusted.