vaultwarden-updater/README.md

80 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

# vaultwarden-updater
This script checks if Vaultwarden is up to date, updates it if necessary and sends a message to a Telegram bot.
2020-12-07 23:48:40 +01:00
## Introduction
The trap to avoid when installing custom software is to update it. It seems obvious, but it is never very easy because
there is often a compilation part, interoperability management between bricks, backups and so on.
2020-12-07 23:48:40 +01:00
## Requirements
### Software
It is clearly necessary to have deployed a Vaultwarden instance on your server. I wrote an article about this topic
here: https://illuad.fr/2020/06/11/install-vaultwarden.html
Since a message is sent to a Telegram bot, it is necessary to have one configured. I wrote an article about this topic
here: https://illuad.fr/2020/10/27/get-a-telegram-alert-on-a-ssh-login-with-pam.html
2020-12-07 23:48:40 +01:00
### System
2020-12-07 23:48:40 +01:00
This script can run on any GNU/Linux machine.
This script uses `git`, `cargo`, `curl` and `restorecon` commands but if you have followed my article, some of them are
required which means they will necessarily be installed.
2020-12-07 23:48:40 +01:00
## Installation
2020-12-07 23:48:40 +01:00
Since this script must be executed with root rights, it is a good practice to place it in `/usr/local/sbin/`.
```
curl -LOsSf https://gitea.illuad.fr/adrien/vaultwarden-updater/raw/branch/master/vaultwarden-updater.sh
sudo mv vaultwarden-updater.sh /usr/local/sbin
sudo chmod 750 /usr/local/sbin/vaultwarden-updater.sh
2020-12-07 23:48:40 +01:00
```
2021-01-25 14:56:42 +01:00
Create the logs' directory.
```
sudo mkdir -p /var/log/updater/vaultwarden-updater
2021-01-25 14:56:42 +01:00
```
2020-12-07 23:48:40 +01:00
## Configuration
2020-12-07 23:48:40 +01:00
This script requires the configuration of 3 variables to work: `key`, `chat_id` and `username`.
Variables `key` and `chat_id` correspond to the API key and the chat id obtained during the bot creation process. The
variable `username` must match the username with which you installed Vaultwarden.
2020-12-07 23:48:40 +01:00
#### Fast variables setting
2020-12-07 23:48:40 +01:00
For the `key` variable.
```
sudo sed -i "s/key=/key=<your_key>/" /usr/local/sbin/vaultwarden-updater.sh
2020-12-07 23:48:40 +01:00
```
For the `chat_id` variable.
```
sudo sed -i "s/chat_id=/chat_id=<your_chat_id>/" /usr/local/sbin/vaultwarden-updater.sh
2020-12-07 23:48:40 +01:00
```
For the `username` variable.
```
sudo sed -i "s/username=/username=<your_username>/" /usr/local/sbin/vaultwarden-updater.sh
2020-12-07 23:48:40 +01:00
```
## Automation
2020-12-07 23:48:40 +01:00
Running this script automatically is a good idea, here is what you should have in the cron jobs of the root user.
```
sudo crontab -l
0 1 * * * /usr/local/sbin/vaultwarden-updater.sh
2020-12-07 23:48:40 +01:00
```
Every day at 1:00 am, the script will check if Vaultwarden is up to date.