Compare commits

...

3 Commits

Author SHA1 Message Date
jude
98191d29ee deb-related stuff 2023-05-07 21:08:59 +01:00
jude
1c4c4a8b31 Add deb stuff. Correct dependency on database name 2023-05-07 20:59:07 +01:00
jude
d496c81003 Correct typo in path 2023-05-07 20:38:08 +01:00
12 changed files with 56 additions and 23 deletions

2
Cargo.lock generated
View File

@ -2188,7 +2188,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]] [[package]]
name = "reminder_rs" name = "reminder-rs"
version = "1.6.10" version = "1.6.10"
dependencies = [ dependencies = [
"base64", "base64",

View File

@ -1,8 +1,10 @@
[package] [package]
name = "reminder_rs" name = "reminder-rs"
version = "1.6.10" version = "1.6.10"
authors = ["Jude Southworth <judesouthworth@pm.me>"] authors = ["Jude Southworth <judesouthworth@pm.me>"]
edition = "2021" edition = "2021"
license = "AGPL-3.0 only"
description = "Reminder Bot for Discord, now in Rust"
[dependencies] [dependencies]
poise = "0.4" poise = "0.4"
@ -33,12 +35,14 @@ path = "postman"
path = "web" path = "web"
[package.metadata.deb] [package.metadata.deb]
depends = "$auto, nginx, python3, python3-venv" depends = "$auto, python3-dateparser"
suggests = "mysql-server-8.0" suggests = "mysql-server-8.0, nginx"
maintainer-scripts = "debian" maintainer-scripts = "debian"
assets = [ assets = [
["target/release/reminder-rs", "usr/bin/reminder-rs", "755"], ["target/release/reminder-rs", "usr/bin/reminder-rs", "755"],
["conf/default.env", "etc/reminder-rs/default.env", "600"] ["conf/default.env", "etc/reminder-rs/default.env", "600"],
# ["web/static/", "var/www/reminder-rs/static", "755"],
# ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"]
] ]
[package.metadata.deb.systemd-units] [package.metadata.deb.systemd-units]

9
Containerfile Normal file
View File

@ -0,0 +1,9 @@
FROM ubuntu:20.04
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y gcc gcc-multilib cmake pkg-config libssl-dev curl mysql-client-8.0
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal
RUN cargo install cargo-deb

View File

@ -9,7 +9,7 @@ You'll need rustc and cargo for compilation. To run, you'll need Python 3 still
### Compiling ### Compiling
Install build requirements: Install build requirements:
`sudo apt install gcc gcc-multilib cmake libssl-dev build-essential` `sudo apt install gcc gcc-multilib cmake libssl-dev build-essential python3-dateparser`
Install Rust from https://rustup.rs Install Rust from https://rustup.rs
@ -28,9 +28,7 @@ Use MySQL 8. MariaDB is confirmed not working at the moment.
Load the SQL files in order from "migrations" to generate the database schema. Load the SQL files in order from "migrations" to generate the database schema.
### Setting up Python ### Setting up Python
Reminder Bot by default looks for a venv within it's working directory to run Python out of. To set up a venv, install `python3-venv` and run `python3 -m venv venv`. Then, run `source venv/bin/activate` to activate the venv, and do `pip install dateparser` to install the required library. Reminder Bot uses `python3-dateparser` to handle dates. This depends on Python 3.
Remember where you create the venv! You may need to change the `PYTHON_LOCATION` variable in the next step to point to your Python binary if the venv is not in your working directory.
### Environment Variables ### Environment Variables
Reminder Bot reads a number of environment variables. Some are essential, and others have hardcoded fallbacks. Environment variables can be loaded from a .env file in the working directory. Reminder Bot reads a number of environment variables. Some are essential, and others have hardcoded fallbacks. Environment variables can be loaded from a .env file in the working directory.
@ -46,8 +44,3 @@ __Other Variables__
* `CNC_GUILD` - default `None`, accepts a single Discord guild ID for the server that the subscription roles belong to * `CNC_GUILD` - default `None`, accepts a single Discord guild ID for the server that the subscription roles belong to
* `PYTHON_LOCATION` - default `venv/bin/python3`. Can be changed if your Python executable is located somewhere else * `PYTHON_LOCATION` - default `venv/bin/python3`. Can be changed if your Python executable is located somewhere else
* `THEME_COLOR` - default `8fb677`. Specifies the hex value of the color to use on info message embeds * `THEME_COLOR` - default `8fb677`. Specifies the hex value of the color to use on info message embeds
* `DM_ENABLED` - default `1`, if `1`, Reminder Bot will respond to direct messages
### Todo List
* Convert aliases to macros

3
build.rs Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("cargo:rerun-if-changed=migrations");
}

View File

@ -6,7 +6,8 @@ PATREON_ROLE_ID=
LOCAL_TIMEZONE= LOCAL_TIMEZONE=
MIN_INTERVAL= MIN_INTERVAL=
PYTHON_LOCATION= PYTHON_LOCATION=/usr/bin/python3
DONTRUN=web
SECRET_KEY= SECRET_KEY=
REMIND_INTERVAL= REMIND_INTERVAL=

2
debian/.gitignore vendored
View File

@ -1,2 +0,0 @@
*
!.gitignore

13
debian/postinst vendored Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
id -u reminder &>/dev/null || useradd -r -M reminder
if [ ! -f /etc/reminder-rs/config.env ]; then
cp /etc/reminder-rs/default.env /etc/reminder-rs/config.env
fi
chown reminder /etc/reminder-rs/config.env
#DEBHELPER#

11
debian/postrm vendored Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e
id -u reminder &>/dev/null || userdel reminder
if [ -f /etc/reminder-rs/config.env ]; then
rm /etc/reminder-rs/config.env
fi
#DEBHELPER#

View File

@ -14,7 +14,7 @@ CREATE TABLE guilds (
default_avatar VARCHAR(512) DEFAULT 'https://raw.githubusercontent.com/reminder-bot/logos/master/Remind_Me_Bot_Logo_PPic.jpg' NOT NULL, default_avatar VARCHAR(512) DEFAULT 'https://raw.githubusercontent.com/reminder-bot/logos/master/Remind_Me_Bot_Logo_PPic.jpg' NOT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
FOREIGN KEY (default_channel_id) REFERENCES reminders.channels(id) ON DELETE SET NULL FOREIGN KEY (default_channel_id) REFERENCES channels(id) ON DELETE SET NULL
); );
CREATE TABLE channels ( CREATE TABLE channels (
@ -35,7 +35,7 @@ CREATE TABLE channels (
guild_id INT UNSIGNED, guild_id INT UNSIGNED,
PRIMARY KEY (id), PRIMARY KEY (id),
FOREIGN KEY (guild_id) REFERENCES reminders.guilds(id) ON DELETE CASCADE FOREIGN KEY (guild_id) REFERENCES guilds(id) ON DELETE CASCADE
); );
CREATE TABLE users ( CREATE TABLE users (
@ -55,7 +55,7 @@ CREATE TABLE users (
patreon BOOLEAN NOT NULL DEFAULT 0, patreon BOOLEAN NOT NULL DEFAULT 0,
PRIMARY KEY (id), PRIMARY KEY (id),
FOREIGN KEY (dm_channel) REFERENCES reminders.channels(id) ON DELETE RESTRICT FOREIGN KEY (dm_channel) REFERENCES channels(id) ON DELETE RESTRICT
); );
CREATE TABLE roles ( CREATE TABLE roles (
@ -67,7 +67,7 @@ CREATE TABLE roles (
guild_id INT UNSIGNED NOT NULL, guild_id INT UNSIGNED NOT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
FOREIGN KEY (guild_id) REFERENCES reminders.guilds(id) ON DELETE CASCADE FOREIGN KEY (guild_id) REFERENCES guilds(id) ON DELETE CASCADE
); );
CREATE TABLE embeds ( CREATE TABLE embeds (

View File

@ -88,8 +88,8 @@ async fn main() -> Result<(), Box<dyn StdError + Send + Sync>> {
async fn _main(tx: Sender<()>) -> Result<(), Box<dyn StdError + Send + Sync>> { async fn _main(tx: Sender<()>) -> Result<(), Box<dyn StdError + Send + Sync>> {
env_logger::init(); env_logger::init();
if Path::new("/etc/soundfx-rs/default.env").exists() { if Path::new("/etc/reminder-rs/config.env").exists() {
dotenv::from_path("/etc/soundfx-rs/default.env")?; dotenv::from_path("/etc/reminder-rs/config.env")?;
} }
let discord_token = env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment"); let discord_token = env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment");

View File

@ -2,6 +2,7 @@
Description=Reminder Bot Description=Reminder Bot
[Service] [Service]
User=reminder
Type=simple Type=simple
ExecStart=/usr/bin/reminder-rs ExecStart=/usr/bin/reminder-rs
Restart=always Restart=always