| sidebar_position | 6 |
|---|---|
| sidebar_label | Installation on Debian |
:::tip
These are instructions for the installation of draupnir from source on Debian. This installation method is intended for experienced sysadmins.
:::
install git curl and sudo
apt update && apt install -y git curl sudoinstall node 20 from the node source repo, the full instructions can be found at https://nodesource.com/products/distributions
curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt update && apt install nodejs -yinstall yarn via npm
npm install --global yarncreate the directory to clone the repo
mkdir /opt/mod-botclone the repo and fetch the tags
git clone --branch v2.9.0 --depth 1 https://github.com/the-draupnir-project/Draupnir.git /opt/mod-bot/Draupnirgit -C /opt/mod-bot/Draupnir fetch --tagscreate the directory for draupnirs datastorage
mkdir /opt/mod-bot/Draupnir/datastorageadd corepack
yarn global add corepackadd 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
useradd -m draupnirgive ownership of the draupnir directory to the bot user
chown -R draupnir:draupnir /opt/mod-bot/Draupnirbuild the bot with yarn
sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && yarn install"
sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && yarn build"copy the default config to production.yaml
cp /opt/mod-bot/Draupnir/config/default.yaml /opt/mod-bot/Draupnir/config/production.yamlchange the path of the datadirectory from the default to the directory we created earlier since the default dir is for the docker setup
sed -i 's|dataPath: "/data/storage"|dataPath: "/opt/mod-bot/Draupnir/datastorage"|' /opt/mod-bot/Draupnir/config/production.yamledit the production config: the most important things to configure are the
homeserverUrl:, the rawHomeserverUrl:, the accessToken: and the
managementRoom:
nano /opt/mod-bot/Draupnir/config/production.yamlcopy this to /etc/systemd/system/draupnir.service and enable with
systemctl enable draupnir, then simply start with systemctl start draupnir
:::tip
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)
:::
[Unit]
Description=Draupnir
#After=matrix-synapse.service # You can enable this if your matrix server is synapse, otherwise you might want to change it to the service that starts your homeserver
#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
Restart=always
User=draupnir
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
SyslogIdentifier=draupnir
ReadWritePaths=/opt/mod-bot/Draupnir
NoNewPrivileges=yes
PrivateDevices=yes
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=strict
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictRealtime=true
LockPersonality=true
ProtectKernelLogs=true
ProtectKernelTunables=true
ProtectHostname=true
ProtectKernelModules=true
PrivateUsers=true
ProtectClock=true
SystemCallArchitectures=native
SystemCallErrorNumber=EPERM
SystemCallFilter=@system-service
# EnvironmentFile=-/path/to/env/file # Optional: if you want to load environment variables from a file
[Install]
WantedBy=multi-user.targetif you want to update && upgrade everything, use the draupnir useraccount in order to not create conflicts with filepermissions/ownerships
stop the bot
systemctl stop draupnirpull updates from github with
sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && git fetch --tags && git checkout v2.9.0"install/update yarn
sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && yarn install"build the bot
sudo -u draupnir bash -c "cd /opt/mod-bot/Draupnir && yarn build"then simply start the bot again with
systemctl restart draupnir