From b49bae58b5e0eb36e0fe07bade1c263be1558690 Mon Sep 17 00:00:00 2001 From: rugk Date: Fri, 3 Nov 2023 17:23:41 +0000 Subject: [PATCH 01/13] Use environmental variables for docker-compose * You can start it as usual, `.env` file is automatically used. * IMHO easier and cleaner to configure. * Also removed the `` as it makes this not-runnable out-of-the-box. I need this for https://github.com/Ravinou/borgwarehouse/pull/69 and this was the initial idea of making this PR. * The `${:?}` syntax is a bash-like thing to produce a proper error message if the variable is not provided. I checked the setup should basically start (just got a permission error as the UID/GID is wrong). --- docker-compose.yml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9cdf5a1..3f39852 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,24 +7,22 @@ services: # context: . # dockerfile: Dockerfile image: borgwarehouse/borgwarehouse - # UID:GID must match the user and group ID of the host folders and must be > 1000 - user: '1001:1001' + user: "${UID:?UID variable missing}:${GID:?GID variable missing}" ports: - - '3000:3000' - - '2222:22' + - "${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000" + - "${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22" environment: - - NEXTAUTH_URL=https://your.domain.com - - NEXTAUTH_SECRET=your-secret - - CRONJOB_KEY=your-other-secret - # The SSH_SERVER_PORT must match the port exposed above - - SSH_SERVER_PORT=2222 - - FQDN=your.domain.com + - NEXTAUTH_URL=${NEXTAUTH_URL:?NEXTAUTH_URL variable missing} + - NEXTAUTH_SECRET=${NEXTAUTH_SECRET:?NEXTAUTH_SECRET variable missing} + - CRONJOB_KEY=${CRONJOB_KEY:?CRONJOB_KEY variable missing} + - SSH_SERVER_PORT=${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing} + - FQDN=${FQDN:?FQDN variable missing} volumes: - # The host folders must be owned by the user with UID and GID specified above - - /config:/home/borgwarehouse/app/config - - /ssh:/home/borgwarehouse/.ssh - - /ssh_host:/etc/ssh - - /repos:/home/borgwarehouse/repos + - ${CONFIG_PATH:?CONFIG_PATH variable missing}:/home/borgwarehouse/app/config + - ${SSH_PATH:?SSH_PATH variable missing}:/home/borgwarehouse/.ssh + - ${SSH_HOST:?SSH_HOST variable missing}:/etc/ssh + - ${BORG_REPOSITORY_PATH:?BORG_REPOSITORY_PATH variable missing}:/home/borgwarehouse/repos + # Apprise is used to send notifications, it's optional. http://apprise:8000 is the URL to use in BorgWarehouse. apprise: container_name: apprise From fb77a975db3d9040bec2222946608f7c9c66f294 Mon Sep 17 00:00:00 2001 From: rugk Date: Fri, 3 Nov 2023 17:32:26 +0000 Subject: [PATCH 02/13] Add .env file as sample for env variables --- .env.sample | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..14d75a7 --- /dev/null +++ b/.env.sample @@ -0,0 +1,22 @@ +# ports +WEB_SERVER_PORT=3000 +SSH_SERVER_PORT=2222 + +# your domain +FQDN=your.domain.com +NEXTAUTH_URL=https://your.domain.com + +# secrets +NEXTAUTH_SECRET=your-secret +CRONJOB_KEY=your-other-secret + +# UID:GID must match the user and group ID of the host folders and must be > 1000 +UID=1001 +GID=1001 + +# config folders +# The host folders must be owned by the user with UID and GID specified above +CONFIG_PATH=./config +SSH_PATH=./ssh +SSH_HOST=./ssh_host +BORG_REPOSITORY_PATH=./repos From f6929fa7de8fc7f34296050775f8a6a67fe84b77 Mon Sep 17 00:00:00 2001 From: rugk Date: Tue, 5 Dec 2023 19:58:34 +0000 Subject: [PATCH 03/13] Use more and new environment variables --- .env.sample | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.env.sample b/.env.sample index 14d75a7..dc76aa4 100644 --- a/.env.sample +++ b/.env.sample @@ -1,12 +1,14 @@ -# ports +## Required variables section ## + +# Host port mappings WEB_SERVER_PORT=3000 SSH_SERVER_PORT=2222 -# your domain +# Hostname and URL FQDN=your.domain.com NEXTAUTH_URL=https://your.domain.com -# secrets +# Secrects NEXTAUTH_SECRET=your-secret CRONJOB_KEY=your-other-secret @@ -14,9 +16,23 @@ CRONJOB_KEY=your-other-secret UID=1001 GID=1001 -# config folders +# Config and data folders (volume mounts) # The host folders must be owned by the user with UID and GID specified above CONFIG_PATH=./config SSH_PATH=./ssh SSH_HOST=./ssh_host BORG_REPOSITORY_PATH=./repos + +## Optional variables section ## + +# LAN feature +FQDN_LAN= +SSH_SERVER_PORT_LAN= + +# SMTP server settings +MAIL_SMTP_FROM= +MAIL_SMTP_HOST= +MAIL_SMTP_PORT= +MAIL_SMTP_LOGIN= +MAIL_SMTP_PWD= +MAIL_REJECT_SELFSIGNED_TLS= \ No newline at end of file From 20b3504b94b60a4fd2e85916a6f80ae4b37c0402 Mon Sep 17 00:00:00 2001 From: rugk Date: Tue, 5 Dec 2023 20:02:26 +0000 Subject: [PATCH 04/13] Refactor to load whole .env file instead of single variables --- docker-compose.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3f39852..4c173e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,12 +11,8 @@ services: ports: - "${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000" - "${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22" - environment: - - NEXTAUTH_URL=${NEXTAUTH_URL:?NEXTAUTH_URL variable missing} - - NEXTAUTH_SECRET=${NEXTAUTH_SECRET:?NEXTAUTH_SECRET variable missing} - - CRONJOB_KEY=${CRONJOB_KEY:?CRONJOB_KEY variable missing} - - SSH_SERVER_PORT=${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing} - - FQDN=${FQDN:?FQDN variable missing} + env_file: + - .env volumes: - ${CONFIG_PATH:?CONFIG_PATH variable missing}:/home/borgwarehouse/app/config - ${SSH_PATH:?SSH_PATH variable missing}:/home/borgwarehouse/.ssh From 10ad738755f7f0abbc72e7b10364900fc1e3cf4d Mon Sep 17 00:00:00 2001 From: Ravinou Date: Fri, 10 Nov 2023 16:24:58 +0100 Subject: [PATCH 05/13] feat: add a disabled option in repo alert settings --- Components/Repo/Repo.js | 41 ++++++++++++++++------------- Components/Repo/Repo.module.css | 9 +++++++ Containers/RepoList/RepoList.js | 1 + Containers/RepoManage/RepoManage.js | 3 ++- pages/api/cronjob/checkStatus.js | 1 + pages/api/repo/add.js | 2 +- pages/api/repo/id/[slug]/edit.js | 2 +- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Components/Repo/Repo.js b/Components/Repo/Repo.js index 1d1cb03..d06089a 100644 --- a/Components/Repo/Repo.js +++ b/Components/Repo/Repo.js @@ -6,6 +6,7 @@ import { IconInfoCircle, IconChevronDown, IconChevronUp, + IconBellOff, } from '@tabler/icons-react'; import timestampConverter from '../../helpers/functions/timestampConverter'; import StorageBar from '../UI/StorageBar/StorageBar'; @@ -53,22 +54,33 @@ export default function Repo(props) { setDisplayDetails(boolean); }; + //Status indicator + const statusIndicator = () => { + return props.status + ? classes.statusIndicatorGreen + : classes.statusIndicatorRed; + }; + + //Alert indicator + const alertIndicator = () => { + if (props.alert === 0) { + return ( +
+ +
+ ); + } + }; + return ( <> {displayDetails ? ( <>
- {props.status ? ( -
- ) : ( -
- )} +
{props.alias}
+ {alertIndicator()} {props.comment && (
@@ -141,16 +153,9 @@ export default function Repo(props) { <>
- {props.status ? ( -
- ) : ( -
- )} +
{props.alias}
+ {alertIndicator()} {props.comment && (
diff --git a/Components/Repo/Repo.module.css b/Components/Repo/Repo.module.css index 04250d0..ae972e8 100644 --- a/Components/Repo/Repo.module.css +++ b/Components/Repo/Repo.module.css @@ -148,6 +148,15 @@ } } +/* Alert icon */ + +.alertIcon { + display: flex; + flex-direction: row; + align-items: center; + margin-left: 10px; +} + /* GENERAL */ .alias { font-weight: bold; diff --git a/Containers/RepoList/RepoList.js b/Containers/RepoList/RepoList.js index 2bbf642..8e794f1 100644 --- a/Containers/RepoList/RepoList.js +++ b/Containers/RepoList/RepoList.js @@ -116,6 +116,7 @@ export default function RepoList() { alias={repo.alias} status={repo.status} lastSave={repo.lastSave} + alert={repo.alert} repositoryName={repo.repositoryName} storageSize={repo.storageSize} storageUsed={repo.storageUsed} diff --git a/Containers/RepoManage/RepoManage.js b/Containers/RepoManage/RepoManage.js index 4d19db2..90370ca 100644 --- a/Containers/RepoManage/RepoManage.js +++ b/Containers/RepoManage/RepoManage.js @@ -23,6 +23,7 @@ export default function RepoManage(props) { } = useForm({ mode: 'onChange' }); //List of possible times for alerts const alertOptions = [ + { value: 0, label: 'Disabled' }, { value: 3600, label: '1 hour' }, { value: 21600, label: '6 hours' }, { value: 43200, label: '12 hours' }, @@ -471,7 +472,7 @@ export default function RepoManage(props) { x.value === targetRepo.alert ) - : alertOptions[3] + : alertOptions[4] } control={control} render={({ diff --git a/pages/api/cronjob/checkStatus.js b/pages/api/cronjob/checkStatus.js index 19f394e..842aaa3 100644 --- a/pages/api/cronjob/checkStatus.js +++ b/pages/api/cronjob/checkStatus.js @@ -102,6 +102,7 @@ export default async function handler(req, res) { for (let index in newRepoList) { if ( !newRepoList[index].status && + newRepoList[index].alert !== 0 && (!newRepoList[index].lastStatusAlertSend || date - newRepoList[index].lastStatusAlertSend > 90000) ) { diff --git a/pages/api/repo/add.js b/pages/api/repo/add.js index 0288817..3dd4770 100644 --- a/pages/api/repo/add.js +++ b/pages/api/repo/add.js @@ -19,7 +19,7 @@ export default async function handler(req, res) { const { alias, sshPublicKey, size, comment, alert, lanCommand } = req.body; //We check that we receive data for each variable. Only "comment" and "lanCommand" are optional in the form. - if (!alias || !sshPublicKey || !size || !alert) { + if (!alias || !sshPublicKey || !size || (!alert && alert !== 0)) { //If a variable is empty. res.status(422).json({ message: 'Unexpected data', diff --git a/pages/api/repo/id/[slug]/edit.js b/pages/api/repo/id/[slug]/edit.js index c724ef6..ea61b97 100644 --- a/pages/api/repo/id/[slug]/edit.js +++ b/pages/api/repo/id/[slug]/edit.js @@ -19,7 +19,7 @@ export default async function handler(req, res) { const { alias, sshPublicKey, size, comment, alert, lanCommand } = req.body; //We check that we receive data for each variable. Only "comment" and "lanCommand" are optional in the form. - if (!alias || !sshPublicKey || !size || !alert) { + if (!alias || !sshPublicKey || !size || (!alert && alert !== 0)) { //If a variable is empty. res.status(422).json({ message: 'Unexpected data', From 3638cd6d1deb0482d2d9c1e5467c3a5982651535 Mon Sep 17 00:00:00 2001 From: Ravinou Date: Sat, 11 Nov 2023 11:05:32 +0100 Subject: [PATCH 06/13] feat: add a LAN badge next to the quicksettings button --- .../Repo/QuickCommands/QuickCommands.js | 6 ++++-- .../QuickCommands/QuickCommands.module.css | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Components/Repo/QuickCommands/QuickCommands.js b/Components/Repo/QuickCommands/QuickCommands.js index 8685d80..c76a3a7 100644 --- a/Components/Repo/QuickCommands/QuickCommands.js +++ b/Components/Repo/QuickCommands/QuickCommands.js @@ -50,11 +50,13 @@ export default function QuickCommands(props) {
Copied !
) : (
- ssh://{wizardEnv.UNIX_USER}@ - {FQDN}:{SSH_SERVER_PORT}/./ + ssh://{wizardEnv.UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./ {props.repositoryName}
)} + + {props.lanCommand &&
LAN
} +