mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-29 10:50:32 +02:00
Compare commits
283 commits
Author | SHA1 | Date | |
---|---|---|---|
|
26530d6bdc | ||
|
13aa4055ff | ||
|
6763cac795 | ||
|
2085a7bb67 | ||
|
b7ec34588f | ||
|
f7de065ee2 | ||
|
b620cd27b8 | ||
|
d51103c4f5 | ||
|
de3fa3f3af | ||
|
f8b6c46d80 | ||
|
8a7e30d008 | ||
|
7dbe181629 | ||
|
36753d0aa0 | ||
|
67d959f9fb | ||
|
81ed817045 | ||
|
02efa8ad94 | ||
|
3f8fbb77bb | ||
|
52ed551200 | ||
|
ea5d565567 | ||
|
fa218b0522 | ||
|
56098d3f8d | ||
|
08e6b0e6a6 | ||
|
a79a91ecb0 | ||
|
779cceacf2 | ||
|
94fd0c6188 | ||
|
09224e6f24 | ||
|
0ed03e9433 | ||
|
76d11d83f7 | ||
|
6b43c38cc2 | ||
|
7687f10b7e | ||
|
9c28a11320 | ||
|
5162000e25 | ||
|
3b5100acee | ||
|
3332d5ecf6 | ||
|
e4ef267637 | ||
|
97904d2cd4 | ||
|
d3e1c79a4b | ||
|
5ebd2ea881 | ||
|
f3f3789b87 | ||
|
ee244ff0d2 | ||
|
9b3d2e8698 | ||
|
8b3969c26e | ||
|
e824bc815e | ||
|
938595f86a | ||
|
26ba1538e9 | ||
|
6380e94fb8 | ||
|
02595d6b0d | ||
|
732b9a5bdc | ||
|
59246e7b70 | ||
|
4e462de87a | ||
|
24a917c28b | ||
|
f46cd5f52c | ||
|
0544def9e5 | ||
|
4c97551ff9 | ||
|
659cfde44d | ||
|
a47f339bf0 | ||
|
69789283f6 | ||
|
9ae6f21603 | ||
|
65cfa0f305 | ||
|
63bbd5cfe8 | ||
|
55195469d8 | ||
|
891dbb4db5 | ||
|
a3275adfd1 | ||
|
6030502288 | ||
|
a2460e1225 | ||
|
e972c6d280 | ||
|
b9b6f667f9 | ||
|
77960edc2d | ||
|
39abbfc540 | ||
|
986d33308d | ||
|
d9a6b1072c | ||
|
042e1e1eba | ||
|
11dae87bc1 | ||
|
4265a040ec | ||
|
00667606d8 | ||
|
712a67c555 | ||
|
b9bcde093b | ||
|
aa8ada68d9 | ||
|
9f42245de1 | ||
|
904207e48a | ||
|
204c7fc384 | ||
|
e4b8ab2d33 | ||
|
c6f8f3cf7c | ||
|
65f3590a5a | ||
|
dbbbc08d5a | ||
|
1ae58a7299 | ||
|
b9ef00e6a0 | ||
|
d6858ddbd8 | ||
|
318e773df9 | ||
|
c4eb68a160 | ||
|
eccddab276 | ||
|
3d1275371d | ||
|
237b9d31a1 | ||
|
5bd3b79040 | ||
|
795ce100de | ||
|
45b211f397 | ||
|
731be37845 | ||
|
bbd51f3c06 | ||
|
660fa112e2 | ||
|
0c5e23b84c | ||
|
bdb5a3e711 | ||
|
a9c3d59b47 | ||
|
643bf012d8 | ||
|
fc4655a0c3 | ||
|
8cf753da8f | ||
|
2900455700 | ||
|
b0a6108c93 | ||
|
5c9e5584da | ||
|
c3271c33e6 | ||
|
0c7d6f9290 | ||
|
22943577fc | ||
|
50277cf657 | ||
|
ba204ebfd7 | ||
|
331bd34cde | ||
|
2143291075 | ||
|
8a771df290 | ||
|
006fa4862a | ||
|
532d23973e | ||
|
f90f690bba | ||
|
9470957639 | ||
|
15e7859e66 | ||
|
ac715e9173 | ||
|
32e9e5a161 | ||
|
3afb8c0805 | ||
|
3638cd6d1d | ||
|
10ad738755 | ||
|
1f519c50fa | ||
|
3a3fe992ff | ||
|
115b60325d | ||
|
cc586965be | ||
|
a04337ee2c | ||
|
fe23e9d874 | ||
|
90d0c7961d | ||
|
a188c5114b | ||
|
900f1b41ea | ||
|
f4e4cdd4e7 | ||
|
20b3504b94 | ||
|
157ad23dd8 | ||
|
f6929fa7de | ||
|
7b5744baf2 | ||
|
8e49af85e0 | ||
|
ffa56e0882 | ||
|
e05e478921 | ||
|
d05a6dc07c | ||
|
7860f187ae | ||
|
653c723d31 | ||
|
81d43c131e | ||
|
a0fa965527 | ||
|
93ac2714c3 | ||
|
b84cf3638c | ||
|
19236a19fe | ||
|
1e401484ce | ||
|
76f1a33817 | ||
|
468bb3325f | ||
|
4041f15f74 | ||
|
193992a399 | ||
|
93a3d5207e | ||
|
51450dfdd3 | ||
|
e48aafd458 | ||
|
016bdd3529 | ||
|
fb77a975db | ||
|
b49bae58b5 | ||
|
c5444b9d39 | ||
|
99875a8c9d | ||
|
78e314d178 | ||
|
a37e5efb6d | ||
|
eb9625a542 | ||
|
8a366d614e | ||
|
0c8256b24d | ||
|
dd4a406040 | ||
|
390dec131f | ||
|
3e34e20e2c | ||
|
74dd8d07f6 | ||
|
ed9086dbdc | ||
|
4ad9374761 | ||
|
69b3954a4a | ||
|
3085c8a1ba | ||
|
cf00132efc | ||
|
2777978114 | ||
|
2c451d125f | ||
|
a99f7945d9 | ||
|
c644253f40 | ||
|
467a200c6d | ||
|
1652cb7ded | ||
|
3c1f692bc1 | ||
|
0377b162ed | ||
|
69671395ec | ||
|
cd96e66c45 | ||
|
6aed841b9f | ||
|
957bba58dc | ||
|
9fe80e4f29 | ||
|
6ea4c7f184 | ||
|
d3b69fd97d | ||
|
0d6b5aaf12 | ||
|
70dbd64aff | ||
|
1e6b53615f | ||
|
3d409916be | ||
|
ddd2972b9c | ||
|
2642d15f4f | ||
|
1ef8703991 | ||
|
bd4ff2f87e | ||
|
ea68dea83f | ||
|
3e63f187e8 | ||
|
5720ff906c | ||
|
55a33d627d | ||
|
6db2364ca3 | ||
|
d55a9c17a0 | ||
|
608a3b6bf5 | ||
|
f217d922a1 | ||
|
2ff969d3c1 | ||
|
805253491d | ||
|
8df8c6a100 | ||
|
ed97e52c60 | ||
|
9e55b47f77 | ||
|
f1cfe2459b | ||
|
1baef885d2 | ||
|
88e351f18c | ||
|
b5b4f1a766 | ||
|
f4479bb2f8 | ||
|
7e21c7b379 | ||
|
22eabd165d | ||
|
941fd93653 | ||
|
100c62f39b | ||
|
ddc5229136 | ||
|
8198c5462b | ||
|
81682ac2a2 | ||
|
1e7917041d | ||
|
28115f3506 | ||
|
d4c62e8572 | ||
|
85f30d7ce7 | ||
|
1bd8f4c880 | ||
|
4e997fa794 | ||
|
d083995b51 | ||
|
0e72f7a4cf | ||
|
1d1c4e01d6 | ||
|
ad46df61a3 | ||
|
2df933dc95 | ||
|
446efb8696 | ||
|
6eb1861d1b | ||
|
2700eab46b | ||
|
28dd40561f | ||
|
95126cfa57 | ||
|
eace07ed9a | ||
|
a735144a55 | ||
|
a7beb7b37f | ||
|
695e360d07 | ||
|
04038b5b0d | ||
|
7b04e8dc4c | ||
|
071e9733d2 | ||
|
d8e5542aa4 | ||
|
adb90e2a08 | ||
|
f5e3262534 | ||
|
b64843c6c2 | ||
|
13116f2334 | ||
|
e84b0ec131 | ||
|
2b6e83c8fc | ||
|
b589bc9b15 | ||
|
0a1ef9140c | ||
|
67267961a1 | ||
|
5ae03396e0 | ||
|
38b2d25f87 | ||
|
f8d1d15afb | ||
|
c1d28331a4 | ||
|
37a475afd1 | ||
|
c060932749 | ||
|
0ce98074da | ||
|
be65bb6321 | ||
|
8ff7c26ee1 | ||
|
d4932dcc89 | ||
|
fa1a142529 | ||
|
65b495b841 | ||
|
13adfa1031 | ||
|
68e24d31a5 | ||
|
af922219eb | ||
|
d92dead1bd | ||
|
08fba83271 | ||
|
9e4aa30e3a | ||
|
c4cb47a88c | ||
|
237d8e6611 | ||
|
ccebfd54fe | ||
|
0c4955603e | ||
|
045f1d1576 | ||
|
b96bfbff13 |
11
.dockerignore
Normal file
11
.dockerignore
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
node_modules
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.dockerignore
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
.prettierrc.json
|
||||||
|
.env.local
|
||||||
|
.next
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
README.md
|
41
.env.sample
Normal file
41
.env.sample
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
## Required variables section ##
|
||||||
|
|
||||||
|
# Host port mappings
|
||||||
|
WEB_SERVER_PORT=3000
|
||||||
|
SSH_SERVER_PORT=2222
|
||||||
|
|
||||||
|
# Hostname and URL
|
||||||
|
FQDN=your.domain.com
|
||||||
|
NEXTAUTH_URL=https://your.domain.com
|
||||||
|
|
||||||
|
# Secrects
|
||||||
|
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
|
||||||
|
# If you want to use a different user than 1001:1001, you must rebuild the image yourself.
|
||||||
|
UID=1001
|
||||||
|
GID=1001
|
||||||
|
|
||||||
|
# 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
|
||||||
|
TMP_PATH=./tmp
|
||||||
|
LOGS_PATH=./logs
|
||||||
|
|
||||||
|
## 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=
|
13
.github/FUNDING.yml
vendored
Normal file
13
.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: [Ravinou]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: R4VEN
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
16
.github/dependabot.yml
vendored
Normal file
16
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "docker"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
# Maintain dependencies for GitHub Actions
|
||||||
|
# src: https://github.com/marketplace/actions/build-and-push-docker-images#keep-up-to-date-with-github-dependabot
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
29
.github/workflows/docker-image-develop.yml
vendored
Normal file
29
.github/workflows/docker-image-develop.yml
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
name: Build and Push Docker Image for Develop Branch
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'develop'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64 # linux/arm/v7 arm32 is not supported by node20 https://github.com/nodejs/docker-node/issues/1946
|
||||||
|
tags: borgwarehouse/borgwarehouse:develop
|
29
.github/workflows/docker-image-latest.yml
vendored
Normal file
29
.github/workflows/docker-image-latest.yml
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64 # linux/arm/v7 arm32 is not supported by node20 https://github.com/nodejs/docker-node/issues/1946
|
||||||
|
tags: borgwarehouse/borgwarehouse:latest
|
32
.github/workflows/docker-image-release.yml
vendored
Normal file
32
.github/workflows/docker-image-release.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
name: Build and Push Docker Image on Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Get Release Tag
|
||||||
|
id: get_release_tag
|
||||||
|
run: echo "::set-output name=TAG::${{ github.event.release.tag_name }}"
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64 # linux/arm/v7 arm32 is not supported by node20 https://github.com/nodejs/docker-node/issues/1946
|
||||||
|
tags: borgwarehouse/borgwarehouse:${{ steps.get_release_tag.outputs.TAG }}
|
21
.github/workflows/docker-image-test.yml
vendored
Normal file
21
.github/workflows/docker-image-test.yml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
name: Test Docker Container Build on Pull Request
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-container:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Build Docker Container
|
||||||
|
run: |
|
||||||
|
docker buildx build --platform linux/amd64,linux/arm64 -t borgwarehouse:pr-${{ github.event.pull_request.number }} .
|
23
.github/workflows/shellcheck.yml
vendored
Normal file
23
.github/workflows/shellcheck.yml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
pull_request:
|
||||||
|
branches: main
|
||||||
|
|
||||||
|
name: "Shellcheck"
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
name: Shellcheck
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Run ShellCheck
|
||||||
|
uses: ludeeus/action-shellcheck@master
|
||||||
|
env:
|
||||||
|
SHELLCHECK_OPTS: -e SC1091
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -109,3 +109,6 @@ dist
|
||||||
# config file for BorgWarehouse
|
# config file for BorgWarehouse
|
||||||
config/repo.json
|
config/repo.json
|
||||||
config/users.json
|
config/users.json
|
||||||
|
|
||||||
|
# docker files
|
||||||
|
docker-compose.yml
|
|
@ -1,5 +1,7 @@
|
||||||
|
# Run test against shells with "pre-commit run shellcheck --all-files"
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||||
rev: 3.0.0
|
rev: 3.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: shellcheck
|
- id: shellcheck
|
||||||
|
files: helpers/shells/
|
||||||
|
|
21
.prettierrc.json
Normal file
21
.prettierrc.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"tabWidth": 4,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"endOfLine": "lf",
|
||||||
|
"htmlWhitespaceSensitivity": "css",
|
||||||
|
"insertPragma": false,
|
||||||
|
"singleAttributePerLine": false,
|
||||||
|
"bracketSameLine": false,
|
||||||
|
"jsxBracketSameLine": false,
|
||||||
|
"jsxSingleQuote": true,
|
||||||
|
"printWidth": 80,
|
||||||
|
"proseWrap": "preserve",
|
||||||
|
"quoteProps": "as-needed",
|
||||||
|
"requirePragma": false,
|
||||||
|
"useTabs": false,
|
||||||
|
"embeddedLanguageFormatting": "auto"
|
||||||
|
}
|
|
@ -6,19 +6,20 @@ import { IconSettingsAutomation, IconCopy } from '@tabler/icons-react';
|
||||||
|
|
||||||
export default function QuickCommands(props) {
|
export default function QuickCommands(props) {
|
||||||
////Vars
|
////Vars
|
||||||
|
const wizardEnv = props.wizardEnv;
|
||||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||||
let HOSTNAME;
|
let FQDN;
|
||||||
let SSH_SERVER_PORT;
|
let SSH_SERVER_PORT;
|
||||||
if (
|
if (
|
||||||
props.lanCommand &&
|
props.lanCommand &&
|
||||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
wizardEnv.FQDN_LAN &&
|
||||||
process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN
|
wizardEnv.SSH_SERVER_PORT_LAN
|
||||||
) {
|
) {
|
||||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME_LAN;
|
FQDN = wizardEnv.FQDN_LAN;
|
||||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN;
|
SSH_SERVER_PORT = wizardEnv.SSH_SERVER_PORT_LAN;
|
||||||
} else {
|
} else {
|
||||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME;
|
FQDN = wizardEnv.FQDN;
|
||||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT;
|
SSH_SERVER_PORT = wizardEnv.SSH_SERVER_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//State
|
//State
|
||||||
|
@ -29,7 +30,7 @@ export default function QuickCommands(props) {
|
||||||
// Asynchronously call copy to clipboard
|
// Asynchronously call copy to clipboard
|
||||||
navigator.clipboard
|
navigator.clipboard
|
||||||
.writeText(
|
.writeText(
|
||||||
`borg init -e repokey-blake2 ssh://${props.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.repository}`
|
`ssh://${wizardEnv.UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.repositoryName}`
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// If successful, update the isCopied state value
|
// If successful, update the isCopied state value
|
||||||
|
@ -49,11 +50,13 @@ export default function QuickCommands(props) {
|
||||||
<div className={classes.copyValid}>Copied !</div>
|
<div className={classes.copyValid}>Copied !</div>
|
||||||
) : (
|
) : (
|
||||||
<div className={classes.tooltip}>
|
<div className={classes.tooltip}>
|
||||||
borg init -e repokey-blake2 ssh://{props.unixUser}@
|
ssh://{wizardEnv.UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||||
{HOSTNAME}:{SSH_SERVER_PORT}/./
|
{props.repositoryName}
|
||||||
{props.repository}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{props.lanCommand && <div className={classes.lanBadge}>LAN</div>}
|
||||||
|
|
||||||
<div className={classes.icons}>
|
<div className={classes.icons}>
|
||||||
<button onClick={handleCopy} className={classes.copyButton}>
|
<button onClick={handleCopy} className={classes.copyButton}>
|
||||||
<IconCopy color='#65748b' stroke={1.25} />
|
<IconCopy color='#65748b' stroke={1.25} />
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
.icons {
|
.icons {
|
||||||
position: relative;
|
position: relative;
|
||||||
bottom: 14px;
|
bottom: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quickSetting {
|
.quickSetting {
|
||||||
|
@ -16,6 +16,15 @@
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lanBadge {
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #6d4aff;
|
||||||
|
color: #6d4aff;
|
||||||
|
font-size: 0.9em;
|
||||||
|
padding: 2px 5px;
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.tooltip {
|
.tooltip {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
@ -91,6 +100,15 @@
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container:hover .lanBadge {
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
@media all and (max-width: 1000px) {
|
@media all and (max-width: 1000px) {
|
||||||
.container {
|
.container {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -1,28 +1,98 @@
|
||||||
//Lib
|
//Lib
|
||||||
import React from 'react';
|
import { useState } from 'react';
|
||||||
import classes from './Repo.module.css';
|
import classes from './Repo.module.css';
|
||||||
import { IconSettings, IconInfoCircle } from '@tabler/icons-react';
|
import {
|
||||||
|
IconSettings,
|
||||||
|
IconInfoCircle,
|
||||||
|
IconChevronDown,
|
||||||
|
IconChevronUp,
|
||||||
|
IconBellOff,
|
||||||
|
IconLockPlus,
|
||||||
|
} from '@tabler/icons-react';
|
||||||
import timestampConverter from '../../helpers/functions/timestampConverter';
|
import timestampConverter from '../../helpers/functions/timestampConverter';
|
||||||
import StorageBar from '../UI/StorageBar/StorageBar';
|
import StorageBar from '../UI/StorageBar/StorageBar';
|
||||||
import QuickCommands from './QuickCommands/QuickCommands';
|
import QuickCommands from './QuickCommands/QuickCommands';
|
||||||
|
|
||||||
export default function Repo(props) {
|
export default function Repo(props) {
|
||||||
|
//Load displayDetails from LocalStorage
|
||||||
|
const displayDetailsFromLS = () => {
|
||||||
|
try {
|
||||||
|
if (
|
||||||
|
localStorage.getItem('displayDetailsRepo' + props.id) === null
|
||||||
|
) {
|
||||||
|
localStorage.setItem(
|
||||||
|
'displayDetailsRepo' + props.id,
|
||||||
|
JSON.stringify(true)
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return JSON.parse(
|
||||||
|
localStorage.getItem('displayDetailsRepo' + props.id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(
|
||||||
|
'LocalStorage error, key',
|
||||||
|
'displayDetailsRepo' + props.id,
|
||||||
|
'will be removed. Try again.',
|
||||||
|
'Error message on this key : ',
|
||||||
|
error
|
||||||
|
);
|
||||||
|
localStorage.removeItem('displayDetailsRepo' + props.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//States
|
||||||
|
const [displayDetails, setDisplayDetails] = useState(displayDetailsFromLS);
|
||||||
|
|
||||||
|
//BUTTON : Display or not repo details for ONE repo
|
||||||
|
const displayDetailsForOneHandler = (boolean) => {
|
||||||
|
//Update localStorage
|
||||||
|
localStorage.setItem(
|
||||||
|
'displayDetailsRepo' + props.id,
|
||||||
|
JSON.stringify(boolean)
|
||||||
|
);
|
||||||
|
setDisplayDetails(boolean);
|
||||||
|
};
|
||||||
|
|
||||||
|
//Status indicator
|
||||||
|
const statusIndicator = () => {
|
||||||
|
return props.status
|
||||||
|
? classes.statusIndicatorGreen
|
||||||
|
: classes.statusIndicatorRed;
|
||||||
|
};
|
||||||
|
|
||||||
|
//Alert indicator
|
||||||
|
const alertIndicator = () => {
|
||||||
|
if (props.alert === 0) {
|
||||||
|
return (
|
||||||
|
<div className={classes.alertIcon}>
|
||||||
|
<IconBellOff size={16} color='grey' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const appendOnlyModeIndicator = () => {
|
||||||
|
if (props.appendOnlyMode) {
|
||||||
|
return (
|
||||||
|
<div className={classes.appendOnlyModeIcon}>
|
||||||
|
<IconLockPlus size={16} color='grey' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{props.displayDetails ? (
|
{displayDetails ? (
|
||||||
<>
|
<>
|
||||||
<div className={classes.RepoOpen}>
|
<div className={classes.RepoOpen}>
|
||||||
<div className={classes.openFlex}>
|
<div className={classes.openFlex}>
|
||||||
{props.status ? (
|
<div className={statusIndicator()} />
|
||||||
<div
|
|
||||||
className={classes.statusIndicatorGreen}
|
|
||||||
></div>
|
|
||||||
) : (
|
|
||||||
<div
|
|
||||||
className={classes.statusIndicatorRed}
|
|
||||||
></div>
|
|
||||||
)}
|
|
||||||
<div className={classes.alias}>{props.alias}</div>
|
<div className={classes.alias}>{props.alias}</div>
|
||||||
|
{appendOnlyModeIndicator()}
|
||||||
|
{alertIndicator()}
|
||||||
{props.comment && (
|
{props.comment && (
|
||||||
<div className={classes.comment}>
|
<div className={classes.comment}>
|
||||||
<IconInfoCircle size={16} color='grey' />
|
<IconInfoCircle size={16} color='grey' />
|
||||||
|
@ -32,9 +102,9 @@ export default function Repo(props) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<QuickCommands
|
<QuickCommands
|
||||||
unixUser={props.unixUser}
|
repositoryName={props.repositoryName}
|
||||||
repository={props.repository}
|
|
||||||
lanCommand={props.lanCommand}
|
lanCommand={props.lanCommand}
|
||||||
|
wizardEnv={props.wizardEnv}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -57,8 +127,8 @@ export default function Repo(props) {
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{props.repository}</th>
|
<th>{props.repositoryName}</th>
|
||||||
<th>{props.storageSize}Go</th>
|
<th>{props.storageSize} GB</th>
|
||||||
<th style={{ padding: '0 4% 0 4%' }}>
|
<th style={{ padding: '0 4% 0 4%' }}>
|
||||||
<StorageBar
|
<StorageBar
|
||||||
storageUsed={props.storageUsed}
|
storageUsed={props.storageUsed}
|
||||||
|
@ -95,16 +165,10 @@ export default function Repo(props) {
|
||||||
<>
|
<>
|
||||||
<div className={classes.RepoClose}>
|
<div className={classes.RepoClose}>
|
||||||
<div className={classes.closeFlex}>
|
<div className={classes.closeFlex}>
|
||||||
{props.status ? (
|
<div className={statusIndicator()} />
|
||||||
<div
|
|
||||||
className={classes.statusIndicatorGreen}
|
|
||||||
></div>
|
|
||||||
) : (
|
|
||||||
<div
|
|
||||||
className={classes.statusIndicatorRed}
|
|
||||||
></div>
|
|
||||||
)}
|
|
||||||
<div className={classes.alias}>{props.alias}</div>
|
<div className={classes.alias}>{props.alias}</div>
|
||||||
|
{appendOnlyModeIndicator()}
|
||||||
|
{alertIndicator()}
|
||||||
{props.comment && (
|
{props.comment && (
|
||||||
<div className={classes.comment}>
|
<div className={classes.comment}>
|
||||||
<IconInfoCircle size={16} color='#637381' />
|
<IconInfoCircle size={16} color='#637381' />
|
||||||
|
@ -127,6 +191,27 @@ export default function Repo(props) {
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{displayDetails ? (
|
||||||
|
<div className={classes.chevron}>
|
||||||
|
<IconChevronUp
|
||||||
|
color='#494b7a'
|
||||||
|
size={28}
|
||||||
|
onClick={() => {
|
||||||
|
displayDetailsForOneHandler(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className={classes.chevron}>
|
||||||
|
<IconChevronDown
|
||||||
|
color='#494b7a'
|
||||||
|
size={28}
|
||||||
|
onClick={() => {
|
||||||
|
displayDetailsForOneHandler(true);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
box-shadow:
|
||||||
|
0 1px 3px rgba(0, 0, 0, 0.12),
|
||||||
|
0 1px 2px rgba(0, 0, 0, 0.24);
|
||||||
width: auto;
|
width: auto;
|
||||||
max-height: 65px;
|
max-height: 65px;
|
||||||
margin: 20px 0px 0px 0px;
|
margin: 20px 0px 0px 0px;
|
||||||
|
@ -29,13 +31,15 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
box-shadow:
|
||||||
|
0 1px 3px rgba(0, 0, 0, 0.12),
|
||||||
|
0 1px 2px rgba(0, 0, 0, 0.24);
|
||||||
width: auto;
|
width: auto;
|
||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
margin: 20px 0px 0px 0px;
|
margin: 20px 0px 0px 0px;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
transition: max-height 0.2s linear;
|
transition: max-height 0.1s linear;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
/* Need to display comment on hover (which is position : absolute) */
|
/* Need to display comment on hover (which is position : absolute) */
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -144,6 +148,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Alert icon */
|
||||||
|
|
||||||
|
.alertIcon {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appendOnlyModeIcon {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* GENERAL */
|
/* GENERAL */
|
||||||
.alias {
|
.alias {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -183,7 +203,9 @@
|
||||||
margin: 0px 0 0 20px;
|
margin: 0px 0 0 20px;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transition: 0.5s opacity;
|
transition: 0.5s opacity;
|
||||||
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
|
box-shadow:
|
||||||
|
0 3px 6px rgba(0, 0, 0, 0.16),
|
||||||
|
0 3px 6px rgba(0, 0, 0, 0.23);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +215,17 @@
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chevron {
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chevron :focus,
|
||||||
|
.chevron :hover {
|
||||||
|
cursor: pointer;
|
||||||
|
filter: invert(27%) sepia(82%) saturate(2209%) hue-rotate(240deg)
|
||||||
|
brightness(99%) contrast(105%);
|
||||||
|
}
|
||||||
|
|
||||||
/* MOBILE */
|
/* MOBILE */
|
||||||
@media all and (max-width: 1000px) {
|
@media all and (max-width: 1000px) {
|
||||||
.tabInfo {
|
.tabInfo {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//Lib
|
//Lib
|
||||||
import classes from './Footer.module.css';
|
import classes from './Footer.module.css';
|
||||||
|
import packageInfo from '../../../../package.json';
|
||||||
|
|
||||||
function Footer() {
|
function Footer() {
|
||||||
return (
|
return (
|
||||||
|
@ -13,7 +14,8 @@ function Footer() {
|
||||||
rel='noreferrer'
|
rel='noreferrer'
|
||||||
>
|
>
|
||||||
BorgWarehouse
|
BorgWarehouse
|
||||||
</a>
|
</a>{' '}
|
||||||
|
- v{packageInfo.version}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,20 @@
|
||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footer p {
|
||||||
|
padding-left: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
a.site {
|
a.site {
|
||||||
color: #6d4aff;
|
color: #6d4aff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 1000px) {
|
||||||
|
.footer {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.footer p {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
//Lib
|
//Lib
|
||||||
import classes from "./Header.module.css";
|
import classes from './Header.module.css';
|
||||||
|
|
||||||
//Components
|
//Components
|
||||||
import Nav from "./Nav/Nav";
|
import Nav from './Nav/Nav';
|
||||||
|
|
||||||
function Header() {
|
function Header() {
|
||||||
return (
|
return (
|
||||||
<header className={classes.Header}>
|
<header className={classes.Header}>
|
||||||
<div className={[classes.flex, 'container'].join(' ')}>
|
<div className={[classes.flex, 'container'].join(' ')}>
|
||||||
<div className={classes.logo}>
|
<div className={classes.logo}>BorgWarehouse</div>
|
||||||
BorgWarehouse
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<Nav />
|
<Nav />
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Header;
|
export default Header;
|
|
@ -1,7 +1,9 @@
|
||||||
.Header {
|
.Header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: #111827;
|
background: #111827;
|
||||||
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
|
box-shadow:
|
||||||
|
0 3px 6px rgba(0, 0, 0, 0.16),
|
||||||
|
0 3px 6px rgba(0, 0, 0, 0.23);
|
||||||
height: 50px;
|
height: 50px;
|
||||||
color: white;
|
color: white;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default function Nav() {
|
||||||
<div>
|
<div>
|
||||||
<IconUser size={28} />
|
<IconUser size={28} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className={classes.username}>
|
||||||
{status === 'authenticated' && data.user.name}
|
{status === 'authenticated' && data.user.name}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.username::first-letter {
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
.account {
|
.account {
|
||||||
background: none;
|
background: none;
|
||||||
border: none;
|
border: none;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import classes from './StorageBar.module.css';
|
||||||
|
|
||||||
export default function StorageBar(props) {
|
export default function StorageBar(props) {
|
||||||
//Var
|
//Var
|
||||||
//storageUsed is in octet, storageSize is in Go. Round to 1 decimal for %.
|
//storageUsed is in octet, storageSize is in GB. Round to 1 decimal for %.
|
||||||
const storageUsedPercent = (
|
const storageUsedPercent = (
|
||||||
((props.storageUsed / 1000000) * 100) /
|
((props.storageUsed / 1000000) * 100) /
|
||||||
props.storageSize
|
props.storageSize
|
||||||
|
@ -23,8 +23,8 @@ export default function StorageBar(props) {
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.tooltip}>
|
<div className={classes.tooltip}>
|
||||||
{storageUsedPercent}% (
|
{storageUsedPercent}% (
|
||||||
{(props.storageUsed / 1000000).toFixed(1)}Go/
|
{(props.storageUsed / 1000000).toFixed(1)} GB /{' '}
|
||||||
{props.storageSize}Go)
|
{props.storageSize} GB)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -51,7 +51,9 @@
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
transition: opacity 0.3s 0.1s, transform 0.2s 0.1s;
|
transition:
|
||||||
|
opacity 0.3s 0.1s,
|
||||||
|
transform 0.2s 0.1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Span */
|
/* Span */
|
||||||
|
@ -75,7 +77,9 @@
|
||||||
height: 14px;
|
height: 14px;
|
||||||
background-color: rgba(var(--pure-material-onsurface-rgb, 0, 0, 0), 0.38);
|
background-color: rgba(var(--pure-material-onsurface-rgb, 0, 0, 0), 0.38);
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
transition: background-color 0.2s, opacity 0.2s;
|
transition:
|
||||||
|
background-color 0.2s,
|
||||||
|
opacity 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Thumb */
|
/* Thumb */
|
||||||
|
@ -88,9 +92,13 @@
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
background-color: rgb(var(--pure-material-onprimary-rgb, 255, 255, 255));
|
background-color: rgb(var(--pure-material-onprimary-rgb, 255, 255, 255));
|
||||||
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2),
|
box-shadow:
|
||||||
0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
0 3px 1px -2px rgba(0, 0, 0, 0.2),
|
||||||
transition: background-color 0.2s, transform 0.2s;
|
0 2px 2px 0 rgba(0, 0, 0, 0.14),
|
||||||
|
0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
||||||
|
transition:
|
||||||
|
background-color 0.2s,
|
||||||
|
transform 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checked */
|
/* Checked */
|
||||||
|
@ -112,7 +120,9 @@
|
||||||
.pureMaterialSwitch > input:active {
|
.pureMaterialSwitch > input:active {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: scale(0);
|
transform: scale(0);
|
||||||
transition: transform 0s, opacity 0s;
|
transition:
|
||||||
|
transform 0s,
|
||||||
|
opacity 0s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pureMaterialSwitch > input:active + span::before {
|
.pureMaterialSwitch > input:active + span::before {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
.container {
|
.container {
|
||||||
margin: 40px 20px 20px 5px;
|
margin: 40px 20px 20px 5px;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
box-shadow:
|
||||||
|
0 1px 3px rgba(0, 0, 0, 0.12),
|
||||||
|
0 1px 2px rgba(0, 0, 0, 0.24);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 30px 70px;
|
padding: 30px 70px;
|
||||||
|
@ -54,8 +56,15 @@ h1 .icon {
|
||||||
.code {
|
.code {
|
||||||
background-color: #111827;
|
background-color: #111827;
|
||||||
color: #f8f8f2;
|
color: #f8f8f2;
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
font-family:
|
||||||
liberation mono, courier new, monospace;
|
ui-monospace,
|
||||||
|
SFMono-Regular,
|
||||||
|
Menlo,
|
||||||
|
Monaco,
|
||||||
|
Consolas,
|
||||||
|
liberation mono,
|
||||||
|
courier new,
|
||||||
|
monospace;
|
||||||
padding: 5px 15px;
|
padding: 5px 15px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -91,8 +100,15 @@ h1 .icon {
|
||||||
|
|
||||||
.verifyOrange li .sshPublicKey {
|
.verifyOrange li .sshPublicKey {
|
||||||
background-color: #282a36;
|
background-color: #282a36;
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
font-family:
|
||||||
liberation mono, courier new, monospace;
|
ui-monospace,
|
||||||
|
SFMono-Regular,
|
||||||
|
Menlo,
|
||||||
|
Monaco,
|
||||||
|
Consolas,
|
||||||
|
liberation mono,
|
||||||
|
courier new,
|
||||||
|
monospace;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,23 +3,17 @@ import React from 'react';
|
||||||
import classes from '../WizardStep1/WizardStep1.module.css';
|
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||||
import { IconTool, IconAlertCircle } from '@tabler/icons-react';
|
import { IconTool, IconAlertCircle } from '@tabler/icons-react';
|
||||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||||
|
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||||
|
|
||||||
function WizardStep2(props) {
|
function WizardStep2(props) {
|
||||||
////Vars
|
////Vars
|
||||||
|
const wizardEnv = props.wizardEnv;
|
||||||
|
const UNIX_USER = wizardEnv.UNIX_USER;
|
||||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||||
let HOSTNAME;
|
const { FQDN, SSH_SERVER_PORT } = lanCommandOption(
|
||||||
let SSH_SERVER_PORT;
|
wizardEnv,
|
||||||
if (
|
props.selectedOption.lanCommand
|
||||||
props.selectedOption.lanCommand &&
|
);
|
||||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
|
||||||
process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN
|
|
||||||
) {
|
|
||||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME_LAN;
|
|
||||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN;
|
|
||||||
} else {
|
|
||||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME;
|
|
||||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
|
@ -39,12 +33,11 @@ function WizardStep2(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg init -e repokey-blake2 ssh://
|
borg init -e repokey-blake2 ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
{props.selectedOption.repositoryName}
|
||||||
{props.selectedOption.repository}
|
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg init -e repokey-blake2 ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}`}
|
dataToCopy={`borg init -e repokey-blake2 ssh://${UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.note}>
|
<div className={classes.note}>
|
||||||
|
@ -64,7 +57,7 @@ function WizardStep2(props) {
|
||||||
<div className={classes.separator}></div>
|
<div className={classes.separator}></div>
|
||||||
<h2>Borgmatic</h2>
|
<h2>Borgmatic</h2>
|
||||||
<div className={classes.description}>
|
<div className={classes.description}>
|
||||||
If you are using Borgmatic and have <b>already edited</b> the
|
If you are using Borgmatic and have <b>already edited</b> the configuration file
|
||||||
(find a sample on the step 4) :
|
(find a sample on the step 4) :
|
||||||
<br />
|
<br />
|
||||||
<div
|
<div
|
||||||
|
@ -75,9 +68,9 @@ function WizardStep2(props) {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg init -e repokey-blake2
|
borgmatic init -e repokey-blake2
|
||||||
</div>
|
</div>
|
||||||
<CopyButton dataToCopy='borg init -e repokey-blake2' />
|
<CopyButton dataToCopy='borgmatic init -e repokey-blake2' />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -95,12 +88,11 @@ function WizardStep2(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
ssh://
|
ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
{props.selectedOption.repositoryName}
|
||||||
{props.selectedOption.repository}
|
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}`}
|
dataToCopy={`ssh://${UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
For more information about the Vorta graphical client, please
|
For more information about the Vorta graphical client, please
|
||||||
|
@ -122,24 +114,21 @@ function WizardStep2(props) {
|
||||||
<b>Check the fingerprint of server</b>
|
<b>Check the fingerprint of server</b>
|
||||||
</div>
|
</div>
|
||||||
To check that you are talking to the right server, please make
|
To check that you are talking to the right server, please make
|
||||||
sure to validate the following sshPublicKeys when you first
|
sure to validate one of the following key's fingerprint when you
|
||||||
connect :
|
first connect :
|
||||||
<li>
|
<li>
|
||||||
<span className={classes.sshPublicKey}>
|
<span className={classes.sshPublicKey}>
|
||||||
ECDSA :{' '}
|
ECDSA : {wizardEnv.SSH_SERVER_FINGERPRINT_ECDSA}
|
||||||
{process.env.NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_ECDSA}
|
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span className={classes.sshPublicKey}>
|
<span className={classes.sshPublicKey}>
|
||||||
ED25519 :{' '}
|
ED25519 : {wizardEnv.SSH_SERVER_FINGERPRINT_ED25519}
|
||||||
{process.env.NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_ED25519}
|
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span className={classes.sshPublicKey}>
|
<span className={classes.sshPublicKey}>
|
||||||
RSA :{' '}
|
RSA : {wizardEnv.SSH_SERVER_FINGERPRINT_RSA}
|
||||||
{process.env.NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_RSA}
|
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,23 +3,17 @@ import React from 'react';
|
||||||
import classes from '../WizardStep1/WizardStep1.module.css';
|
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||||
import { IconChecks, IconPlayerPlay } from '@tabler/icons-react';
|
import { IconChecks, IconPlayerPlay } from '@tabler/icons-react';
|
||||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||||
|
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||||
|
|
||||||
function WizardStep3(props) {
|
function WizardStep3(props) {
|
||||||
////Vars
|
////Vars
|
||||||
|
const wizardEnv = props.wizardEnv;
|
||||||
|
const UNIX_USER = wizardEnv.UNIX_USER;
|
||||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||||
let HOSTNAME;
|
const { FQDN, SSH_SERVER_PORT } = lanCommandOption(
|
||||||
let SSH_SERVER_PORT;
|
wizardEnv,
|
||||||
if (
|
props.selectedOption.lanCommand
|
||||||
props.selectedOption.lanCommand &&
|
);
|
||||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
|
||||||
process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN
|
|
||||||
) {
|
|
||||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME_LAN;
|
|
||||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN;
|
|
||||||
} else {
|
|
||||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME;
|
|
||||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
|
@ -38,13 +32,12 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg create ssh://
|
borg create ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
{props.selectedOption.repositoryName}
|
||||||
{props.selectedOption.repository}
|
|
||||||
::archive1 /your/pathToBackup
|
::archive1 /your/pathToBackup
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg create ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}::archive1 /your/pathToBackup`}
|
dataToCopy={`borg create ssh://${UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}::archive1 /your/pathToBackup`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -85,12 +78,11 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg check -v --progress ssh://
|
borg check -v --progress ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
{props.selectedOption.repositoryName}
|
||||||
{props.selectedOption.repository}
|
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg check -v --progress ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}`}
|
dataToCopy={`borg check -v --progress ssh://${UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<li>List the remote archives with :</li>
|
<li>List the remote archives with :</li>
|
||||||
|
@ -103,12 +95,11 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg list ssh://
|
borg list ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
{props.selectedOption.repositoryName}
|
||||||
{props.selectedOption.repository}
|
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg list ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}`}
|
dataToCopy={`borg list ssh://${UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<li>Download a remote archive with the following command :</li>
|
<li>Download a remote archive with the following command :</li>
|
||||||
|
@ -121,13 +112,12 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg export-tar --tar-filter="gzip -9" ssh://
|
borg export-tar --tar-filter="gzip -9" ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
{props.selectedOption.repositoryName}
|
||||||
{props.selectedOption.repository}
|
|
||||||
::archive1 archive1.tar.gz
|
::archive1 archive1.tar.gz
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg export-tar --tar-filter="gzip -9" ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}::archive1 archive1.tar.gz`}
|
dataToCopy={`borg export-tar --tar-filter="gzip -9" ssh://${UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}::archive1 archive1.tar.gz`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<li>
|
<li>
|
||||||
|
@ -143,13 +133,12 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg mount ssh://
|
borg mount ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
{props.selectedOption.repositoryName}
|
||||||
{props.selectedOption.repository}
|
|
||||||
::archive1 /tmp/yourMountPoint
|
::archive1 /tmp/yourMountPoint
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg mount ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}::archive1 /tmp/yourMountPoint`}
|
dataToCopy={`borg mount ssh://${UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}::archive1 /tmp/yourMountPoint`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -3,23 +3,17 @@ import React from 'react';
|
||||||
import classes from '../WizardStep1/WizardStep1.module.css';
|
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||||
import { IconWand } from '@tabler/icons-react';
|
import { IconWand } from '@tabler/icons-react';
|
||||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||||
|
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||||
|
|
||||||
function WizardStep4(props) {
|
function WizardStep4(props) {
|
||||||
////Vars
|
////Vars
|
||||||
|
const wizardEnv = props.wizardEnv;
|
||||||
|
const UNIX_USER = wizardEnv.UNIX_USER;
|
||||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||||
let HOSTNAME;
|
const { FQDN, SSH_SERVER_PORT } = lanCommandOption(
|
||||||
let SSH_SERVER_PORT;
|
wizardEnv,
|
||||||
if (
|
props.selectedOption.lanCommand
|
||||||
props.selectedOption.lanCommand &&
|
);
|
||||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
|
||||||
process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN
|
|
||||||
) {
|
|
||||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME_LAN;
|
|
||||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN;
|
|
||||||
} else {
|
|
||||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME;
|
|
||||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT;
|
|
||||||
}
|
|
||||||
|
|
||||||
const configBorgmatic = `location:
|
const configBorgmatic = `location:
|
||||||
# List of source directories to backup.
|
# List of source directories to backup.
|
||||||
|
@ -29,10 +23,10 @@ function WizardStep4(props) {
|
||||||
|
|
||||||
repositories:
|
repositories:
|
||||||
# Paths of local or remote repositories to backup to.
|
# Paths of local or remote repositories to backup to.
|
||||||
- ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}
|
- ssh://${UNIX_USER}@${FQDN}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}
|
||||||
|
|
||||||
storage:
|
storage:
|
||||||
archive_name_format: '{HOSTNAME}-documents-{now}'
|
archive_name_format: '{FQDN}-documents-{now}'
|
||||||
encryption_passphrase: "YOUR PASSPHRASE"
|
encryption_passphrase: "YOUR PASSPHRASE"
|
||||||
|
|
||||||
retention:
|
retention:
|
||||||
|
@ -46,7 +40,7 @@ consistency:
|
||||||
checks:
|
checks:
|
||||||
- name: repository
|
- name: repository
|
||||||
- name: archives
|
- name: archives
|
||||||
- frequency: 2 weeks
|
frequency: 2 weeks
|
||||||
|
|
||||||
#hooks:
|
#hooks:
|
||||||
# Custom preparation scripts to run.
|
# Custom preparation scripts to run.
|
||||||
|
|
|
@ -78,7 +78,7 @@ export default function StorageUsedChartBar() {
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: 'Storage used (%)',
|
label: 'Storage used (%)',
|
||||||
//storageUsed is in octet, storageSize is in Go. Round to 1 decimal for %.
|
//storageUsed is in octet, storageSize is in GB. Round to 1 decimal for %.
|
||||||
data: data.map((repo) =>
|
data: data.map((repo) =>
|
||||||
(
|
(
|
||||||
((repo.storageUsed / 1000000) * 100) /
|
((repo.storageUsed / 1000000) * 100) /
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//Lib
|
//Lib
|
||||||
import classes from './RepoList.module.css';
|
import classes from './RepoList.module.css';
|
||||||
import { useState, useEffect, useRef } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { IconPlus, IconChevronDown, IconChevronUp } from '@tabler/icons-react';
|
import { IconPlus } from '@tabler/icons-react';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import useSWR, { useSWRConfig } from 'swr';
|
import useSWR, { useSWRConfig } from 'swr';
|
||||||
|
@ -43,12 +43,27 @@ export default function RepoList() {
|
||||||
if (router.pathname.startsWith('/manage-repo/edit')) {
|
if (router.pathname.startsWith('/manage-repo/edit')) {
|
||||||
setDisplayRepoEdit(!displayRepoEdit);
|
setDisplayRepoEdit(!displayRepoEdit);
|
||||||
}
|
}
|
||||||
|
//Fetch wizardEnv to hydrate Repo components
|
||||||
|
const fetchWizardEnv = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/account/getWizardEnv', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setWizardEnv((await response.json()).wizardEnv);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Fetching datas error');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchWizardEnv();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
////States
|
////States
|
||||||
const [displayRepoAdd, setDisplayRepoAdd] = useState(false);
|
const [displayRepoAdd, setDisplayRepoAdd] = useState(false);
|
||||||
const [displayRepoEdit, setDisplayRepoEdit] = useState(false);
|
const [displayRepoEdit, setDisplayRepoEdit] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [wizardEnv, setWizardEnv] = useState({});
|
||||||
|
|
||||||
////Functions
|
////Functions
|
||||||
|
|
||||||
|
@ -67,32 +82,6 @@ export default function RepoList() {
|
||||||
return <ToastContainer />;
|
return <ToastContainer />;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BUTTON : Display or not repo details for ONE repo
|
|
||||||
const displayDetailsForOneHandler = async (id, boolean) => {
|
|
||||||
setIsLoading(true);
|
|
||||||
await fetch('/api/repo/id/' + id + '/displayDetails', {
|
|
||||||
method: 'PUT',
|
|
||||||
headers: {
|
|
||||||
'Content-type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ displayDetails: boolean }),
|
|
||||||
})
|
|
||||||
.then((response) => {
|
|
||||||
if (response.ok) {
|
|
||||||
mutate('/api/repo');
|
|
||||||
setIsLoading(false);
|
|
||||||
} else {
|
|
||||||
setIsLoading(false);
|
|
||||||
toast.error('API error', toastOptions);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log(error);
|
|
||||||
setIsLoading(false);
|
|
||||||
toast.error('API error', toastOptions);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//BUTTON : Display RepoManage component box for ADD
|
//BUTTON : Display RepoManage component box for ADD
|
||||||
const manageRepoAddHandler = () => {
|
const manageRepoAddHandler = () => {
|
||||||
router.replace('/manage-repo/add');
|
router.replace('/manage-repo/add');
|
||||||
|
@ -127,49 +116,17 @@ export default function RepoList() {
|
||||||
alias={repo.alias}
|
alias={repo.alias}
|
||||||
status={repo.status}
|
status={repo.status}
|
||||||
lastSave={repo.lastSave}
|
lastSave={repo.lastSave}
|
||||||
repository={repo.repository}
|
alert={repo.alert}
|
||||||
|
repositoryName={repo.repositoryName}
|
||||||
storageSize={repo.storageSize}
|
storageSize={repo.storageSize}
|
||||||
storageUsed={repo.storageUsed}
|
storageUsed={repo.storageUsed}
|
||||||
sshPublicKey={repo.sshPublicKey}
|
sshPublicKey={repo.sshPublicKey}
|
||||||
displayDetails={repo.displayDetails}
|
|
||||||
unixUser={repo.unixUser}
|
|
||||||
comment={repo.comment}
|
comment={repo.comment}
|
||||||
lanCommand={repo.lanCommand}
|
lanCommand={repo.lanCommand}
|
||||||
|
appendOnlyMode={repo.appendOnlyMode}
|
||||||
repoManageEditHandler={() => repoManageEditHandler(repo.id)}
|
repoManageEditHandler={() => repoManageEditHandler(repo.id)}
|
||||||
|
wizardEnv={wizardEnv}
|
||||||
></Repo>
|
></Repo>
|
||||||
{repo.displayDetails ? (
|
|
||||||
<div className={classes.chevron}>
|
|
||||||
{isLoading ? (
|
|
||||||
<IconChevronUp color='#494b7a' size={28} />
|
|
||||||
) : (
|
|
||||||
<IconChevronUp
|
|
||||||
color='#494b7a'
|
|
||||||
size={28}
|
|
||||||
onClick={() => {
|
|
||||||
displayDetailsForOneHandler(repo.id, false);
|
|
||||||
// tell all SWRs with this key to revalidate
|
|
||||||
mutate('/api/repo');
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className={classes.chevron}>
|
|
||||||
{isLoading ? (
|
|
||||||
<IconChevronDown color='#494b7a' size={28} />
|
|
||||||
) : (
|
|
||||||
<IconChevronDown
|
|
||||||
color='#494b7a'
|
|
||||||
size={28}
|
|
||||||
onClick={() => {
|
|
||||||
displayDetailsForOneHandler(repo.id, true);
|
|
||||||
// tell all SWRs with this key to revalidate
|
|
||||||
mutate('/api/repo');
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -112,17 +112,6 @@
|
||||||
transform: scale(0.96);
|
transform: scale(0.96);
|
||||||
}
|
}
|
||||||
|
|
||||||
.chevron {
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chevron :focus,
|
|
||||||
.chevron :hover {
|
|
||||||
cursor: pointer;
|
|
||||||
filter: invert(27%) sepia(82%) saturate(2209%) hue-rotate(240deg)
|
|
||||||
brightness(99%) contrast(105%);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media all and (max-width: 1000px) {
|
@media all and (max-width: 1000px) {
|
||||||
.newRepoButton {
|
.newRepoButton {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -23,6 +23,7 @@ export default function RepoManage(props) {
|
||||||
} = useForm({ mode: 'onChange' });
|
} = useForm({ mode: 'onChange' });
|
||||||
//List of possible times for alerts
|
//List of possible times for alerts
|
||||||
const alertOptions = [
|
const alertOptions = [
|
||||||
|
{ value: 0, label: 'Disabled' },
|
||||||
{ value: 3600, label: '1 hour' },
|
{ value: 3600, label: '1 hour' },
|
||||||
{ value: 21600, label: '6 hours' },
|
{ value: 21600, label: '6 hours' },
|
||||||
{ value: 43200, label: '12 hours' },
|
{ value: 43200, label: '12 hours' },
|
||||||
|
@ -108,10 +109,58 @@ export default function RepoManage(props) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Verify that the SSH key is unique
|
||||||
|
const isSSHKeyUnique = async (sshPublicKey) => {
|
||||||
|
let isUnique = true;
|
||||||
|
|
||||||
|
// Extract the first two columns of the SSH key in the form
|
||||||
|
const publicKeyPrefix = sshPublicKey.split(' ').slice(0, 2).join(' ');
|
||||||
|
|
||||||
|
await fetch('/api/repo', { method: 'GET' })
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
|
for (let element in data.repoList) {
|
||||||
|
// Extract the first two columns of the SSH key in the repoList
|
||||||
|
const repoPublicKeyPrefix = data.repoList[
|
||||||
|
element
|
||||||
|
].sshPublicKey
|
||||||
|
.split(' ')
|
||||||
|
.slice(0, 2)
|
||||||
|
.join(' ');
|
||||||
|
|
||||||
|
if (
|
||||||
|
repoPublicKeyPrefix === publicKeyPrefix && // Compare the first two columns of the SSH key
|
||||||
|
(!targetRepo ||
|
||||||
|
data.repoList[element].id != targetRepo.id)
|
||||||
|
) {
|
||||||
|
toast.error(
|
||||||
|
'The SSH key is already used in repository #' +
|
||||||
|
data.repoList[element].id +
|
||||||
|
'. Please use another key or delete the key from the other repository.',
|
||||||
|
toastOptions
|
||||||
|
);
|
||||||
|
isUnique = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
toast.error('An error has occurred', toastOptions);
|
||||||
|
isUnique = false;
|
||||||
|
});
|
||||||
|
return isUnique;
|
||||||
|
};
|
||||||
|
|
||||||
//Form submit Handler for ADD or EDIT a repo
|
//Form submit Handler for ADD or EDIT a repo
|
||||||
const formSubmitHandler = async (dataForm) => {
|
const formSubmitHandler = async (dataForm) => {
|
||||||
//Loading button on submit to avoid multiple send.
|
//Loading button on submit to avoid multiple send.
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
//Verify that the SSH key is unique
|
||||||
|
if (!(await isSSHKeyUnique(dataForm.sshkey))) {
|
||||||
|
setIsLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
//ADD a repo
|
//ADD a repo
|
||||||
if (props.mode == 'add') {
|
if (props.mode == 'add') {
|
||||||
const newRepo = {
|
const newRepo = {
|
||||||
|
@ -121,6 +170,7 @@ export default function RepoManage(props) {
|
||||||
comment: dataForm.comment,
|
comment: dataForm.comment,
|
||||||
alert: dataForm.alert.value,
|
alert: dataForm.alert.value,
|
||||||
lanCommand: dataForm.lanCommand,
|
lanCommand: dataForm.lanCommand,
|
||||||
|
appendOnlyMode: dataForm.appendOnlyMode,
|
||||||
};
|
};
|
||||||
//POST API to send new repo
|
//POST API to send new repo
|
||||||
await fetch('/api/repo/add', {
|
await fetch('/api/repo/add', {
|
||||||
|
@ -130,7 +180,7 @@ export default function RepoManage(props) {
|
||||||
},
|
},
|
||||||
body: JSON.stringify(newRepo),
|
body: JSON.stringify(newRepo),
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(async (response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success(
|
toast.success(
|
||||||
'New repository added ! 🥳',
|
'New repository added ! 🥳',
|
||||||
|
@ -138,9 +188,13 @@ export default function RepoManage(props) {
|
||||||
);
|
);
|
||||||
router.replace('/');
|
router.replace('/');
|
||||||
} else {
|
} else {
|
||||||
toast.error('An error has occurred', toastOptions);
|
const errorMessage = await response.json();
|
||||||
|
toast.error(
|
||||||
|
`An error has occurred : ${errorMessage.message}`,
|
||||||
|
toastOptions
|
||||||
|
);
|
||||||
router.replace('/');
|
router.replace('/');
|
||||||
console.log('Fail to post');
|
console.log(`Fail to ${props.mode}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
@ -157,6 +211,7 @@ export default function RepoManage(props) {
|
||||||
comment: dataForm.comment,
|
comment: dataForm.comment,
|
||||||
alert: dataForm.alert.value,
|
alert: dataForm.alert.value,
|
||||||
lanCommand: dataForm.lanCommand,
|
lanCommand: dataForm.lanCommand,
|
||||||
|
appendOnlyMode: dataForm.appendOnlyMode,
|
||||||
};
|
};
|
||||||
await fetch('/api/repo/id/' + router.query.slug + '/edit', {
|
await fetch('/api/repo/id/' + router.query.slug + '/edit', {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
|
@ -165,7 +220,7 @@ export default function RepoManage(props) {
|
||||||
},
|
},
|
||||||
body: JSON.stringify(dataEdited),
|
body: JSON.stringify(dataEdited),
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(async (response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success(
|
toast.success(
|
||||||
'The repository #' +
|
'The repository #' +
|
||||||
|
@ -175,9 +230,13 @@ export default function RepoManage(props) {
|
||||||
);
|
);
|
||||||
router.replace('/');
|
router.replace('/');
|
||||||
} else {
|
} else {
|
||||||
toast.error('An error has occurred', toastOptions);
|
const errorMessage = await response.json();
|
||||||
|
toast.error(
|
||||||
|
`An error has occurred : ${errorMessage.message}`,
|
||||||
|
toastOptions
|
||||||
|
);
|
||||||
router.replace('/');
|
router.replace('/');
|
||||||
console.log('Fail to PUT');
|
console.log(`Fail to ${props.mode}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
@ -327,9 +386,10 @@ export default function RepoManage(props) {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{/* SIZE */}
|
{/* SIZE */}
|
||||||
<label htmlFor='size'>Storage Size (Go)</label>
|
<label htmlFor='size'>Storage Size (GB)</label>
|
||||||
<input
|
<input
|
||||||
type='number'
|
type='number'
|
||||||
|
min='1'
|
||||||
defaultValue={
|
defaultValue={
|
||||||
props.mode == 'edit'
|
props.mode == 'edit'
|
||||||
? targetRepo.storageSize
|
? targetRepo.storageSize
|
||||||
|
@ -368,7 +428,7 @@ export default function RepoManage(props) {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{/* LAN COMMAND GENERATION */}
|
{/* LAN COMMAND GENERATION */}
|
||||||
<div className={classes.lanCommandWrapper}>
|
<div className={classes.optionCommandWrapper}>
|
||||||
<input
|
<input
|
||||||
type='checkbox'
|
type='checkbox'
|
||||||
name='lanCommand'
|
name='lanCommand'
|
||||||
|
@ -397,6 +457,36 @@ export default function RepoManage(props) {
|
||||||
/>
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
{/* APPEND-ONLY MODE */}
|
||||||
|
<div className={classes.optionCommandWrapper}>
|
||||||
|
<input
|
||||||
|
type='checkbox'
|
||||||
|
name='appendOnlyMode'
|
||||||
|
defaultChecked={
|
||||||
|
props.mode == 'edit'
|
||||||
|
? targetRepo.appendOnlyMode
|
||||||
|
: false
|
||||||
|
}
|
||||||
|
{...register('appendOnlyMode')}
|
||||||
|
/>
|
||||||
|
<label htmlFor='appendOnlyMode'>
|
||||||
|
Enable append-only mode.
|
||||||
|
</label>
|
||||||
|
<Link
|
||||||
|
style={{
|
||||||
|
alignSelf: 'baseline',
|
||||||
|
marginLeft: '5px',
|
||||||
|
}}
|
||||||
|
href='https://borgwarehouse.com/docs/user-manual/repositories/#append-only-mode'
|
||||||
|
rel='noreferrer'
|
||||||
|
target='_blank'
|
||||||
|
>
|
||||||
|
<IconExternalLink
|
||||||
|
size={16}
|
||||||
|
color='#6c737f'
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
{/* ALERT */}
|
{/* ALERT */}
|
||||||
<label
|
<label
|
||||||
style={{ margin: '25px auto 10px auto' }}
|
style={{ margin: '25px auto 10px auto' }}
|
||||||
|
@ -414,7 +504,7 @@ export default function RepoManage(props) {
|
||||||
x.value ===
|
x.value ===
|
||||||
targetRepo.alert
|
targetRepo.alert
|
||||||
)
|
)
|
||||||
: alertOptions[3]
|
: alertOptions[4]
|
||||||
}
|
}
|
||||||
control={control}
|
control={control}
|
||||||
render={({
|
render={({
|
||||||
|
|
|
@ -126,23 +126,23 @@
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lanCommandWrapper {
|
.optionCommandWrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
color: #494b7a;
|
color: #494b7a;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lanCommandWrapper label {
|
.optionCommandWrapper label {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lanCommandWrapper input[type='checkbox'] {
|
.optionCommandWrapper input[type='checkbox'] {
|
||||||
width: auto;
|
width: auto;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
accent-color: #6d4aff;
|
accent-color: #6d4aff;
|
||||||
}
|
}
|
||||||
.lanCommandWrapper input[type='checkbox']:focus {
|
.optionCommandWrapper input[type='checkbox']:focus {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
accent-color: #6d4aff;
|
accent-color: #6d4aff;
|
||||||
|
|
|
@ -20,10 +20,10 @@ function SetupWizard(props) {
|
||||||
const [list, setList] = useState([]);
|
const [list, setList] = useState([]);
|
||||||
const [listIsLoading, setListIsLoading] = useState(true);
|
const [listIsLoading, setListIsLoading] = useState(true);
|
||||||
const [step, setStep] = useState();
|
const [step, setStep] = useState();
|
||||||
|
const [wizardEnv, setWizardEnv] = useState({});
|
||||||
const [selectedOption, setSelectedOption] = useState({
|
const [selectedOption, setSelectedOption] = useState({
|
||||||
id: '#id',
|
id: '#id',
|
||||||
repository: 'repo',
|
repository: 'repo',
|
||||||
unixUser: 'user',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
////LifeCycle
|
////LifeCycle
|
||||||
|
@ -45,6 +45,21 @@ function SetupWizard(props) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
repoList();
|
repoList();
|
||||||
|
//Fetch wizardEnv to hydrate Wizard' steps
|
||||||
|
const fetchWizardEnv = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/account/getWizardEnv', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setWizardEnv((await response.json()).wizardEnv);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Fetching datas error');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchWizardEnv();
|
||||||
}, []);
|
}, []);
|
||||||
//Component did update
|
//Component did update
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -59,8 +74,7 @@ function SetupWizard(props) {
|
||||||
label: `${repo.alias} - #${repo.id}`,
|
label: `${repo.alias} - #${repo.id}`,
|
||||||
value: `${repo.alias} - #${repo.id}`,
|
value: `${repo.alias} - #${repo.id}`,
|
||||||
id: repo.id,
|
id: repo.id,
|
||||||
repository: repo.repository,
|
repositoryName: repo.repositoryName,
|
||||||
unixUser: repo.unixUser,
|
|
||||||
lanCommand: repo.lanCommand,
|
lanCommand: repo.lanCommand,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -86,11 +100,26 @@ function SetupWizard(props) {
|
||||||
if (step == 1) {
|
if (step == 1) {
|
||||||
return <WizardStep1 />;
|
return <WizardStep1 />;
|
||||||
} else if (step == 2) {
|
} else if (step == 2) {
|
||||||
return <WizardStep2 selectedOption={selectedOption} />;
|
return (
|
||||||
|
<WizardStep2
|
||||||
|
selectedOption={selectedOption}
|
||||||
|
wizardEnv={wizardEnv}
|
||||||
|
/>
|
||||||
|
);
|
||||||
} else if (step == 3) {
|
} else if (step == 3) {
|
||||||
return <WizardStep3 selectedOption={selectedOption} />;
|
return (
|
||||||
|
<WizardStep3
|
||||||
|
selectedOption={selectedOption}
|
||||||
|
wizardEnv={wizardEnv}
|
||||||
|
/>
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return <WizardStep4 selectedOption={selectedOption} />;
|
return (
|
||||||
|
<WizardStep4
|
||||||
|
selectedOption={selectedOption}
|
||||||
|
wizardEnv={wizardEnv}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default function AppriseMode() {
|
||||||
const [modeFormIsSaved, setModeFormIsSaved] = useState(false);
|
const [modeFormIsSaved, setModeFormIsSaved] = useState(false);
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
const [displayStatelessURL, setDisplayStatelessURL] = useState(false);
|
const [displayStatelessURL, setDisplayStatelessURL] = useState(false);
|
||||||
const [appriseMode, setAppriseMode] = useState('');
|
const [appriseMode, setAppriseMode] = useState('stateless');
|
||||||
const [appriseStatelessURL, setAppriseStatelessURL] = useState();
|
const [appriseStatelessURL, setAppriseStatelessURL] = useState();
|
||||||
|
|
||||||
////LifeCycle
|
////LifeCycle
|
||||||
|
|
|
@ -86,7 +86,7 @@ export default function PasswordSettings(props) {
|
||||||
<p>
|
<p>
|
||||||
<input
|
<input
|
||||||
type='password'
|
type='password'
|
||||||
placeholder='Actual password'
|
placeholder='Current password'
|
||||||
{...register('oldPassword', {
|
{...register('oldPassword', {
|
||||||
required: true,
|
required: true,
|
||||||
})}
|
})}
|
||||||
|
|
59
Dockerfile
Normal file
59
Dockerfile
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
ARG UID=1001
|
||||||
|
ARG GID=1001
|
||||||
|
|
||||||
|
FROM node:20-bookworm-slim as base
|
||||||
|
|
||||||
|
# build stage
|
||||||
|
FROM base AS deps
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
|
||||||
|
RUN npm ci --only=production
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN sed -i "s/images:/output: 'standalone',images:/" next.config.js
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# run stage
|
||||||
|
FROM base AS runner
|
||||||
|
|
||||||
|
ARG UID
|
||||||
|
ARG GID
|
||||||
|
|
||||||
|
ENV NODE_ENV production
|
||||||
|
|
||||||
|
RUN echo 'deb http://deb.debian.org/debian bookworm-backports main' >> /etc/apt/sources.list
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
supervisor curl jq jc borgbackup/bookworm-backports openssh-server rsyslog && \
|
||||||
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN groupadd -g ${GID} borgwarehouse && useradd -m -u ${UID} -g ${GID} borgwarehouse
|
||||||
|
|
||||||
|
RUN cp /etc/ssh/moduli /home/borgwarehouse/
|
||||||
|
|
||||||
|
WORKDIR /home/borgwarehouse/app
|
||||||
|
|
||||||
|
COPY --from=builder --chown=borgwarehouse:borgwarehouse /app/docker/docker-bw-init.sh /app/LICENSE ./
|
||||||
|
COPY --from=builder --chown=borgwarehouse:borgwarehouse /app/helpers/shells ./helpers/shells
|
||||||
|
COPY --from=builder --chown=borgwarehouse:borgwarehouse /app/.next/standalone ./
|
||||||
|
COPY --from=builder --chown=borgwarehouse:borgwarehouse /app/public ./public
|
||||||
|
COPY --from=builder --chown=borgwarehouse:borgwarehouse /app/.next/static ./.next/static
|
||||||
|
COPY --from=builder --chown=borgwarehouse:borgwarehouse /app/docker/supervisord.conf ./
|
||||||
|
COPY --from=builder --chown=borgwarehouse:borgwarehouse /app/docker/rsyslog.conf /etc/rsyslog.conf
|
||||||
|
COPY --from=builder --chown=borgwarehouse:borgwarehouse /app/docker/sshd_config ./
|
||||||
|
|
||||||
|
USER borgwarehouse
|
||||||
|
|
||||||
|
EXPOSE 3000 22
|
||||||
|
|
||||||
|
ENTRYPOINT ["./docker-bw-init.sh"]
|
78
README.md
78
README.md
|
@ -1,7 +1,12 @@
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
[![Next][Next.js]][Next-url]
|
[![Next][Next.js]][Next-url]
|
||||||
[![React][React.js]][React-url]
|
[![React][React.js]][React-url]
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
[![Docker](https://img.shields.io/badge/Docker-borgwarehouse-blue?style=for-the-badge&logo=docker)](https://hub.docker.com/r/borgwarehouse/borgwarehouse)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -19,7 +24,16 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## What is BorgWarehouse ?
|
## ⭐ Support the Project
|
||||||
|
<div align="center">
|
||||||
|
<a href="https://github.com/sponsors/Ravinou"><img alt="GitHub Sponsors" src="https://img.shields.io/github/sponsors/Ravinou?style=for-the-badge&logo=github&label=Github%20Sponsors&link=https%3A%2F%2Fgithub.com%2Fsponsors%2FRavinou"></a>
|
||||||
|
<a href="https://liberapay.com/R4VEN/"><img alt="Liberapay patrons" src="https://img.shields.io/liberapay/patrons/R4VEN?style=for-the-badge&logo=liberapay&label=Liberapay%20Sponsors&link=https%3A%2F%2Fliberapay.com%2FR4VEN"></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
If you find BorgWarehouse helpful or interesting, please consider **giving it a star on GitHub** and **[sponsoring](https://github.com/sponsors/Ravinou)**. Your support is greatly appreciated!
|
||||||
|
|
||||||
|
## ✨ What is BorgWarehouse ?
|
||||||
|
|
||||||
**BorgWarehouse is a graphical interface to manage a central [BorgBackup](https://borgbackup.readthedocs.io/en/stable/#what-is-borgbackup) repository server.**
|
**BorgWarehouse is a graphical interface to manage a central [BorgBackup](https://borgbackup.readthedocs.io/en/stable/#what-is-borgbackup) repository server.**
|
||||||
|
|
||||||
|
@ -37,59 +51,33 @@ With BorgWarehouse, you have an interface that allows you to do all this simply
|
||||||
|
|
||||||
The whole system part is automatically managed by BorgWarehouse and **you don't have to touch your terminal anymore** while enjoying a visual feedback on the status of your repositories.
|
The whole system part is automatically managed by BorgWarehouse and **you don't have to touch your terminal anymore** while enjoying a visual feedback on the status of your repositories.
|
||||||
|
|
||||||
## Get started
|
## 📖 Get started
|
||||||
|
|
||||||
You can find the documentation here : <a href="https://borgwarehouse.com/docs/prologue/introduction/">https://borgwarehouse.com/</a>
|
You can find the documentation here : [borgwarehouse.com](https://borgwarehouse.com/docs/prologue/introduction/)
|
||||||
|
|
||||||
## :key: Environment Variables
|
## 🔑 Environment Variables
|
||||||
|
|
||||||
To run this project, you will need to add the following environment variables to your `.env.local` file.
|
To run this project, you will need to add some environment variables.
|
||||||
|
|
||||||
Required variables :
|
You will find a complete documentation for this [here](https://borgwarehouse.com/docs/admin-manual/env-vars/).
|
||||||
|
|
||||||
- `NEXTAUTH_URL` : The url of your application as **https://borgwarehouse.com**.
|
## ⏬ How to update ?
|
||||||
- `NEXTAUTH_SECRET` : A secret random key.
|
|
||||||
- `CRONJOB_KEY` : A secret API key for cronjob.
|
|
||||||
- `NEXT_PUBLIC_HOSTNAME` : FQDN as **borgwarehouse.com**
|
|
||||||
- `NEXT_PUBLIC_SSH_SERVER_PORT` : SSH port of your server as **22**.
|
|
||||||
- `NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_RSA` : Your server SSH fingerprint for RSA.
|
|
||||||
- `NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_ED25519` : Your server SSH fingerprint for ED25519.
|
|
||||||
- `NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_ECDSA` : Your server SSH fingerprint for ECDSA.
|
|
||||||
|
|
||||||
Example for a valid `.env.local` file :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Private variable
|
|
||||||
NEXTAUTH_URL=https://yourbwdomain.com
|
|
||||||
NEXTAUTH_SECRET=YOURFIRSTSECRET
|
|
||||||
CRONJOB_KEY=YOURSECONDSECRET
|
|
||||||
MAIL_SMTP_FROM=
|
|
||||||
MAIL_SMTP_HOST=
|
|
||||||
MAIL_SMTP_PORT=
|
|
||||||
MAIL_SMTP_LOGIN=
|
|
||||||
MAIL_SMTP_PWD=
|
|
||||||
MAIL_REJECT_SELFSIGNED_TLS=true
|
|
||||||
|
|
||||||
# Public variable (Any change need a rebuild of app)
|
|
||||||
NEXT_PUBLIC_HOSTNAME=yourbwdomain.com
|
|
||||||
NEXT_PUBLIC_SSH_SERVER_PORT=22
|
|
||||||
NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_RSA=SHA256:36mfYNRrm1aconVt6cBpi8LhAoPP4kB8QsVW4n8eGHQ
|
|
||||||
NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_ED25519=SHA256:tYQuzrZZMqaw0Bzvn/sMoDs1CVEitZ9IrRyUg02yTPA
|
|
||||||
NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_ECDSA=SHA256:nTpxui1oEmH9konPau17qBVIzBQVOsD1BIbBFU5IL04
|
|
||||||
|
|
||||||
# Disable NextJS telemetry
|
|
||||||
NEXT_TELEMETRY_DISABLED=1
|
|
||||||
```
|
|
||||||
|
|
||||||
You can find more details about generating your secrets or retrieving your SSH fingerprint. You can find more details about generating your secrets or retrieving your SSH fingerprint <a href="https://borgwarehouse.com/docs/admin-manual/debian-installation/#configure-application-environment-variables">in the documentation</a>.
|
|
||||||
|
|
||||||
## How to update ?
|
|
||||||
|
|
||||||
Check the online documentation [just here](https://borgwarehouse.com/docs/admin-manual/how-to-update/) !
|
Check the online documentation [just here](https://borgwarehouse.com/docs/admin-manual/how-to-update/) !
|
||||||
|
|
||||||
<!-- MARKDOWN LINKS & IMAGES -->
|
<!-- MARKDOWN LINKS & IMAGES -->
|
||||||
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
|
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
|
||||||
|
|
||||||
|
## ❤️ Special thanks to sponsors ❤️
|
||||||
|
|
||||||
|
### 🥇 Current sponsors 🥇
|
||||||
|
<a href="https://github.com/royalmoose"><img src="https://avatars.githubusercontent.com/royalmoose" style="width:50px; border-radius:50%;"/></a>
|
||||||
|
<a href="https://github.com/Magneticdud"><img src="https://avatars.githubusercontent.com/Magneticdud" style="width:50px; border-radius:50%;"/></a>
|
||||||
|
<a href="https://github.com/dhenry123"><img src="https://avatars.githubusercontent.com/dhenry123" style="width:50px; border-radius:50%;"/></a>
|
||||||
|
|
||||||
|
#### Past sponsors
|
||||||
|
<a href="https://github.com/shad-lp"><img src="https://avatars.githubusercontent.com/shad-lp" style="width:25px; border-radius:50%;"/></a>
|
||||||
|
|
||||||
[next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white
|
[next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white
|
||||||
[next-url]: https://nextjs.org/
|
[next-url]: https://nextjs.org/
|
||||||
[react.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB
|
[react.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB
|
||||||
|
|
30
docker-compose.yml
Normal file
30
docker-compose.yml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
borgwarehouse:
|
||||||
|
container_name: borgwarehouse
|
||||||
|
# If you want to build the image yourself, uncomment the following lines and comment the image line
|
||||||
|
#build:
|
||||||
|
# context: .
|
||||||
|
# dockerfile: Dockerfile
|
||||||
|
# args:
|
||||||
|
# - UID=${UID}
|
||||||
|
# - GID=${GID}
|
||||||
|
image: borgwarehouse/borgwarehouse
|
||||||
|
user: '${UID:?UID variable missing}:${GID:?GID variable missing}'
|
||||||
|
ports:
|
||||||
|
- '${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000'
|
||||||
|
- '${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22'
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ${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
|
||||||
|
- ${TMP_PATH:?TMP_PATH variable missing}:/home/borgwarehouse/tmp
|
||||||
|
- ${LOGS_PATH:?LOGS_PATH variable missing}:/home/borgwarehouse/logs
|
||||||
|
# Apprise is used to send notifications, it's optional. http://apprise:8000 is the URL to use in BorgWarehouse.
|
||||||
|
apprise:
|
||||||
|
container_name: apprise
|
||||||
|
image: caronc/apprise
|
||||||
|
user: 'www-data:www-data'
|
86
docker/docker-bw-init.sh
Executable file
86
docker/docker-bw-init.sh
Executable file
|
@ -0,0 +1,86 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SSH_DIR="/home/borgwarehouse/.ssh"
|
||||||
|
AUTHORIZED_KEYS_FILE="$SSH_DIR/authorized_keys"
|
||||||
|
REPOS_DIR="/home/borgwarehouse/repos"
|
||||||
|
|
||||||
|
print_green() {
|
||||||
|
echo -e "\e[92m$1\e[0m";
|
||||||
|
}
|
||||||
|
print_red() {
|
||||||
|
echo -e "\e[91m$1\e[0m";
|
||||||
|
}
|
||||||
|
|
||||||
|
init_ssh_server() {
|
||||||
|
if [ -z "$(ls -A /etc/ssh)" ]; then
|
||||||
|
print_green "/etc/ssh is empty, generating SSH host keys..."
|
||||||
|
ssh-keygen -A
|
||||||
|
cp /home/borgwarehouse/moduli /etc/ssh/
|
||||||
|
fi
|
||||||
|
if [ ! -f "/etc/ssh/sshd_config" ]; then
|
||||||
|
print_green "sshd_config not found in your volume, copying the default one..."
|
||||||
|
cp /home/borgwarehouse/app/sshd_config /etc/ssh/
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_ssh_directory() {
|
||||||
|
if [ ! -d "$SSH_DIR" ]; then
|
||||||
|
print_red "The .ssh directory does not exist, you need to mount it as docker volume."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
chmod 700 "$SSH_DIR"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
create_authorized_keys_file() {
|
||||||
|
if [ ! -f "$AUTHORIZED_KEYS_FILE" ]; then
|
||||||
|
print_green "The authorized_keys file does not exist, creating..."
|
||||||
|
touch "$AUTHORIZED_KEYS_FILE"
|
||||||
|
fi
|
||||||
|
chmod 600 "$AUTHORIZED_KEYS_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_repos_directory() {
|
||||||
|
if [ ! -d "$REPOS_DIR" ]; then
|
||||||
|
print_red "The repos directory does not exist, you need to mount it as docker volume."
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
chmod 700 "$REPOS_DIR"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_SSH_fingerprints() {
|
||||||
|
print_green "Getting SSH fingerprints..."
|
||||||
|
RSA_FINGERPRINT=$(ssh-keygen -lf /etc/ssh/ssh_host_rsa_key | awk '{print $2}')
|
||||||
|
ED25519_FINGERPRINT=$(ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key | awk '{print $2}')
|
||||||
|
ECDSA_FINGERPRINT=$(ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key | awk '{print $2}')
|
||||||
|
export SSH_SERVER_FINGERPRINT_RSA="$RSA_FINGERPRINT"
|
||||||
|
export SSH_SERVER_FINGERPRINT_ED25519="$ED25519_FINGERPRINT"
|
||||||
|
export SSH_SERVER_FINGERPRINT_ECDSA="$ECDSA_FINGERPRINT"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_env() {
|
||||||
|
if [ -z "$CRONJOB_KEY" ]; then
|
||||||
|
CRONJOB_KEY=$(openssl rand -base64 32)
|
||||||
|
print_green "CRONJOB_KEY not found or empty. Generating a random key..."
|
||||||
|
export CRONJOB_KEY
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$NEXTAUTH_SECRET" ]; then
|
||||||
|
NEXTAUTH_SECRET=$(openssl rand -base64 32)
|
||||||
|
print_green "NEXTAUTH_SECRET not found or empty. Generating a random key..."
|
||||||
|
export NEXTAUTH_SECRET
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_env
|
||||||
|
init_ssh_server
|
||||||
|
check_ssh_directory
|
||||||
|
create_authorized_keys_file
|
||||||
|
check_repos_directory
|
||||||
|
get_SSH_fingerprints
|
||||||
|
|
||||||
|
print_green "Successful initialization. BorgWarehouse is ready !"
|
||||||
|
exec supervisord -c /home/borgwarehouse/app/supervisord.conf
|
40
docker/rsyslog.conf
Normal file
40
docker/rsyslog.conf
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# rsyslog configuration file
|
||||||
|
|
||||||
|
$WorkDirectory /home/borgwarehouse/tmp
|
||||||
|
$FileOwner borgwarehouse
|
||||||
|
$FileGroup borgwarehouse
|
||||||
|
$FileCreateMode 0640
|
||||||
|
$DirCreateMode 0755
|
||||||
|
$Umask 0022
|
||||||
|
|
||||||
|
$RepeatedMsgReduction on
|
||||||
|
|
||||||
|
module(load="imfile" PollingInterval="10")
|
||||||
|
|
||||||
|
input(type="imfile"
|
||||||
|
File="/home/borgwarehouse/tmp/borgwarehouse.log"
|
||||||
|
Tag="BorgWarehouse"
|
||||||
|
Severity="info"
|
||||||
|
Facility="local7"
|
||||||
|
ruleset="bwLogs")
|
||||||
|
|
||||||
|
input(type="imfile"
|
||||||
|
File="/home/borgwarehouse/tmp/sshd.log"
|
||||||
|
Tag="sshd"
|
||||||
|
Severity="info"
|
||||||
|
Facility="local7"
|
||||||
|
ruleset="sshdLogs")
|
||||||
|
|
||||||
|
$template myFormat,"%timegenerated:::date-rfc3339% %syslogtag% %msg%\n"
|
||||||
|
|
||||||
|
ruleset(name="bwLogs") {
|
||||||
|
action(type="omfile"
|
||||||
|
File="/home/borgwarehouse/logs/borgwarehouse.log"
|
||||||
|
Template="myFormat")
|
||||||
|
}
|
||||||
|
|
||||||
|
ruleset(name="sshdLogs") {
|
||||||
|
action(type="omfile"
|
||||||
|
File="/home/borgwarehouse/logs/sshd.log"
|
||||||
|
Template="myFormat")
|
||||||
|
}
|
32
docker/sshd_config
Normal file
32
docker/sshd_config
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
Port 22
|
||||||
|
PidFile /home/borgwarehouse/tmp/sshd.pid
|
||||||
|
AllowUsers borgwarehouse
|
||||||
|
LogLevel INFO
|
||||||
|
SyslogFacility AUTH
|
||||||
|
|
||||||
|
# Security
|
||||||
|
Protocol 2
|
||||||
|
PermitRootLogin no
|
||||||
|
PasswordAuthentication no
|
||||||
|
ChallengeResponseAuthentication no
|
||||||
|
AuthenticationMethods publickey
|
||||||
|
MaxAuthTries 2
|
||||||
|
MaxStartups 2:30:10
|
||||||
|
LoginGraceTime 30
|
||||||
|
UsePAM no
|
||||||
|
|
||||||
|
# Useless options for BorgWarehouse
|
||||||
|
PrintMotd no
|
||||||
|
UseDNS no
|
||||||
|
AllowTcpForwarding no
|
||||||
|
X11Forwarding no
|
||||||
|
PermitTTY no
|
||||||
|
|
||||||
|
# Ciphers
|
||||||
|
Ciphers aes256-ctr,aes192-ctr,aes128-ctr
|
||||||
|
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
|
||||||
|
|
||||||
|
# With low bandwidth or huge backup, uncomment the following lines to avoid SSH timeout (Broken pipe).
|
||||||
|
#ClientAliveInterval 600
|
||||||
|
#ClientAliveCountMax 0
|
||||||
|
|
24
docker/supervisord.conf
Normal file
24
docker/supervisord.conf
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
logfile=/home/borgwarehouse/logs/supervisord.log
|
||||||
|
loglevel=error
|
||||||
|
pidfile=/home/borgwarehouse/tmp/supervisord.pid
|
||||||
|
logfile_maxbytes=10MB
|
||||||
|
logfile_backups=5
|
||||||
|
|
||||||
|
[program:sshd]
|
||||||
|
command=/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config
|
||||||
|
stdout_logfile=/home/borgwarehouse/tmp/sshd.log
|
||||||
|
stdout_logfile_maxbytes=10MB
|
||||||
|
stdout_logfile_backups=5
|
||||||
|
redirect_stderr=true
|
||||||
|
|
||||||
|
[program:borgwarehouse]
|
||||||
|
command=/usr/local/bin/node server.js
|
||||||
|
stdout_logfile=/home/borgwarehouse/tmp/borgwarehouse.log
|
||||||
|
stdout_logfile_maxbytes=10MB
|
||||||
|
stdout_logfile_backups=5
|
||||||
|
redirect_stderr=true
|
||||||
|
|
||||||
|
[program:rsyslogd]
|
||||||
|
command=rsyslogd -n -i /home/borgwarehouse/tmp/rsyslogd.pid -f /etc/rsyslog.conf
|
|
@ -1,9 +0,0 @@
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/sbin/userdel -rf [[\:xdigit\:]]*
|
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/sbin/useradd -d /var/borgwarehouse/[[\:xdigit\:]]* -s /bin/bash -m --badname [[\:xdigit\:]]*
|
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/mkdir -p /var/borgwarehouse/[[\:xdigit\:]]*/repos/repo[[\:digit\:]]*, /usr/bin/mkdir -p /var/borgwarehouse/[[\:xdigit\:]]*/.ssh
|
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/touch /var/borgwarehouse/[[\:xdigit\:]]*/.ssh/authorized_keys
|
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/chmod -R 750 /var/borgwarehouse/[[\:xdigit\:]]*, /usr/bin/chmod 600 /var/borgwarehouse/[[\:xdigit\:]]*/.ssh/authorized_keys
|
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/chown -R [[\:xdigit\:]]*\:borgwarehouse /var/borgwarehouse/[[\:xdigit\:]]*
|
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/tee /var/borgwarehouse/[[\:xdigit\:]]*/.ssh/authorized_keys
|
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/sed -ri s|*|g /var/borgwarehouse/[[\:xdigit\:]]*/.ssh/authorized_keys
|
|
||||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/du -s -- [[\:xdigit\:]]*
|
|
13
helpers/functions/lanCommandOption.js
Normal file
13
helpers/functions/lanCommandOption.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
export default function lanCommandOption(wizardEnv, lanCommand) {
|
||||||
|
let FQDN;
|
||||||
|
let SSH_SERVER_PORT;
|
||||||
|
if (lanCommand && wizardEnv.FQDN_LAN && wizardEnv.SSH_SERVER_PORT_LAN) {
|
||||||
|
FQDN = wizardEnv.FQDN_LAN;
|
||||||
|
SSH_SERVER_PORT = wizardEnv.SSH_SERVER_PORT_LAN;
|
||||||
|
} else {
|
||||||
|
FQDN = wizardEnv.FQDN;
|
||||||
|
SSH_SERVER_PORT = wizardEnv.SSH_SERVER_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { FQDN, SSH_SERVER_PORT };
|
||||||
|
}
|
45
helpers/functions/repoHistory.js
Normal file
45
helpers/functions/repoHistory.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
export default async function repoHistory(data) {
|
||||||
|
try {
|
||||||
|
const repoHistoryDir = path.join(process.cwd(), '/config/versions');
|
||||||
|
const maxBackupCount = parseInt(process.env.MAX_REPO_BACKUP_COUNT) || 8;
|
||||||
|
const timestamp = new Date().toISOString();
|
||||||
|
const backupDate = timestamp.split('T')[0];
|
||||||
|
|
||||||
|
//Create the directory if it does not exist
|
||||||
|
await fs.mkdir(repoHistoryDir, { recursive: true });
|
||||||
|
|
||||||
|
const existingBackups = await fs.readdir(repoHistoryDir);
|
||||||
|
|
||||||
|
if (existingBackups.length >= maxBackupCount) {
|
||||||
|
existingBackups.sort();
|
||||||
|
const backupsToDelete = existingBackups.slice(
|
||||||
|
0,
|
||||||
|
existingBackups.length - maxBackupCount + 1
|
||||||
|
);
|
||||||
|
for (const backupToDelete of backupsToDelete) {
|
||||||
|
const backupFilePathToDelete = path.join(
|
||||||
|
repoHistoryDir,
|
||||||
|
backupToDelete
|
||||||
|
);
|
||||||
|
await fs.unlink(backupFilePathToDelete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const backupFileName = `${backupDate}.log`;
|
||||||
|
const backupFilePath = path.join(repoHistoryDir, backupFileName);
|
||||||
|
const jsonData = JSON.stringify(data, null, 2);
|
||||||
|
|
||||||
|
const logData = `\n>>>> History of file repo.json at "${timestamp}" <<<<\n${jsonData}\n`;
|
||||||
|
|
||||||
|
// Écrire ou réécrire le fichier avec le contenu mis à jour
|
||||||
|
await fs.appendFile(backupFilePath, logData);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(
|
||||||
|
'An error occurred while saving the repo history :',
|
||||||
|
error.message
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,87 +1,84 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Shell created by Raven for BorgWarehouse.
|
# Shell created by Raven for BorgWarehouse.
|
||||||
# This shell takes 3 arguments : [reponame] X [SSH pub key] X [quota]
|
# This shell takes 2 arguments : [SSH pub key] X [quota] x [append only mode (boolean)]
|
||||||
# Main steps are :
|
# Main steps are :
|
||||||
# - check if args are present
|
# - check if args are present
|
||||||
# - check the ssh pub key format
|
# - check the ssh pub key format
|
||||||
|
# - check if the ssh pub key is already present in authorized_keys
|
||||||
# - check if borgbackup package is install
|
# - check if borgbackup package is install
|
||||||
# - generate a random username, check if it exists in /etc/passwd
|
# - generate a random repositoryName
|
||||||
# - add the user (with random name), group, shell and home
|
|
||||||
# - create a pool which is the folder where all the repositories for a user are located (only one by user for borgwarehouse usage)
|
|
||||||
# - create the authorized_keys
|
|
||||||
# - add the SSH public key in the authorized_keys with borg restriction for repository and storage quota.
|
# - add the SSH public key in the authorized_keys with borg restriction for repository and storage quota.
|
||||||
# This simple method prevents the user from connecting to the server with a shell in SSH.
|
# This simple method prevents the user from connecting to the server with a shell in SSH.
|
||||||
# He can only use the borg command. Moreover, he will not be able to leave his repository or create a new one.
|
# He can only use the borg command. Moreover, he will not be able to leave his repository or create a new one.
|
||||||
# It is similar to a jail and that is the goal.
|
# It is similar to a jail and that is the goal.
|
||||||
|
|
||||||
|
# Limitation : all SSH pubkey are unique : https://github.com/borgbackup/borg/issues/7757
|
||||||
|
|
||||||
# Exit when any command fails
|
# Exit when any command fails
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Load .env if exists
|
||||||
|
if [[ -f .env ]]; then
|
||||||
|
source .env
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default value if .env not exists
|
||||||
|
: "${home:=/home/borgwarehouse}"
|
||||||
|
|
||||||
|
# Some variables
|
||||||
|
pool="${home}/repos"
|
||||||
|
authorized_keys="${home}/.ssh/authorized_keys"
|
||||||
|
|
||||||
# Check args
|
# Check args
|
||||||
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ];then
|
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" != "true" ] && [ "$3" != "false" ];then
|
||||||
echo "This shell takes 3 argument : Reponame, SSH Public Key, Quota in Go [e.g. : 10] "
|
echo -n "This shell takes 3 arguments : SSH Public Key, Quota in Go [e.g. : 10], Append only mode [true|false]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the SSH public key is a valid format
|
# Check if the SSH public key is a valid format
|
||||||
# This pattern validates SSH public keys for : rsa, ed25519, ed25519-sk
|
# This pattern validates SSH public keys for : rsa, ed25519, ed25519-sk
|
||||||
pattern='(ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29t|ssh-rsa AAAAB3NzaC1yc2)[0-9A-Za-z+/]+[=]{0,3}(\s.*)?'
|
pattern='(ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29t|ssh-rsa AAAAB3NzaC1yc2)[0-9A-Za-z+/]+[=]{0,3}(\s.*)?'
|
||||||
if [[ ! "$2" =~ $pattern ]]
|
if [[ ! "$1" =~ $pattern ]]
|
||||||
then
|
then
|
||||||
echo "Invalid public SSH KEY format. Provide a key in OpenSSH format (rsa, ed25519, ed25519-sk)"
|
echo -n "Invalid public SSH KEY format. Provide a key in OpenSSH format (rsa, ed25519, ed25519-sk)"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## Check if authorized_keys exists
|
||||||
|
if [ ! -f "${authorized_keys}" ];then
|
||||||
|
echo -n "${authorized_keys} must be present"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if SSH pub key is already present in authorized_keys
|
||||||
|
if grep -q "$1" "$authorized_keys"; then
|
||||||
|
echo -n "SSH pub key already present in authorized_keys"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if borgbackup is installed
|
# Check if borgbackup is installed
|
||||||
if ! [ -x "$(command -v borg)" ]; then
|
if ! [ -x "$(command -v borg)" ]; then
|
||||||
echo "You must install borgbackup package."
|
echo -n "You must install borgbackup package."
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generation of a random for username
|
|
||||||
randUsername () {
|
|
||||||
openssl rand -hex 4
|
|
||||||
}
|
|
||||||
user=$(randUsername)
|
|
||||||
|
|
||||||
# Check if the random is already a username.
|
|
||||||
while grep -q "$user" /etc/passwd
|
|
||||||
do
|
|
||||||
user=$(randUsername)
|
|
||||||
done
|
|
||||||
|
|
||||||
# Some variables
|
|
||||||
home="/var/borgwarehouse/${user}"
|
|
||||||
pool="${home}/repos"
|
|
||||||
authorized_keys="${home}/.ssh/authorized_keys"
|
|
||||||
|
|
||||||
## add user and create homedirectory ${user} - [shell=/bin/bash home=${home} group=${group}]
|
|
||||||
sudo useradd -d "${home}" -s "/bin/bash" -m --badname "${user}"
|
|
||||||
|
|
||||||
## Create directory ${home}/.ssh
|
|
||||||
sudo mkdir -p "${home}/.ssh"
|
|
||||||
|
|
||||||
## Create autorized_keys file
|
|
||||||
sudo touch "${home}/.ssh/authorized_keys"
|
|
||||||
|
|
||||||
## Create the repo
|
|
||||||
sudo mkdir -p "${pool}/$1"
|
|
||||||
|
|
||||||
## Change permissions
|
|
||||||
sudo chmod -R 750 "${home}"
|
|
||||||
sudo chmod 600 "${authorized_keys}"
|
|
||||||
sudo chown -R "${user}:borgwarehouse" "${home}"
|
|
||||||
|
|
||||||
## Check if authorized_keys exists
|
|
||||||
if [ ! -f "${authorized_keys}" ];then
|
|
||||||
echo "${authorized_keys} must be present"
|
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Add ssh public key in authorized_keys with borg restriction for only 1 repository (:$1) and storage quota
|
# Generation of a random for repositoryName
|
||||||
restricted_authkeys="command=\"cd ${pool};borg serve --restrict-to-repository ${pool}/$1 --storage-quota $3G\",restrict $2"
|
randRepositoryName () {
|
||||||
echo "$restricted_authkeys" | sudo tee "${authorized_keys}" >/dev/null
|
openssl rand -hex 4
|
||||||
|
}
|
||||||
|
repositoryName=$(randRepositoryName)
|
||||||
|
|
||||||
## Return the unix user
|
# Append only mode
|
||||||
echo "${user}"
|
if [ "$3" == "true" ]; then
|
||||||
|
appendOnlyMode=" --append-only"
|
||||||
|
else
|
||||||
|
appendOnlyMode=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Add ssh public key in authorized_keys with borg restriction for only 1 repository and storage quota
|
||||||
|
restricted_authkeys="command=\"cd ${pool};borg serve${appendOnlyMode} --restrict-to-path ${pool}/${repositoryName} --storage-quota $2G\",restrict $1"
|
||||||
|
echo "$restricted_authkeys" | tee -a "${authorized_keys}" >/dev/null
|
||||||
|
|
||||||
|
## Return the repositoryName
|
||||||
|
echo "${repositoryName}"
|
|
@ -1,32 +1,47 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Shell created by Raven for BorgWarehouse.
|
# Shell created by Raven for BorgWarehouse.
|
||||||
# This shell takes 1 arg : [user] with 8 char. length only.
|
# This shell takes 1 arg : [repositoryName] with 8 char. length only.
|
||||||
# This shell **delete the user** in arg and **all his data**.
|
# This shell **delete the repository** in arg and **all his data** and the line associated in the authorized_keys file.
|
||||||
|
|
||||||
# Exit when any command fails
|
# Exit when any command fails
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Load .env if exists
|
||||||
|
if [[ -f .env ]]; then
|
||||||
|
source .env
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default value if .env not exists
|
||||||
|
: "${home:=/home/borgwarehouse}"
|
||||||
|
|
||||||
|
# Some variables
|
||||||
|
pool="${home}/repos"
|
||||||
|
authorized_keys="${home}/.ssh/authorized_keys"
|
||||||
|
|
||||||
# Check arg
|
# Check arg
|
||||||
if [[ $# -ne 1 || $1 = "" ]]; then
|
if [[ $# -ne 1 || $1 = "" ]]; then
|
||||||
echo "You must provide a username in argument."
|
echo -n "You must provide a repositoryName in argument."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if username length is 8 char. With createRepo.sh our randoms have a length of 8 characters.
|
# Check if the repositoryName length is 8 char. With createRepo.sh our randoms have a length of 8 characters.
|
||||||
# If we receive another length there is necessarily a problem.
|
# If we receive another length there is necessarily a problem.
|
||||||
username=$1
|
repositoryName=$1
|
||||||
if [ ${#username} != 8 ]
|
if [ ${#repositoryName} != 8 ]; then
|
||||||
then
|
echo -n "Error with the length of the repositoryName."
|
||||||
echo "Error with the length of the username."
|
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete the user if it exists
|
# Delete the repository and the line associated in the authorized_keys file
|
||||||
if id "$1" &>/dev/null; then
|
if [ -d "${pool}/${repositoryName}" ]; then
|
||||||
sudo userdel -rf "$1"
|
# Delete the repository
|
||||||
echo "The user $1 and all his data have been deleted"
|
rm -rf """${pool}""/""${repositoryName:?}"""
|
||||||
|
# Delete the line in the authorized_keys file
|
||||||
|
sed -i "/${repositoryName}/d" "${authorized_keys}"
|
||||||
|
echo -n "The folder ""${pool}"/"${repositoryName}"" and all its data have been deleted. The line associated in the authorized_keys file has been deleted."
|
||||||
else
|
else
|
||||||
echo "The user $1 does not exist"
|
# Delete the line in the authorized_keys file
|
||||||
exit 3
|
sed -i "/${repositoryName}/d" "${authorized_keys}"
|
||||||
|
echo -n "The folder ""${pool}"/"${repositoryName}"" did not exist (repository never initialized or used). The line associated in the authorized_keys file has been deleted."
|
||||||
fi
|
fi
|
|
@ -5,16 +5,12 @@
|
||||||
# stdout will be an array like :
|
# stdout will be an array like :
|
||||||
# [
|
# [
|
||||||
# {
|
# {
|
||||||
# "user": "09d8240f",
|
# "repositoryName": "a7035047",
|
||||||
# "lastSave": 1668513608
|
# "lastSave": 1691341603
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# "user": "635a6f8b",
|
# "repositoryName": "a7035048",
|
||||||
# "lastSave": 1667910810
|
# "lastSave": 1691342688
|
||||||
# },
|
|
||||||
# {
|
|
||||||
# "user": "83bd4ef1",
|
|
||||||
# "lastSave": 1667985985
|
|
||||||
# }
|
# }
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
|
@ -22,6 +18,18 @@
|
||||||
# Exit when any command fails
|
# Exit when any command fails
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
stat --format='{"user":"%U","lastSave":%Y}' \
|
# Load .env if exists
|
||||||
/var/borgwarehouse/*/repos/*/integrity* |
|
if [[ -f .env ]]; then
|
||||||
jq --slurp
|
source .env
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default value if .env not exists
|
||||||
|
: "${home:=/home/borgwarehouse}"
|
||||||
|
|
||||||
|
if [ -n "$(find -L "${home}"/repos -mindepth 1 -maxdepth 1 -type d)" ]; then
|
||||||
|
stat --format='{"repositoryName":"%n","lastSave":%Y}' \
|
||||||
|
"${home}"/repos/*/integrity* |
|
||||||
|
jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]'
|
||||||
|
else
|
||||||
|
echo "[]"
|
||||||
|
fi
|
|
@ -14,6 +14,14 @@
|
||||||
# Exit when any command fails
|
# Exit when any command fails
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Load .env if exists
|
||||||
|
if [[ -f .env ]]; then
|
||||||
|
source .env
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default value if .env not exists
|
||||||
|
: "${home:=/home/borgwarehouse}"
|
||||||
|
|
||||||
# Use jc to output a JSON format with du command
|
# Use jc to output a JSON format with du command
|
||||||
cd /var/borgwarehouse
|
cd "${home}"/repos
|
||||||
sudo /usr/bin/du -s -- * | jc --du
|
du -s -- * | jc --du
|
||||||
|
|
|
@ -1,47 +1,79 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Shell created by Raven for BorgWarehouse.
|
# Shell created by Raven for BorgWarehouse.
|
||||||
# This shell takes 2 args : [user] [new SSH pub key] [quota]
|
# This shell takes 4 args: [repositoryName] [new SSH pub key] [quota] [append-only mode (boolean)]
|
||||||
# This shell updates the ssh key for a repository.
|
# This shell updates the SSH key and the quota for a repository.
|
||||||
|
|
||||||
# Exit when any command fails
|
# Exit when any command fails
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Check args
|
# Load .env if exists
|
||||||
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ];then
|
if [[ -f .env ]]; then
|
||||||
echo "This shell takes 3 args : [user] [new SSH pub key] [quota]"
|
source .env
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Some variables
|
# Default value if .env not exists
|
||||||
home="/var/borgwarehouse/$1"
|
: "${home:=/home/borgwarehouse}"
|
||||||
|
|
||||||
|
# Check args
|
||||||
|
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ] || [ "$4" != "true" ] && [ "$4" != "false" ]; then
|
||||||
|
echo -n "This shell takes 4 args: [repositoryName] [new SSH pub key] [quota] [Append only mode [true|false]]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if the SSH public key is a valid format
|
# Check if the SSH public key is a valid format
|
||||||
# This pattern validates SSH public keys for : rsa, ed25519, ed25519-sk
|
# This pattern validates SSH public keys for : rsa, ed25519, ed25519-sk
|
||||||
pattern='(ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29t|ssh-rsa AAAAB3NzaC1yc2)[0-9A-Za-z+/]+[=]{0,3}(\s.*)?'
|
pattern='(ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29t|ssh-rsa AAAAB3NzaC1yc2)[0-9A-Za-z+/]+[=]{0,3}(\s.*)?'
|
||||||
if [[ ! "$2" =~ $pattern ]]
|
if [[ ! "$2" =~ $pattern ]]
|
||||||
then
|
then
|
||||||
echo "Invalid public SSH KEY format. Provide a key in OpenSSH format (rsa, ed25519, ed25519-sk)"
|
echo -n "Invalid public SSH KEY format. Provide a key in OpenSSH format (rsa, ed25519, ed25519-sk)"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if username length is 8 char. With createRepo.sh our randoms have a length of 8 characters.
|
# Check if repositoryName length is 8 char. With createRepo.sh our randoms have a length of 8 characters.
|
||||||
# If we receive another length there is necessarily a problem.
|
# If we receive another length, there is necessarily a problem.
|
||||||
username=$1
|
repositoryName=$1
|
||||||
if [ ${#username} != 8 ]
|
if [ ${#repositoryName} != 8 ]; then
|
||||||
then
|
echo -n "Error with the length of the repositoryName."
|
||||||
echo "Error with the length of the username."
|
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the user exists
|
# Check if a line in authorized_keys contains repository_name
|
||||||
if ! id "$1" &>/dev/null; then
|
if ! grep -q "command=\".*${repositoryName}.*\",restrict" "$home/.ssh/authorized_keys"; then
|
||||||
echo "The user $1 does not exist"
|
echo -n "No line containing $repositoryName found in authorized_keys"
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Modify authorized_keys for the user : only the ssh key is modify with this regex
|
# Check if the new SSH pub key is already present on a line OTHER than the one corresponding to repositoryName
|
||||||
sudo sed -ri "s|(command=\".*\",restrict ).*|\1$2|g" "$home/.ssh/authorized_keys"
|
found=false
|
||||||
|
regex="command=\".*${repositoryName}.*\",restrict"
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [[ $line =~ $pattern ]]; then
|
||||||
|
# Get the SSH pub key of the line (ignore the comment)
|
||||||
|
key1=$(echo "${BASH_REMATCH[0]}" | awk '{print $1 " " $2}')
|
||||||
|
# Get the SSH pub key of the new SSH pub key (ignore the comment)
|
||||||
|
key2=$(echo "$2" | awk '{print $1 " " $2}')
|
||||||
|
|
||||||
# Modify authorized_keys for the user : only the quota is modify with this regex
|
if [ "$key1" == "$key2" ]; then
|
||||||
sudo sed -ri "s|--storage-quota.*\"|--storage-quota $3G\"|g" "$home/.ssh/authorized_keys"
|
# If the SSH pub key is already present on a line other than the one corresponding to repositoryName
|
||||||
|
if [[ ! $line =~ $regex ]]; then
|
||||||
|
found=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$home/.ssh/authorized_keys"
|
||||||
|
if [ "$found" = true ]; then
|
||||||
|
echo -n "This SSH pub key is already present in authorized_keys on a different line."
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Append only mode
|
||||||
|
if [ "$4" == "true" ]; then
|
||||||
|
sed -ri "/command=\".*${repositoryName}.*\",restrict/ {/borg serve .*--append-only /! s|(borg serve )|\1--append-only |}" "$home/.ssh/authorized_keys"
|
||||||
|
elif [ "$4" == "false" ]; then
|
||||||
|
sed -ri "/command=\".*${repositoryName}.*\",restrict/ s|(--append-only )||g" "$home/.ssh/authorized_keys"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Modify authorized_keys for the repositoryName: update the line with the quota and the SSH pub key
|
||||||
|
sed -ri "s|(command=\".*${repositoryName}.*--storage-quota ).*G\",restrict .*|\\1$3G\",restrict $2|g" "$home/.ssh/authorized_keys"
|
||||||
|
|
BIN
helpers/templates/attachments/alert-icon.png
Normal file
BIN
helpers/templates/attachments/alert-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
helpers/templates/attachments/valid-icon.png
Normal file
BIN
helpers/templates/attachments/valid-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -11,156 +11,125 @@ export default function emailTest(mailTo, username, aliasList) {
|
||||||
from: 'BorgWarehouse' + '<' + process.env.MAIL_SMTP_FROM + '>',
|
from: 'BorgWarehouse' + '<' + process.env.MAIL_SMTP_FROM + '>',
|
||||||
to: mailTo,
|
to: mailTo,
|
||||||
subject: 'Down status alert !',
|
subject: 'Down status alert !',
|
||||||
text: 'Some repositories need attention ! Please, check your BorgWarehouse interface.',
|
text: 'Some repositories require your attention ! Please, check your BorgWarehouse interface.',
|
||||||
html:
|
html:
|
||||||
`
|
`
|
||||||
<div
|
<!DOCTYPE html>
|
||||||
style="
|
<html>
|
||||||
max-width: 37.5em;
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 475px;
|
||||||
|
margin: 40px auto;
|
||||||
border: 1px solid #eaeaea;
|
border: 1px solid #eaeaea;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin: 40px auto;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
max-width: 475px;
|
}
|
||||||
"
|
.header {
|
||||||
>
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
border-image-slice: 1;
|
|
||||||
border-top: 4px solid;
|
border-top: 4px solid;
|
||||||
border-image-source: linear-gradient(
|
border-image-source: linear-gradient(90deg, #020024 0%, #6d4aff 50%, #020024 100%);
|
||||||
90deg,
|
border-image-slice: 1;
|
||||||
#020024 0%,
|
}
|
||||||
#6d4aff 50%,
|
.content {
|
||||||
#020024 100%
|
padding: 20px;
|
||||||
);
|
}
|
||||||
"
|
.title {
|
||||||
></div>
|
|
||||||
|
|
||||||
<div style="padding: 20px; display: flex; flex-direction: column">
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
color: #6d4aff;
|
color: #6d4aff;
|
||||||
font-family: Inter, sans-serif;
|
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
"
|
}
|
||||||
>
|
.icon {
|
||||||
BorgWarehouse
|
display: block;
|
||||||
</div>
|
margin: 30px auto 20px;
|
||||||
<div style="margin: 30px auto 20px">
|
text-align: center;
|
||||||
<svg
|
}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
.message {
|
||||||
class="icon icon-tabler icon-tabler-alert-triangle"
|
|
||||||
width="96"
|
|
||||||
height="96"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
color="#6d4aff"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
||||||
<path d="M12 9v2m0 4v.01"></path>
|
|
||||||
<path
|
|
||||||
d="M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
font-family: Inter, sans-serif;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #494b7a;
|
color: #494b7a;
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
"
|
}
|
||||||
>
|
.description {
|
||||||
<p>Some repositories need attention,<br /> ` +
|
|
||||||
username +
|
|
||||||
` !</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
font-family: Inter, sans-serif;
|
|
||||||
color: #494b7a;
|
color: #494b7a;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
"
|
}
|
||||||
>
|
.alert {
|
||||||
<p>
|
|
||||||
List of repositories with down status :
|
|
||||||
</p>
|
|
||||||
<ul>` +
|
|
||||||
aliasTemplate(aliasList) +
|
|
||||||
`</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
margin: 2rem -0.5rem 0rem -0.5rem;
|
margin: 2rem -0.5rem 0rem -0.5rem;
|
||||||
color: #494b7a;
|
color: #494b7a;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border: 1px solid #6d4aff5c;
|
border: 1px solid #6d4aff5c;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12),
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||||
0 1px 2px rgba(0, 0, 0, 0.24);
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
font-family: Inter, sans-serif;
|
font-family: Inter, sans-serif;
|
||||||
position: relative;
|
|
||||||
padding: 1rem 1.5rem;
|
padding: 1rem 1.5rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
"
|
}
|
||||||
>
|
.footer {
|
||||||
<div style="flex-shrink: 1 !important; margin-right: 0.75rem">
|
|
||||||
🚩
|
|
||||||
</div>
|
|
||||||
<div style="width: 100%">
|
|
||||||
Please remember that the status is based on
|
|
||||||
<b>the last modification</b>. Backups are
|
|
||||||
<b
|
|
||||||
>encrypted from end to end between your client and the
|
|
||||||
server</b
|
|
||||||
>
|
|
||||||
controlled by BorgWarehouse. Don't forget to
|
|
||||||
<a
|
|
||||||
style="text-decoration: none; color: #6d4aff"
|
|
||||||
href="https://borgwarehouse.com/docs/user-manual/setupwizard/#step-3--launch--verify"
|
|
||||||
rel="noreferrer"
|
|
||||||
>check the integrity of your backups regularly</a
|
|
||||||
>.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
color: #c8c8c8;
|
color: #C8C8C8;
|
||||||
font-family: Inter, sans-serif;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
"
|
}
|
||||||
>
|
.footer a {
|
||||||
<p>
|
color: #cfc4fb;
|
||||||
About
|
text-decoration: none;
|
||||||
<a
|
}
|
||||||
style="color: #cfc4fb; text-decoration: none"
|
.alert a {
|
||||||
target="_blank"
|
text-decoration: none;
|
||||||
href="https://borgwarehouse.com/"
|
color: #6d4aff;
|
||||||
rel="noreferrer"
|
}
|
||||||
>BorgWarehouse</a
|
</style>
|
||||||
>
|
</head>
|
||||||
</p>
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header"></div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="title">BorgWarehouse</div>
|
||||||
|
<div class="icon">
|
||||||
|
<img src="cid:alert-icon" alt="alert icon" width="96" height="96">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="message">
|
||||||
`,
|
<p>Some repositories require your attention, ` +
|
||||||
|
username +
|
||||||
|
`!</p>
|
||||||
|
</div>
|
||||||
|
<div class="description">
|
||||||
|
<p>List of repositories with down status:</p>
|
||||||
|
<ul>` +
|
||||||
|
aliasTemplate(aliasList) +
|
||||||
|
`</ul>
|
||||||
|
</div>
|
||||||
|
<div class="alert">
|
||||||
|
<div style="flex-shrink: 1; margin-right: 0.75rem">🚩</div>
|
||||||
|
<div style="width: 100%">
|
||||||
|
Please remember that the status is based on <b>the last modification</b>. Backups are <b>encrypted from end to end between your client and the server</b> controlled by BorgWarehouse. Don't forget to <a href="https://borgwarehouse.com/docs/user-manual/setupwizard/#step-3--launch--verify" rel="noreferrer">check the integrity of your backups regularly</a>.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p>About <a href="https://borgwarehouse.com/" target="_blank" rel="noreferrer">BorgWarehouse</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`,
|
||||||
|
attachments: [
|
||||||
|
{
|
||||||
|
path: 'helpers/templates/attachments/alert-icon.png',
|
||||||
|
cid: 'alert-icon',
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,77 +6,98 @@ export default function emailTest(mailTo, username) {
|
||||||
text: 'If you received this email then the mail configuration seems to be correct.',
|
text: 'If you received this email then the mail configuration seems to be correct.',
|
||||||
html:
|
html:
|
||||||
`
|
`
|
||||||
<div
|
<!DOCTYPE html>
|
||||||
style="
|
<html>
|
||||||
max-width: 37.5em;
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 475px;
|
||||||
|
margin: 40px auto;
|
||||||
border: 1px solid #eaeaea;
|
border: 1px solid #eaeaea;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin: 40px auto;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
max-width: 475px;
|
}
|
||||||
"
|
.header {
|
||||||
>
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
border-image-slice: 1;
|
|
||||||
border-top: 4px solid;
|
border-top: 4px solid;
|
||||||
border-image-source: linear-gradient(
|
border-image-source: linear-gradient(90deg, #020024 0%, #6d4aff 50%, #020024 100%);
|
||||||
90deg,
|
border-image-slice: 1;
|
||||||
#020024 0%,
|
}
|
||||||
#6d4aff 50%,
|
.content {
|
||||||
#020024 100%
|
padding: 20px;
|
||||||
);
|
}
|
||||||
"
|
.title {
|
||||||
></div>
|
|
||||||
|
|
||||||
<div style="padding: 20px; display: flex; flex-direction: column;">
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
color: #6d4aff;
|
color: #6d4aff;
|
||||||
font-family: Inter, sans-serif;
|
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
"
|
}
|
||||||
>
|
.icon {
|
||||||
BorgWarehouse
|
display: block;
|
||||||
</div>
|
margin: 30px auto 20px;
|
||||||
<div style="margin: 30px auto 20px;">
|
text-align: center;
|
||||||
<svg
|
}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
.message {
|
||||||
width="96"
|
font-weight: 500;
|
||||||
height="96"
|
color: #494b7a;
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
color="#563acf"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
||||||
<path d="M7 12l5 5l10 -10"></path>
|
|
||||||
<path d="M2 12l5 5m5 -5l5 -5"></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="font-family: Inter, sans-serif; font-weight: 500; color: #494b7a;
|
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
text-align: center; margin-bottom: 20px;"><p>Good job, ` +
|
text-align: center;
|
||||||
username +
|
margin-bottom: 20px;
|
||||||
` !</p></div>
|
}
|
||||||
|
.description {
|
||||||
<div style="font-family: Inter, sans-serif; color: #494b7a;
|
color: #494b7a;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
text-align: center; margin-bottom: 50px;"><p>If you received this mail then the configuration seems to be correct.</p></div>
|
text-align: center;
|
||||||
|
margin-bottom: 50px;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
font-size: 0.8em;
|
||||||
|
color: #C8C8C8;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.footer a {
|
||||||
|
color: #cfc4fb;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header"></div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="title">BorgWarehouse</div>
|
||||||
|
<div class="icon">
|
||||||
|
<img src="cid:valid-icon" alt="valid icon" width="96" height="96">
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 0.8em;color: #C8C8C8;font-family: Inter, sans-serif; text-align: center;"><p>About <a style="color:#cfc4fb; text-decoration: none;" target="_blank" href="https://borgwarehouse.com/" rel='noreferrer'>BorgWarehouse</a></p></div>
|
<div class="message">
|
||||||
|
<p>Good job, ` +
|
||||||
|
username +
|
||||||
|
`!</p>
|
||||||
|
</div>
|
||||||
|
<div class="description">
|
||||||
|
<p>If you received this mail then the configuration seems to be correct.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p>About <a href="https://borgwarehouse.com/" target="_blank" rel="noreferrer">BorgWarehouse</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
`,
|
`,
|
||||||
|
attachments: [
|
||||||
|
{
|
||||||
|
path: 'helpers/templates/attachments/valid-icon.png',
|
||||||
|
cid: 'valid-icon',
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
3243
package-lock.json
generated
3243
package-lock.json
generated
File diff suppressed because it is too large
Load diff
28
package.json
28
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "borgwarehouse",
|
"name": "borgwarehouse",
|
||||||
"version": "1.5.1",
|
"version": "2.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
@ -9,23 +9,23 @@
|
||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tabler/icons-react": "^2.24.0",
|
"@tabler/icons-react": "^3.7.0",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"chart.js": "^4.3.0",
|
"chart.js": "^4.4.3",
|
||||||
"next": "^13.4.9",
|
"next": "^14.2.4",
|
||||||
"next-auth": "^4.22.1",
|
"next-auth": "^4.24.7",
|
||||||
"nodemailer": "^6.9.3",
|
"nodemailer": "^6.9.14",
|
||||||
"react": "^18.2.0",
|
"react": "^18.3.1",
|
||||||
"react-chartjs-2": "^5.2.0",
|
"react-chartjs-2": "^5.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.3.1",
|
||||||
"react-hook-form": "^7.36.1",
|
"react-hook-form": "^7.52.0",
|
||||||
"react-select": "^5.6.0",
|
"react-select": "^5.8.0",
|
||||||
"react-toastify": "^9.0.8",
|
"react-toastify": "^10.0.5",
|
||||||
"spinners-react": "^1.0.7",
|
"spinners-react": "^1.0.7",
|
||||||
"swr": "^2.2.0"
|
"swr": "^2.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "8.23.1",
|
"eslint-config-next": "^14.2.4",
|
||||||
"eslint-config-next": "^13.4.9"
|
"prettier": "^3.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ export default function MyApp({ Component, pageProps }) {
|
||||||
<link rel='shortcut icon' href='/favicon.ico' />
|
<link rel='shortcut icon' href='/favicon.ico' />
|
||||||
<title>BorgWarehouse</title>
|
<title>BorgWarehouse</title>
|
||||||
</Head>
|
</Head>
|
||||||
<ToastContainer />
|
<ToastContainer stacked />
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
</Layout>
|
</Layout>
|
||||||
</SessionProvider>
|
</SessionProvider>
|
||||||
|
|
49
pages/api/account/getWizardEnv.js
Normal file
49
pages/api/account/getWizardEnv.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//Lib
|
||||||
|
import { authOptions } from '../auth/[...nextauth]';
|
||||||
|
import { getServerSession } from 'next-auth/next';
|
||||||
|
|
||||||
|
export default async function handler(req, res) {
|
||||||
|
if (req.method == 'GET') {
|
||||||
|
//Verify that the user is logged in.
|
||||||
|
const session = await getServerSession(req, res, authOptions);
|
||||||
|
if (!session) {
|
||||||
|
res.status(401).json({ message: 'You must be logged in.' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
function getEnvVariable(envName, defaultValue = '') {
|
||||||
|
return process.env[envName] || defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wizardEnv = {
|
||||||
|
UNIX_USER: getEnvVariable('UNIX_USER', 'borgwarehouse'),
|
||||||
|
FQDN: getEnvVariable('FQDN', 'localhost'),
|
||||||
|
SSH_SERVER_PORT: getEnvVariable('SSH_SERVER_PORT', '22'),
|
||||||
|
FQDN_LAN: getEnvVariable('FQDN_LAN'),
|
||||||
|
SSH_SERVER_PORT_LAN: getEnvVariable('SSH_SERVER_PORT_LAN'),
|
||||||
|
SSH_SERVER_FINGERPRINT_RSA: getEnvVariable(
|
||||||
|
'SSH_SERVER_FINGERPRINT_RSA'
|
||||||
|
),
|
||||||
|
SSH_SERVER_FINGERPRINT_ED25519: getEnvVariable(
|
||||||
|
'SSH_SERVER_FINGERPRINT_ED25519'
|
||||||
|
),
|
||||||
|
SSH_SERVER_FINGERPRINT_ECDSA: getEnvVariable(
|
||||||
|
'SSH_SERVER_FINGERPRINT_ECDSA'
|
||||||
|
),
|
||||||
|
};
|
||||||
|
res.status(200).json({ wizardEnv });
|
||||||
|
return;
|
||||||
|
} catch (error) {
|
||||||
|
//Log for backend
|
||||||
|
console.log(error);
|
||||||
|
//Log for frontend
|
||||||
|
res.status(500).json({
|
||||||
|
status: 500,
|
||||||
|
message: 'API error, contact the administrator',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.status(405).json({ message: 'Bad request on API' });
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,11 +5,20 @@ import { verifyPassword } from '../../../helpers/functions/auth';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
const logLogin = async (message, req, success = false) => {
|
||||||
|
const ipAddress = req.headers['x-forwarded-for'] || 'unknown';
|
||||||
|
if (success) {
|
||||||
|
console.log(`Login success from ${ipAddress} with user ${message}`);
|
||||||
|
} else {
|
||||||
|
console.log(`Login failed from ${ipAddress} : ${message}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
////Use if need getServerSideProps and therefore getServerSession
|
////Use if need getServerSideProps and therefore getServerSession
|
||||||
export const authOptions = {
|
export const authOptions = {
|
||||||
providers: [
|
providers: [
|
||||||
CredentialsProvider({
|
CredentialsProvider({
|
||||||
async authorize(credentials) {
|
async authorize(credentials, req) {
|
||||||
const { username, password } = credentials;
|
const { username, password } = credentials;
|
||||||
//Read the users file
|
//Read the users file
|
||||||
//Find the absolute path of the json directory
|
//Find the absolute path of the json directory
|
||||||
|
@ -21,12 +30,13 @@ export const authOptions = {
|
||||||
JSON.stringify([
|
JSON.stringify([
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
email: 'admin@demo',
|
email: '',
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
password:
|
password:
|
||||||
'$2a$12$20yqRnuaDBH6AE0EvIUcEOzqkuBtn1wDzJdw2Beg8w9S.vEqdso0a',
|
'$2a$12$20yqRnuaDBH6AE0EvIUcEOzqkuBtn1wDzJdw2Beg8w9S.vEqdso0a',
|
||||||
roles: ['admin'],
|
roles: ['admin'],
|
||||||
emailAlert: 'false',
|
emailAlert: false,
|
||||||
|
appriseAlert: false,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
@ -41,8 +51,9 @@ export const authOptions = {
|
||||||
//Step 1 : does the user exist ?
|
//Step 1 : does the user exist ?
|
||||||
const userIndex = usersList
|
const userIndex = usersList
|
||||||
.map((user) => user.username)
|
.map((user) => user.username)
|
||||||
.indexOf(username);
|
.indexOf(username.toLowerCase());
|
||||||
if (userIndex === -1) {
|
if (userIndex === -1) {
|
||||||
|
await logLogin(`Bad username ${req.body.username}`, req);
|
||||||
throw new Error('Incorrect credentials.');
|
throw new Error('Incorrect credentials.');
|
||||||
}
|
}
|
||||||
const user = usersList[userIndex];
|
const user = usersList[userIndex];
|
||||||
|
@ -50,6 +61,10 @@ export const authOptions = {
|
||||||
//Step 2 : Is the password correct ?
|
//Step 2 : Is the password correct ?
|
||||||
const isValid = await verifyPassword(password, user.password);
|
const isValid = await verifyPassword(password, user.password);
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
|
await logLogin(
|
||||||
|
`Wrong password for ${req.body.username}`,
|
||||||
|
req
|
||||||
|
);
|
||||||
throw new Error('Incorrect credentials.');
|
throw new Error('Incorrect credentials.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +76,7 @@ export const authOptions = {
|
||||||
roles: user.roles,
|
roles: user.roles,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
await logLogin(req.body.username, req, true);
|
||||||
return account;
|
return account;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -31,6 +31,20 @@ export default async function handler(req, res) {
|
||||||
|
|
||||||
////PART 1 : Status
|
////PART 1 : Status
|
||||||
try {
|
try {
|
||||||
|
//Check if there are some repositories
|
||||||
|
let repoList = await fs.readFile(
|
||||||
|
jsonDirectory + '/repo.json',
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
repoList = JSON.parse(repoList);
|
||||||
|
if (repoList.length === 0) {
|
||||||
|
res.status(200).json({
|
||||||
|
success:
|
||||||
|
'Status cron has been executed. No repository to check.',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Call the shell : getLastSave.sh
|
//Call the shell : getLastSave.sh
|
||||||
//Find the absolute path of the shells directory
|
//Find the absolute path of the shells directory
|
||||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||||
|
@ -50,19 +64,12 @@ export default async function handler(req, res) {
|
||||||
//Parse the JSON output of getLastSave.sh to use it
|
//Parse the JSON output of getLastSave.sh to use it
|
||||||
const lastSave = JSON.parse(stdout);
|
const lastSave = JSON.parse(stdout);
|
||||||
|
|
||||||
//Find the absolute path of the json directory
|
|
||||||
let repoList = await fs.readFile(
|
|
||||||
jsonDirectory + '/repo.json',
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
//Parse the repoList
|
|
||||||
repoList = JSON.parse(repoList);
|
|
||||||
|
|
||||||
//Rebuild a newRepoList with the lastSave timestamp updated and the status updated.
|
//Rebuild a newRepoList with the lastSave timestamp updated and the status updated.
|
||||||
newRepoList = repoList;
|
newRepoList = repoList;
|
||||||
for (let index in newRepoList) {
|
for (let index in newRepoList) {
|
||||||
const repoFiltered = lastSave.filter(
|
const repoFiltered = lastSave.filter(
|
||||||
(x) => x.user === newRepoList[index].unixUser
|
(x) =>
|
||||||
|
x.repositoryName === newRepoList[index].repositoryName
|
||||||
);
|
);
|
||||||
if (repoFiltered.length === 1) {
|
if (repoFiltered.length === 1) {
|
||||||
//Write the timestamp of the last save
|
//Write the timestamp of the last save
|
||||||
|
@ -95,6 +102,7 @@ export default async function handler(req, res) {
|
||||||
for (let index in newRepoList) {
|
for (let index in newRepoList) {
|
||||||
if (
|
if (
|
||||||
!newRepoList[index].status &&
|
!newRepoList[index].status &&
|
||||||
|
newRepoList[index].alert !== 0 &&
|
||||||
(!newRepoList[index].lastStatusAlertSend ||
|
(!newRepoList[index].lastStatusAlertSend ||
|
||||||
date - newRepoList[index].lastStatusAlertSend > 90000)
|
date - newRepoList[index].lastStatusAlertSend > 90000)
|
||||||
) {
|
) {
|
||||||
|
@ -163,12 +171,6 @@ export default async function handler(req, res) {
|
||||||
transporter.sendMail(mailData, function (err, info) {
|
transporter.sendMail(mailData, function (err, info) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
res.status(400).json({
|
|
||||||
message:
|
|
||||||
'An error occured while sending the email : ' +
|
|
||||||
err,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
console.log(info);
|
console.log(info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default async function handler(req, res) {
|
||||||
let newRepoList = repoList;
|
let newRepoList = repoList;
|
||||||
for (let index in newRepoList) {
|
for (let index in newRepoList) {
|
||||||
const repoFiltered = storageUsed.filter(
|
const repoFiltered = storageUsed.filter(
|
||||||
(x) => x.name === newRepoList[index].unixUser
|
(x) => x.name === newRepoList[index].repositoryName
|
||||||
);
|
);
|
||||||
if (repoFiltered.length === 1) {
|
if (repoFiltered.length === 1) {
|
||||||
newRepoList[index].storageUsed = repoFiltered[0].size;
|
newRepoList[index].storageUsed = repoFiltered[0].size;
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { promises as fs } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { authOptions } from '../../../pages/api/auth/[...nextauth]';
|
import { authOptions } from '../../../pages/api/auth/[...nextauth]';
|
||||||
import { getServerSession } from 'next-auth/next';
|
import { getServerSession } from 'next-auth/next';
|
||||||
|
import repoHistory from '../../../helpers/functions/repoHistory';
|
||||||
const util = require('node:util');
|
const util = require('node:util');
|
||||||
const exec = util.promisify(require('node:child_process').exec);
|
const exec = util.promisify(require('node:child_process').exec);
|
||||||
|
|
||||||
|
@ -15,10 +16,23 @@ export default async function handler(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//The data we expect to receive
|
//The data we expect to receive
|
||||||
const { alias, sshPublicKey, size, comment, alert, lanCommand } =
|
const {
|
||||||
req.body;
|
alias,
|
||||||
|
sshPublicKey,
|
||||||
|
size,
|
||||||
|
comment,
|
||||||
|
alert,
|
||||||
|
lanCommand,
|
||||||
|
appendOnlyMode,
|
||||||
|
} = req.body;
|
||||||
//We check that we receive data for each variable. Only "comment" and "lanCommand" are optional in the form.
|
//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 ||
|
||||||
|
typeof appendOnlyMode !== 'boolean' ||
|
||||||
|
(!alert && alert !== 0)
|
||||||
|
) {
|
||||||
//If a variable is empty.
|
//If a variable is empty.
|
||||||
res.status(422).json({
|
res.status(422).json({
|
||||||
message: 'Unexpected data',
|
message: 'Unexpected data',
|
||||||
|
@ -49,7 +63,7 @@ export default async function handler(req, res) {
|
||||||
const newRepo = {
|
const newRepo = {
|
||||||
id: newID,
|
id: newID,
|
||||||
alias: alias,
|
alias: alias,
|
||||||
repository: 'repo' + newID,
|
repositoryName: '',
|
||||||
status: false,
|
status: false,
|
||||||
lastSave: 0,
|
lastSave: 0,
|
||||||
alert: alert,
|
alert: alert,
|
||||||
|
@ -58,30 +72,26 @@ export default async function handler(req, res) {
|
||||||
sshPublicKey: sshPublicKey,
|
sshPublicKey: sshPublicKey,
|
||||||
comment: comment,
|
comment: comment,
|
||||||
displayDetails: true,
|
displayDetails: true,
|
||||||
unixUser: '',
|
|
||||||
lanCommand: lanCommand,
|
lanCommand: lanCommand,
|
||||||
|
appendOnlyMode: appendOnlyMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
////Call the shell : createRepo.sh
|
////Call the shell : createRepo.sh
|
||||||
//Find the absolute path of the shells directory
|
//Find the absolute path of the shells directory
|
||||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||||
//Exec the shell
|
//Exec the shell
|
||||||
const { stdout, stderr } = await exec(
|
const { stdout } = await exec(
|
||||||
`${shellsDirectory}/shells/createRepo.sh ${newRepo.repository} "${newRepo.sshPublicKey}" ${newRepo.storageSize}`
|
`${shellsDirectory}/shells/createRepo.sh "${newRepo.sshPublicKey}" ${newRepo.storageSize} ${newRepo.appendOnlyMode}`
|
||||||
);
|
);
|
||||||
if (stderr) {
|
|
||||||
console.log('stderr:', stderr);
|
newRepo.repositoryName = stdout.trim();
|
||||||
res.status(500).json({
|
|
||||||
status: 500,
|
|
||||||
message: 'Error on creation, contact the administrator.',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
newRepo.unixUser = stdout.trim();
|
|
||||||
|
|
||||||
//Create the new repoList with the new repo
|
//Create the new repoList with the new repo
|
||||||
let newRepoList = [newRepo, ...repoList];
|
let newRepoList = [newRepo, ...repoList];
|
||||||
|
|
||||||
|
//History the new repoList
|
||||||
|
await repoHistory(newRepoList);
|
||||||
|
|
||||||
//Stringify the newRepoList to write it into the json file.
|
//Stringify the newRepoList to write it into the json file.
|
||||||
newRepoList = JSON.stringify(newRepoList);
|
newRepoList = JSON.stringify(newRepoList);
|
||||||
|
|
||||||
|
@ -106,7 +116,7 @@ export default async function handler(req, res) {
|
||||||
} else {
|
} else {
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
status: 500,
|
status: 500,
|
||||||
message: 'API error, contact the administrator',
|
message: error.stdout,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { promises as fs } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { authOptions } from '../../../auth/[...nextauth]';
|
import { authOptions } from '../../../auth/[...nextauth]';
|
||||||
import { getServerSession } from 'next-auth/next';
|
import { getServerSession } from 'next-auth/next';
|
||||||
|
import repoHistory from '../../../../../helpers/functions/repoHistory';
|
||||||
const util = require('node:util');
|
const util = require('node:util');
|
||||||
const exec = util.promisify(require('node:child_process').exec);
|
const exec = util.promisify(require('node:child_process').exec);
|
||||||
|
|
||||||
|
@ -46,11 +47,10 @@ export default async function handler(req, res) {
|
||||||
//Find the absolute path of the shells directory
|
//Find the absolute path of the shells directory
|
||||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||||
//Exec the shell
|
//Exec the shell
|
||||||
const { stderr } = await exec(
|
const { stdout, stderr } = await exec(
|
||||||
`${shellsDirectory}/shells/deleteRepo.sh ${repoList[indexToDelete].unixUser}`
|
`${shellsDirectory}/shells/deleteRepo.sh ${repoList[indexToDelete].repositoryName}`
|
||||||
);
|
);
|
||||||
//Ignore this normal error with the command userdel in the shell : "userdel: USERXXX mail spool (/var/mail/USERXXX) not found".
|
if (stderr) {
|
||||||
if (stderr && !stderr.includes('mail spool')) {
|
|
||||||
console.log('stderr:', stderr);
|
console.log('stderr:', stderr);
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
status: 500,
|
status: 500,
|
||||||
|
@ -70,7 +70,8 @@ export default async function handler(req, res) {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//History the repoList
|
||||||
|
await repoHistory(repoList);
|
||||||
//Stringify the repoList to write it into the json file.
|
//Stringify the repoList to write it into the json file.
|
||||||
repoList = JSON.stringify(repoList);
|
repoList = JSON.stringify(repoList);
|
||||||
//Write the new json
|
//Write the new json
|
||||||
|
@ -81,6 +82,7 @@ export default async function handler(req, res) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
res.status(200).json({ message: 'Envoi API réussi' });
|
res.status(200).json({ message: 'Envoi API réussi' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//Log for backend
|
//Log for backend
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
import { promises as fs } from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
import { authOptions } from '../../../auth/[...nextauth]';
|
|
||||||
import { getServerSession } from 'next-auth/next';
|
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
|
||||||
if (req.method == 'PUT') {
|
|
||||||
//Verify that the user is logged in.
|
|
||||||
const session = await getServerSession(req, res, authOptions);
|
|
||||||
if (!session) {
|
|
||||||
res.status(401).json({ message: 'You must be logged in.' });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//The data we expect to receive
|
|
||||||
const { displayDetails } = req.body;
|
|
||||||
//We check that we receive displayDetails and it must be a bool.
|
|
||||||
if (typeof displayDetails != 'boolean') {
|
|
||||||
//If a variable is empty.
|
|
||||||
res.status(422).json({
|
|
||||||
message: 'Unexpected data',
|
|
||||||
});
|
|
||||||
//A return to make sure we don't go any further if data are incorrect.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
//console.log('API call (PUT)');
|
|
||||||
//Find the absolute path of the json directory
|
|
||||||
const jsonDirectory = path.join(process.cwd(), '/config');
|
|
||||||
let repoList = await fs.readFile(
|
|
||||||
jsonDirectory + '/repo.json',
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
//Parse the repoList
|
|
||||||
repoList = JSON.parse(repoList);
|
|
||||||
|
|
||||||
//Find the ID in the data and change the values transmitted by the form
|
|
||||||
let newRepoList = repoList.map((repo) =>
|
|
||||||
repo.id == req.query.slug
|
|
||||||
? {
|
|
||||||
...repo,
|
|
||||||
displayDetails: displayDetails,
|
|
||||||
}
|
|
||||||
: repo
|
|
||||||
);
|
|
||||||
//Stringify the newRepoList to write it into the json file.
|
|
||||||
newRepoList = JSON.stringify(newRepoList);
|
|
||||||
//Write the new json
|
|
||||||
await fs.writeFile(
|
|
||||||
jsonDirectory + '/repo.json',
|
|
||||||
newRepoList,
|
|
||||||
(err) => {
|
|
||||||
if (err) console.log(err);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
res.status(200).json({ message: 'Envoi API réussi' });
|
|
||||||
} catch (error) {
|
|
||||||
//Log for backend
|
|
||||||
console.log(error);
|
|
||||||
//Log for frontend
|
|
||||||
if (error.code == 'ENOENT') {
|
|
||||||
res.status(500).json({
|
|
||||||
status: 500,
|
|
||||||
message: 'No such file or directory',
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
res.status(500).json({
|
|
||||||
status: 500,
|
|
||||||
message: 'API error, contact the administrator',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
res.status(405).json({
|
|
||||||
status: 405,
|
|
||||||
message: 'Method Not Allowed ',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ import { promises as fs } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { authOptions } from '../../../auth/[...nextauth]';
|
import { authOptions } from '../../../auth/[...nextauth]';
|
||||||
import { getServerSession } from 'next-auth/next';
|
import { getServerSession } from 'next-auth/next';
|
||||||
|
import repoHistory from '../../../../../helpers/functions/repoHistory';
|
||||||
const util = require('node:util');
|
const util = require('node:util');
|
||||||
const exec = util.promisify(require('node:child_process').exec);
|
const exec = util.promisify(require('node:child_process').exec);
|
||||||
|
|
||||||
|
@ -15,20 +16,30 @@ export default async function handler(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//The data we expect to receive
|
//The data we expect to receive
|
||||||
const { alias, sshPublicKey, size, comment, alert, lanCommand } =
|
const {
|
||||||
req.body;
|
alias,
|
||||||
//We check that we receive data for each variable. Only "comment" and "lanCommand" are optional in the form.
|
sshPublicKey,
|
||||||
if (!alias || !sshPublicKey || !size || !alert) {
|
size,
|
||||||
//If a variable is empty.
|
comment,
|
||||||
|
alert,
|
||||||
|
lanCommand,
|
||||||
|
appendOnlyMode,
|
||||||
|
} = req.body;
|
||||||
|
//Only "comment" and "lanCommand" are optional in the form.
|
||||||
|
if (
|
||||||
|
!alias ||
|
||||||
|
!sshPublicKey ||
|
||||||
|
!size ||
|
||||||
|
typeof appendOnlyMode !== 'boolean' ||
|
||||||
|
(!alert && alert !== 0)
|
||||||
|
) {
|
||||||
res.status(422).json({
|
res.status(422).json({
|
||||||
message: 'Unexpected data',
|
message: 'Unexpected data',
|
||||||
});
|
});
|
||||||
//A return to make sure we don't go any further if data are incorrect.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//console.log('API call (PUT)');
|
|
||||||
//Find the absolute path of the json directory
|
//Find the absolute path of the json directory
|
||||||
const jsonDirectory = path.join(process.cwd(), '/config');
|
const jsonDirectory = path.join(process.cwd(), '/config');
|
||||||
let repoList = await fs.readFile(
|
let repoList = await fs.readFile(
|
||||||
|
@ -48,17 +59,9 @@ export default async function handler(req, res) {
|
||||||
//Find the absolute path of the shells directory
|
//Find the absolute path of the shells directory
|
||||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||||
// //Exec the shell
|
// //Exec the shell
|
||||||
const { stderr } = await exec(
|
await exec(
|
||||||
`${shellsDirectory}/shells/updateRepo.sh ${repoList[repoIndex].unixUser} "${sshPublicKey}" ${size}`
|
`${shellsDirectory}/shells/updateRepo.sh ${repoList[repoIndex].repositoryName} "${sshPublicKey}" ${size} ${appendOnlyMode}`
|
||||||
);
|
);
|
||||||
if (stderr) {
|
|
||||||
console.log('stderr:', stderr);
|
|
||||||
res.status(500).json({
|
|
||||||
status: 500,
|
|
||||||
message: 'Error on update, contact the administrator.',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Find the ID in the data and change the values transmitted by the form
|
//Find the ID in the data and change the values transmitted by the form
|
||||||
let newRepoList = repoList.map((repo) =>
|
let newRepoList = repoList.map((repo) =>
|
||||||
|
@ -67,13 +70,16 @@ export default async function handler(req, res) {
|
||||||
...repo,
|
...repo,
|
||||||
alias: alias,
|
alias: alias,
|
||||||
sshPublicKey: sshPublicKey,
|
sshPublicKey: sshPublicKey,
|
||||||
storageSize: size,
|
storageSize: Number(size),
|
||||||
comment: comment,
|
comment: comment,
|
||||||
alert: alert,
|
alert: alert,
|
||||||
lanCommand: lanCommand,
|
lanCommand: lanCommand,
|
||||||
|
appendOnlyMode: appendOnlyMode,
|
||||||
}
|
}
|
||||||
: repo
|
: repo
|
||||||
);
|
);
|
||||||
|
//History the new repoList
|
||||||
|
await repoHistory(newRepoList);
|
||||||
//Stringify the newRepoList to write it into the json file.
|
//Stringify the newRepoList to write it into the json file.
|
||||||
newRepoList = JSON.stringify(newRepoList);
|
newRepoList = JSON.stringify(newRepoList);
|
||||||
//Write the new json
|
//Write the new json
|
||||||
|
@ -84,6 +90,7 @@ export default async function handler(req, res) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
res.status(200).json({ message: 'Envoi API réussi' });
|
res.status(200).json({ message: 'Envoi API réussi' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//Log for backend
|
//Log for backend
|
||||||
|
@ -97,7 +104,7 @@ export default async function handler(req, res) {
|
||||||
} else {
|
} else {
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
status: 500,
|
status: 500,
|
||||||
message: 'API error, contact the administrator',
|
message: error.stdout,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
16
pages/api/version/index.js
Normal file
16
pages/api/version/index.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import packageInfo from '../../../package.json';
|
||||||
|
|
||||||
|
export default async function handler(req, res) {
|
||||||
|
if (req.method === 'GET') {
|
||||||
|
try {
|
||||||
|
res.status(200).json({ version: packageInfo.version });
|
||||||
|
return;
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
status: 500,
|
||||||
|
message: 'API error, contact the administrator !',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -99,11 +99,14 @@ export default function Login() {
|
||||||
placeholder='Username'
|
placeholder='Username'
|
||||||
className='signInInput'
|
className='signInInput'
|
||||||
{...register('username', {
|
{...register('username', {
|
||||||
required: true,
|
required: 'This field is required.',
|
||||||
|
pattern: {
|
||||||
|
value: /^[^\s]+$/g,
|
||||||
|
message: 'No space allowed.',
|
||||||
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
{errors.email &&
|
{errors.username && (
|
||||||
errors.email.type === 'required' && (
|
|
||||||
<small
|
<small
|
||||||
style={{
|
style={{
|
||||||
color: 'red',
|
color: 'red',
|
||||||
|
@ -111,19 +114,7 @@ export default function Login() {
|
||||||
marginTop: '3px',
|
marginTop: '3px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
This field is required.
|
{errors.username.message}
|
||||||
</small>
|
|
||||||
)}
|
|
||||||
{errors.email &&
|
|
||||||
errors.email.type === 'pattern' && (
|
|
||||||
<small
|
|
||||||
style={{
|
|
||||||
color: 'red',
|
|
||||||
display: 'block',
|
|
||||||
marginTop: '3px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Incorrect email address format.
|
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
@ -133,7 +124,7 @@ export default function Login() {
|
||||||
placeholder='Password'
|
placeholder='Password'
|
||||||
className='signInInput'
|
className='signInInput'
|
||||||
{...register('password', {
|
{...register('password', {
|
||||||
required: true,
|
required: 'This field is required.',
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
{errors.password && (
|
{errors.password && (
|
||||||
|
@ -144,7 +135,7 @@ export default function Login() {
|
||||||
marginTop: '3px',
|
marginTop: '3px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
This field is required.
|
{errors.password.message}
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
|
2
public/robots.txt
Normal file
2
public/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /
|
Loading…
Reference in a new issue