mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-18 05:35:54 +02:00
Compare commits
275 commits
Author | SHA1 | Date | |
---|---|---|---|
|
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
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -108,4 +108,7 @@ dist
|
|||
|
||||
# config file for BorgWarehouse
|
||||
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:
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
rev: 3.0.0
|
||||
hooks:
|
||||
- id: shellcheck
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
rev: 3.0.0
|
||||
hooks:
|
||||
- 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) {
|
||||
////Vars
|
||||
const wizardEnv = props.wizardEnv;
|
||||
//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;
|
||||
if (
|
||||
props.lanCommand &&
|
||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
||||
process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN
|
||||
wizardEnv.FQDN_LAN &&
|
||||
wizardEnv.SSH_SERVER_PORT_LAN
|
||||
) {
|
||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME_LAN;
|
||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN;
|
||||
FQDN = wizardEnv.FQDN_LAN;
|
||||
SSH_SERVER_PORT = wizardEnv.SSH_SERVER_PORT_LAN;
|
||||
} else {
|
||||
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME;
|
||||
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT;
|
||||
FQDN = wizardEnv.FQDN;
|
||||
SSH_SERVER_PORT = wizardEnv.SSH_SERVER_PORT;
|
||||
}
|
||||
|
||||
//State
|
||||
|
@ -29,7 +30,7 @@ export default function QuickCommands(props) {
|
|||
// Asynchronously call copy to clipboard
|
||||
navigator.clipboard
|
||||
.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(() => {
|
||||
// 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.tooltip}>
|
||||
borg init -e repokey-blake2 ssh://{props.unixUser}@
|
||||
{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||
{props.repository}
|
||||
ssh://{wizardEnv.UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||
{props.repositoryName}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{props.lanCommand && <div className={classes.lanBadge}>LAN</div>}
|
||||
|
||||
<div className={classes.icons}>
|
||||
<button onClick={handleCopy} className={classes.copyButton}>
|
||||
<IconCopy color='#65748b' stroke={1.25} />
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
.icons {
|
||||
position: relative;
|
||||
bottom: 14px;
|
||||
bottom: 13px;
|
||||
}
|
||||
|
||||
.quickSetting {
|
||||
|
@ -16,6 +16,15 @@
|
|||
opacity: 1;
|
||||
}
|
||||
|
||||
.lanBadge {
|
||||
border-radius: 5px;
|
||||
border: 1px solid #6d4aff;
|
||||
color: #6d4aff;
|
||||
font-size: 0.9em;
|
||||
padding: 2px 5px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
|
@ -91,6 +100,15 @@
|
|||
opacity: 0;
|
||||
}
|
||||
|
||||
.container:hover .lanBadge {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
@media all and (max-width: 1000px) {
|
||||
.container {
|
||||
display: none;
|
||||
|
|
|
@ -1,28 +1,98 @@
|
|||
//Lib
|
||||
import React from 'react';
|
||||
import { useState } from 'react';
|
||||
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 StorageBar from '../UI/StorageBar/StorageBar';
|
||||
import QuickCommands from './QuickCommands/QuickCommands';
|
||||
|
||||
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 (
|
||||
<>
|
||||
{props.displayDetails ? (
|
||||
{displayDetails ? (
|
||||
<>
|
||||
<div className={classes.RepoOpen}>
|
||||
<div className={classes.openFlex}>
|
||||
{props.status ? (
|
||||
<div
|
||||
className={classes.statusIndicatorGreen}
|
||||
></div>
|
||||
) : (
|
||||
<div
|
||||
className={classes.statusIndicatorRed}
|
||||
></div>
|
||||
)}
|
||||
<div className={statusIndicator()} />
|
||||
<div className={classes.alias}>{props.alias}</div>
|
||||
{appendOnlyModeIndicator()}
|
||||
{alertIndicator()}
|
||||
{props.comment && (
|
||||
<div className={classes.comment}>
|
||||
<IconInfoCircle size={16} color='grey' />
|
||||
|
@ -32,9 +102,9 @@ export default function Repo(props) {
|
|||
</div>
|
||||
)}
|
||||
<QuickCommands
|
||||
unixUser={props.unixUser}
|
||||
repository={props.repository}
|
||||
repositoryName={props.repositoryName}
|
||||
lanCommand={props.lanCommand}
|
||||
wizardEnv={props.wizardEnv}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
@ -57,8 +127,8 @@ export default function Repo(props) {
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{props.repository}</th>
|
||||
<th>{props.storageSize}Go</th>
|
||||
<th>{props.repositoryName}</th>
|
||||
<th>{props.storageSize} GB</th>
|
||||
<th style={{ padding: '0 4% 0 4%' }}>
|
||||
<StorageBar
|
||||
storageUsed={props.storageUsed}
|
||||
|
@ -95,16 +165,10 @@ export default function Repo(props) {
|
|||
<>
|
||||
<div className={classes.RepoClose}>
|
||||
<div className={classes.closeFlex}>
|
||||
{props.status ? (
|
||||
<div
|
||||
className={classes.statusIndicatorGreen}
|
||||
></div>
|
||||
) : (
|
||||
<div
|
||||
className={classes.statusIndicatorRed}
|
||||
></div>
|
||||
)}
|
||||
<div className={statusIndicator()} />
|
||||
<div className={classes.alias}>{props.alias}</div>
|
||||
{appendOnlyModeIndicator()}
|
||||
{alertIndicator()}
|
||||
{props.comment && (
|
||||
<div className={classes.comment}>
|
||||
<IconInfoCircle size={16} color='#637381' />
|
||||
|
@ -127,6 +191,27 @@ export default function Repo(props) {
|
|||
</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;
|
||||
justify-content: space-between;
|
||||
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;
|
||||
max-height: 65px;
|
||||
margin: 20px 0px 0px 0px;
|
||||
|
@ -29,13 +31,15 @@
|
|||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
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;
|
||||
max-height: 200px;
|
||||
margin: 20px 0px 0px 0px;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
transition: max-height 0.2s linear;
|
||||
transition: max-height 0.1s linear;
|
||||
overflow: visible;
|
||||
/* Need to display comment on hover (which is position : absolute) */
|
||||
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 */
|
||||
.alias {
|
||||
font-weight: bold;
|
||||
|
@ -183,7 +203,9 @@
|
|||
margin: 0px 0 0 20px;
|
||||
opacity: 1;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -193,6 +215,17 @@
|
|||
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 */
|
||||
@media all and (max-width: 1000px) {
|
||||
.tabInfo {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//Lib
|
||||
import classes from './Footer.module.css';
|
||||
import packageInfo from '../../../../package.json';
|
||||
|
||||
function Footer() {
|
||||
return (
|
||||
|
@ -13,7 +14,8 @@ function Footer() {
|
|||
rel='noreferrer'
|
||||
>
|
||||
BorgWarehouse
|
||||
</a>
|
||||
</a>{' '}
|
||||
- v{packageInfo.version}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -7,7 +7,20 @@
|
|||
height: 50px;
|
||||
}
|
||||
|
||||
.footer p {
|
||||
padding-left: 70px;
|
||||
}
|
||||
|
||||
a.site {
|
||||
color: #6d4aff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@media all and (max-width: 1000px) {
|
||||
.footer {
|
||||
width: 100%;
|
||||
}
|
||||
.footer p {
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
//Lib
|
||||
import classes from "./Header.module.css";
|
||||
import classes from './Header.module.css';
|
||||
|
||||
//Components
|
||||
import Nav from "./Nav/Nav";
|
||||
import Nav from './Nav/Nav';
|
||||
|
||||
function Header() {
|
||||
return (
|
||||
<header className={classes.Header}>
|
||||
<div className={[classes.flex, 'container'].join(' ')}>
|
||||
<div className={classes.logo}>
|
||||
BorgWarehouse
|
||||
</div>
|
||||
<div className={classes.logo}>BorgWarehouse</div>
|
||||
|
||||
<nav>
|
||||
<Nav />
|
||||
</nav>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export default Header;
|
||||
export default Header;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
.Header {
|
||||
width: 100%;
|
||||
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;
|
||||
color: white;
|
||||
display: flex;
|
||||
|
|
|
@ -38,7 +38,7 @@ export default function Nav() {
|
|||
<div>
|
||||
<IconUser size={28} />
|
||||
</div>
|
||||
<div>
|
||||
<div className={classes.username}>
|
||||
{status === 'authenticated' && data.user.name}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
.username::first-letter {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.account {
|
||||
background: none;
|
||||
border: none;
|
||||
|
|
|
@ -3,7 +3,7 @@ import classes from './StorageBar.module.css';
|
|||
|
||||
export default function StorageBar(props) {
|
||||
//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 = (
|
||||
((props.storageUsed / 1000000) * 100) /
|
||||
props.storageSize
|
||||
|
@ -23,8 +23,8 @@ export default function StorageBar(props) {
|
|||
</div>
|
||||
<div className={classes.tooltip}>
|
||||
{storageUsedPercent}% (
|
||||
{(props.storageUsed / 1000000).toFixed(1)}Go/
|
||||
{props.storageSize}Go)
|
||||
{(props.storageUsed / 1000000).toFixed(1)} GB /{' '}
|
||||
{props.storageSize} GB)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -51,7 +51,9 @@
|
|||
opacity: 0;
|
||||
transform: scale(1);
|
||||
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 */
|
||||
|
@ -75,7 +77,9 @@
|
|||
height: 14px;
|
||||
background-color: rgba(var(--pure-material-onsurface-rgb, 0, 0, 0), 0.38);
|
||||
vertical-align: top;
|
||||
transition: background-color 0.2s, opacity 0.2s;
|
||||
transition:
|
||||
background-color 0.2s,
|
||||
opacity 0.2s;
|
||||
}
|
||||
|
||||
/* Thumb */
|
||||
|
@ -88,9 +92,13 @@
|
|||
width: 20px;
|
||||
height: 20px;
|
||||
background-color: rgb(var(--pure-material-onprimary-rgb, 255, 255, 255));
|
||||
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2),
|
||||
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;
|
||||
box-shadow:
|
||||
0 3px 1px -2px rgba(0, 0, 0, 0.2),
|
||||
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 */
|
||||
|
@ -112,7 +120,9 @@
|
|||
.pureMaterialSwitch > input:active {
|
||||
opacity: 1;
|
||||
transform: scale(0);
|
||||
transition: transform 0s, opacity 0s;
|
||||
transition:
|
||||
transform 0s,
|
||||
opacity 0s;
|
||||
}
|
||||
|
||||
.pureMaterialSwitch > input:active + span::before {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
.container {
|
||||
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;
|
||||
text-align: left;
|
||||
padding: 30px 70px;
|
||||
|
@ -54,8 +56,15 @@ h1 .icon {
|
|||
.code {
|
||||
background-color: #111827;
|
||||
color: #f8f8f2;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
||||
liberation mono, courier new, monospace;
|
||||
font-family:
|
||||
ui-monospace,
|
||||
SFMono-Regular,
|
||||
Menlo,
|
||||
Monaco,
|
||||
Consolas,
|
||||
liberation mono,
|
||||
courier new,
|
||||
monospace;
|
||||
padding: 5px 15px;
|
||||
border-radius: 5px;
|
||||
display: inline-block;
|
||||
|
@ -91,8 +100,15 @@ h1 .icon {
|
|||
|
||||
.verifyOrange li .sshPublicKey {
|
||||
background-color: #282a36;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
||||
liberation mono, courier new, monospace;
|
||||
font-family:
|
||||
ui-monospace,
|
||||
SFMono-Regular,
|
||||
Menlo,
|
||||
Monaco,
|
||||
Consolas,
|
||||
liberation mono,
|
||||
courier new,
|
||||
monospace;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
|
|
@ -3,23 +3,17 @@ import React from 'react';
|
|||
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||
import { IconTool, IconAlertCircle } from '@tabler/icons-react';
|
||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||
|
||||
function WizardStep2(props) {
|
||||
////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.
|
||||
let HOSTNAME;
|
||||
let SSH_SERVER_PORT;
|
||||
if (
|
||||
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 { FQDN, SSH_SERVER_PORT } = lanCommandOption(
|
||||
wizardEnv,
|
||||
props.selectedOption.lanCommand
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={classes.container}>
|
||||
|
@ -39,12 +33,11 @@ function WizardStep2(props) {
|
|||
>
|
||||
<div className={classes.code}>
|
||||
borg init -e repokey-blake2 ssh://
|
||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
||||
{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repository}
|
||||
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repositoryName}
|
||||
</div>
|
||||
<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 className={classes.note}>
|
||||
|
@ -64,7 +57,7 @@ function WizardStep2(props) {
|
|||
<div className={classes.separator}></div>
|
||||
<h2>Borgmatic</h2>
|
||||
<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) :
|
||||
<br />
|
||||
<div
|
||||
|
@ -75,9 +68,9 @@ function WizardStep2(props) {
|
|||
}}
|
||||
>
|
||||
<div className={classes.code}>
|
||||
borg init -e repokey-blake2
|
||||
borgmatic init -e repokey-blake2
|
||||
</div>
|
||||
<CopyButton dataToCopy='borg init -e repokey-blake2' />
|
||||
<CopyButton dataToCopy='borgmatic init -e repokey-blake2' />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -95,12 +88,11 @@ function WizardStep2(props) {
|
|||
>
|
||||
<div className={classes.code}>
|
||||
ssh://
|
||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
||||
{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repository}
|
||||
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repositoryName}
|
||||
</div>
|
||||
<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>
|
||||
For more information about the Vorta graphical client, please
|
||||
|
@ -122,24 +114,21 @@ function WizardStep2(props) {
|
|||
<b>Check the fingerprint of server</b>
|
||||
</div>
|
||||
To check that you are talking to the right server, please make
|
||||
sure to validate the following sshPublicKeys when you first
|
||||
connect :
|
||||
sure to validate one of the following key's fingerprint when you
|
||||
first connect :
|
||||
<li>
|
||||
<span className={classes.sshPublicKey}>
|
||||
ECDSA :{' '}
|
||||
{process.env.NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_ECDSA}
|
||||
ECDSA : {wizardEnv.SSH_SERVER_FINGERPRINT_ECDSA}
|
||||
</span>
|
||||
</li>
|
||||
<li>
|
||||
<span className={classes.sshPublicKey}>
|
||||
ED25519 :{' '}
|
||||
{process.env.NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_ED25519}
|
||||
ED25519 : {wizardEnv.SSH_SERVER_FINGERPRINT_ED25519}
|
||||
</span>
|
||||
</li>
|
||||
<li>
|
||||
<span className={classes.sshPublicKey}>
|
||||
RSA :{' '}
|
||||
{process.env.NEXT_PUBLIC_SSH_SERVER_FINGERPRINT_RSA}
|
||||
RSA : {wizardEnv.SSH_SERVER_FINGERPRINT_RSA}
|
||||
</span>
|
||||
</li>
|
||||
</div>
|
||||
|
|
|
@ -3,23 +3,17 @@ import React from 'react';
|
|||
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||
import { IconChecks, IconPlayerPlay } from '@tabler/icons-react';
|
||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||
|
||||
function WizardStep3(props) {
|
||||
////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.
|
||||
let HOSTNAME;
|
||||
let SSH_SERVER_PORT;
|
||||
if (
|
||||
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 { FQDN, SSH_SERVER_PORT } = lanCommandOption(
|
||||
wizardEnv,
|
||||
props.selectedOption.lanCommand
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={classes.container}>
|
||||
|
@ -38,13 +32,12 @@ function WizardStep3(props) {
|
|||
>
|
||||
<div className={classes.code}>
|
||||
borg create ssh://
|
||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
||||
{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repository}
|
||||
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repositoryName}
|
||||
::archive1 /your/pathToBackup
|
||||
</div>
|
||||
<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>
|
||||
|
@ -85,12 +78,11 @@ function WizardStep3(props) {
|
|||
>
|
||||
<div className={classes.code}>
|
||||
borg check -v --progress ssh://
|
||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
||||
{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repository}
|
||||
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repositoryName}
|
||||
</div>
|
||||
<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>
|
||||
<li>List the remote archives with :</li>
|
||||
|
@ -103,12 +95,11 @@ function WizardStep3(props) {
|
|||
>
|
||||
<div className={classes.code}>
|
||||
borg list ssh://
|
||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
||||
{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repository}
|
||||
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repositoryName}
|
||||
</div>
|
||||
<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>
|
||||
<li>Download a remote archive with the following command :</li>
|
||||
|
@ -121,13 +112,12 @@ function WizardStep3(props) {
|
|||
>
|
||||
<div className={classes.code}>
|
||||
borg export-tar --tar-filter="gzip -9" ssh://
|
||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
||||
{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repository}
|
||||
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repositoryName}
|
||||
::archive1 archive1.tar.gz
|
||||
</div>
|
||||
<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>
|
||||
<li>
|
||||
|
@ -143,13 +133,12 @@ function WizardStep3(props) {
|
|||
>
|
||||
<div className={classes.code}>
|
||||
borg mount ssh://
|
||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
||||
{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repository}
|
||||
{UNIX_USER}@{FQDN}:{SSH_SERVER_PORT}/./
|
||||
{props.selectedOption.repositoryName}
|
||||
::archive1 /tmp/yourMountPoint
|
||||
</div>
|
||||
<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>
|
||||
<br />
|
||||
|
|
|
@ -3,23 +3,17 @@ import React from 'react';
|
|||
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||
import { IconWand } from '@tabler/icons-react';
|
||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||
|
||||
function WizardStep4(props) {
|
||||
////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.
|
||||
let HOSTNAME;
|
||||
let SSH_SERVER_PORT;
|
||||
if (
|
||||
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 { FQDN, SSH_SERVER_PORT } = lanCommandOption(
|
||||
wizardEnv,
|
||||
props.selectedOption.lanCommand
|
||||
);
|
||||
|
||||
const configBorgmatic = `location:
|
||||
# List of source directories to backup.
|
||||
|
@ -29,10 +23,10 @@ function WizardStep4(props) {
|
|||
|
||||
repositories:
|
||||
# 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:
|
||||
archive_name_format: '{HOSTNAME}-documents-{now}'
|
||||
archive_name_format: '{FQDN}-documents-{now}'
|
||||
encryption_passphrase: "YOUR PASSPHRASE"
|
||||
|
||||
retention:
|
||||
|
@ -46,7 +40,7 @@ consistency:
|
|||
checks:
|
||||
- name: repository
|
||||
- name: archives
|
||||
- frequency: 2 weeks
|
||||
frequency: 2 weeks
|
||||
|
||||
#hooks:
|
||||
# Custom preparation scripts to run.
|
||||
|
|
|
@ -78,7 +78,7 @@ export default function StorageUsedChartBar() {
|
|||
datasets: [
|
||||
{
|
||||
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) =>
|
||||
(
|
||||
((repo.storageUsed / 1000000) * 100) /
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//Lib
|
||||
import classes from './RepoList.module.css';
|
||||
import { useState, useEffect, useRef } from 'react';
|
||||
import { IconPlus, IconChevronDown, IconChevronUp } from '@tabler/icons-react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { IconPlus } from '@tabler/icons-react';
|
||||
import { useRouter } from 'next/router';
|
||||
import Link from 'next/link';
|
||||
import useSWR, { useSWRConfig } from 'swr';
|
||||
|
@ -43,12 +43,27 @@ export default function RepoList() {
|
|||
if (router.pathname.startsWith('/manage-repo/edit')) {
|
||||
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
|
||||
const [displayRepoAdd, setDisplayRepoAdd] = useState(false);
|
||||
const [displayRepoEdit, setDisplayRepoEdit] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [wizardEnv, setWizardEnv] = useState({});
|
||||
|
||||
////Functions
|
||||
|
||||
|
@ -67,32 +82,6 @@ export default function RepoList() {
|
|||
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
|
||||
const manageRepoAddHandler = () => {
|
||||
router.replace('/manage-repo/add');
|
||||
|
@ -127,49 +116,17 @@ export default function RepoList() {
|
|||
alias={repo.alias}
|
||||
status={repo.status}
|
||||
lastSave={repo.lastSave}
|
||||
repository={repo.repository}
|
||||
alert={repo.alert}
|
||||
repositoryName={repo.repositoryName}
|
||||
storageSize={repo.storageSize}
|
||||
storageUsed={repo.storageUsed}
|
||||
sshPublicKey={repo.sshPublicKey}
|
||||
displayDetails={repo.displayDetails}
|
||||
unixUser={repo.unixUser}
|
||||
comment={repo.comment}
|
||||
lanCommand={repo.lanCommand}
|
||||
appendOnlyMode={repo.appendOnlyMode}
|
||||
repoManageEditHandler={() => repoManageEditHandler(repo.id)}
|
||||
wizardEnv={wizardEnv}
|
||||
></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);
|
||||
}
|
||||
|
||||
.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) {
|
||||
.newRepoButton {
|
||||
display: none;
|
||||
|
|
|
@ -23,6 +23,7 @@ export default function RepoManage(props) {
|
|||
} = useForm({ mode: 'onChange' });
|
||||
//List of possible times for alerts
|
||||
const alertOptions = [
|
||||
{ value: 0, label: 'Disabled' },
|
||||
{ value: 3600, label: '1 hour' },
|
||||
{ value: 21600, label: '6 hours' },
|
||||
{ value: 43200, label: '12 hours' },
|
||||
|
@ -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
|
||||
const formSubmitHandler = async (dataForm) => {
|
||||
//Loading button on submit to avoid multiple send.
|
||||
setIsLoading(true);
|
||||
//Verify that the SSH key is unique
|
||||
if (!(await isSSHKeyUnique(dataForm.sshkey))) {
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
//ADD a repo
|
||||
if (props.mode == 'add') {
|
||||
const newRepo = {
|
||||
|
@ -121,6 +170,7 @@ export default function RepoManage(props) {
|
|||
comment: dataForm.comment,
|
||||
alert: dataForm.alert.value,
|
||||
lanCommand: dataForm.lanCommand,
|
||||
appendOnlyMode: dataForm.appendOnlyMode,
|
||||
};
|
||||
//POST API to send new repo
|
||||
await fetch('/api/repo/add', {
|
||||
|
@ -130,7 +180,7 @@ export default function RepoManage(props) {
|
|||
},
|
||||
body: JSON.stringify(newRepo),
|
||||
})
|
||||
.then((response) => {
|
||||
.then(async (response) => {
|
||||
if (response.ok) {
|
||||
toast.success(
|
||||
'New repository added ! 🥳',
|
||||
|
@ -138,9 +188,13 @@ export default function RepoManage(props) {
|
|||
);
|
||||
router.replace('/');
|
||||
} else {
|
||||
toast.error('An error has occurred', toastOptions);
|
||||
const errorMessage = await response.json();
|
||||
toast.error(
|
||||
`An error has occurred : ${errorMessage.message}`,
|
||||
toastOptions
|
||||
);
|
||||
router.replace('/');
|
||||
console.log('Fail to post');
|
||||
console.log(`Fail to ${props.mode}`);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -157,6 +211,7 @@ export default function RepoManage(props) {
|
|||
comment: dataForm.comment,
|
||||
alert: dataForm.alert.value,
|
||||
lanCommand: dataForm.lanCommand,
|
||||
appendOnlyMode: dataForm.appendOnlyMode,
|
||||
};
|
||||
await fetch('/api/repo/id/' + router.query.slug + '/edit', {
|
||||
method: 'PUT',
|
||||
|
@ -165,7 +220,7 @@ export default function RepoManage(props) {
|
|||
},
|
||||
body: JSON.stringify(dataEdited),
|
||||
})
|
||||
.then((response) => {
|
||||
.then(async (response) => {
|
||||
if (response.ok) {
|
||||
toast.success(
|
||||
'The repository #' +
|
||||
|
@ -175,9 +230,13 @@ export default function RepoManage(props) {
|
|||
);
|
||||
router.replace('/');
|
||||
} else {
|
||||
toast.error('An error has occurred', toastOptions);
|
||||
const errorMessage = await response.json();
|
||||
toast.error(
|
||||
`An error has occurred : ${errorMessage.message}`,
|
||||
toastOptions
|
||||
);
|
||||
router.replace('/');
|
||||
console.log('Fail to PUT');
|
||||
console.log(`Fail to ${props.mode}`);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -327,9 +386,10 @@ export default function RepoManage(props) {
|
|||
</span>
|
||||
)}
|
||||
{/* SIZE */}
|
||||
<label htmlFor='size'>Storage Size (Go)</label>
|
||||
<label htmlFor='size'>Storage Size (GB)</label>
|
||||
<input
|
||||
type='number'
|
||||
min='1'
|
||||
defaultValue={
|
||||
props.mode == 'edit'
|
||||
? targetRepo.storageSize
|
||||
|
@ -368,7 +428,7 @@ export default function RepoManage(props) {
|
|||
</span>
|
||||
)}
|
||||
{/* LAN COMMAND GENERATION */}
|
||||
<div className={classes.lanCommandWrapper}>
|
||||
<div className={classes.optionCommandWrapper}>
|
||||
<input
|
||||
type='checkbox'
|
||||
name='lanCommand'
|
||||
|
@ -397,6 +457,36 @@ export default function RepoManage(props) {
|
|||
/>
|
||||
</Link>
|
||||
</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 */}
|
||||
<label
|
||||
style={{ margin: '25px auto 10px auto' }}
|
||||
|
@ -414,7 +504,7 @@ export default function RepoManage(props) {
|
|||
x.value ===
|
||||
targetRepo.alert
|
||||
)
|
||||
: alertOptions[3]
|
||||
: alertOptions[4]
|
||||
}
|
||||
control={control}
|
||||
render={({
|
||||
|
|
|
@ -1,268 +1,268 @@
|
|||
.modaleWrapper {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 50px 0px 0px 70px;
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 50px 0px 0px 70px;
|
||||
}
|
||||
|
||||
.modale {
|
||||
position: fixed;
|
||||
top: 10%;
|
||||
width: 1000px;
|
||||
height: auto;
|
||||
max-width: 75%;
|
||||
max-height: 85%;
|
||||
background: #fff;
|
||||
padding: 20px 20px 20px;
|
||||
overflow: auto;
|
||||
border-radius: 10px;
|
||||
box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.4);
|
||||
margin: 0 auto;
|
||||
animation: append-animate 0.3s linear;
|
||||
position: fixed;
|
||||
top: 10%;
|
||||
width: 1000px;
|
||||
height: auto;
|
||||
max-width: 75%;
|
||||
max-height: 85%;
|
||||
background: #fff;
|
||||
padding: 20px 20px 20px;
|
||||
overflow: auto;
|
||||
border-radius: 10px;
|
||||
box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.4);
|
||||
margin: 0 auto;
|
||||
animation: append-animate 0.3s linear;
|
||||
}
|
||||
|
||||
@keyframes append-animate {
|
||||
from {
|
||||
transform: scale(0);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
from {
|
||||
transform: scale(0);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.close {
|
||||
cursor: pointer;
|
||||
margin-left: 95%;
|
||||
color: #494b7a;
|
||||
cursor: pointer;
|
||||
margin-left: 95%;
|
||||
color: #494b7a;
|
||||
}
|
||||
|
||||
.close :hover {
|
||||
color: #aa60ff;
|
||||
color: #aa60ff;
|
||||
}
|
||||
|
||||
.repoManageForm {
|
||||
margin: auto;
|
||||
width: 80%;
|
||||
padding: 15px 30px 30px 30px;
|
||||
border-radius: 5px;
|
||||
text-align: left;
|
||||
margin: auto;
|
||||
width: 80%;
|
||||
padding: 15px 30px 30px 30px;
|
||||
border-radius: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.formWrapper {
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
color: #494b7a;
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
color: #494b7a;
|
||||
}
|
||||
|
||||
.repoManageForm label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
color: #494b7a;
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
color: #494b7a;
|
||||
}
|
||||
|
||||
.repoManageForm input,
|
||||
.repoManageForm textarea,
|
||||
.repoManageForm select {
|
||||
border: 1px solid #6d4aff21;
|
||||
font-size: 16px;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
margin-bottom: 0px;
|
||||
outline: 0;
|
||||
padding: 15px;
|
||||
width: 100%;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 5px;
|
||||
/* color: #1b1340; */
|
||||
color: #494b7a;
|
||||
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03) inset;
|
||||
border: 1px solid #6d4aff21;
|
||||
font-size: 16px;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
margin-bottom: 0px;
|
||||
outline: 0;
|
||||
padding: 15px;
|
||||
width: 100%;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 5px;
|
||||
/* color: #1b1340; */
|
||||
color: #494b7a;
|
||||
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03) inset;
|
||||
}
|
||||
|
||||
.repoManageForm textarea {
|
||||
resize: vertical;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.repoManageForm textarea:focus,
|
||||
.repoManageForm input:focus,
|
||||
.repoManageForm select:focus {
|
||||
outline: 1px solid #6d4aff;
|
||||
box-shadow: 0 0 10px 3px rgba(110, 74, 255, 0.605);
|
||||
outline: 1px solid #6d4aff;
|
||||
box-shadow: 0 0 10px 3px rgba(110, 74, 255, 0.605);
|
||||
}
|
||||
|
||||
.repoManageForm .invalid {
|
||||
background: #f3c7c7;
|
||||
border: 1px solid #e45454;
|
||||
outline: 1px solid #ff4a4a;
|
||||
background: #f3c7c7;
|
||||
border: 1px solid #e45454;
|
||||
outline: 1px solid #ff4a4a;
|
||||
}
|
||||
|
||||
.repoManageForm .invalid:focus {
|
||||
background: #f3c7c7;
|
||||
border: 1px solid #e45454;
|
||||
outline: 1px solid #ff4a4a;
|
||||
box-shadow: 0 0 10px 3px rgba(255, 74, 74, 0.605);
|
||||
background: #f3c7c7;
|
||||
border: 1px solid #e45454;
|
||||
outline: 1px solid #ff4a4a;
|
||||
box-shadow: 0 0 10px 3px rgba(255, 74, 74, 0.605);
|
||||
}
|
||||
|
||||
.repoManageForm button {
|
||||
display: block;
|
||||
margin: 15px auto;
|
||||
display: block;
|
||||
margin: 15px auto;
|
||||
}
|
||||
.repoManageForm button:hover {
|
||||
display: block;
|
||||
margin: 15px auto;
|
||||
display: block;
|
||||
margin: 15px auto;
|
||||
}
|
||||
|
||||
.errorMessage {
|
||||
color: red;
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: red;
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.lanCommandWrapper {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
color: #494b7a;
|
||||
.optionCommandWrapper {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
color: #494b7a;
|
||||
}
|
||||
|
||||
.lanCommandWrapper label {
|
||||
margin: 0;
|
||||
.optionCommandWrapper label {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.lanCommandWrapper input[type='checkbox'] {
|
||||
width: auto;
|
||||
margin-right: 8px;
|
||||
cursor: pointer;
|
||||
accent-color: #6d4aff;
|
||||
.optionCommandWrapper input[type='checkbox'] {
|
||||
width: auto;
|
||||
margin-right: 8px;
|
||||
cursor: pointer;
|
||||
accent-color: #6d4aff;
|
||||
}
|
||||
.lanCommandWrapper input[type='checkbox']:focus {
|
||||
outline: 0;
|
||||
box-shadow: none;
|
||||
accent-color: #6d4aff;
|
||||
.optionCommandWrapper input[type='checkbox']:focus {
|
||||
outline: 0;
|
||||
box-shadow: none;
|
||||
accent-color: #6d4aff;
|
||||
}
|
||||
|
||||
/* DELETE DIALOG */
|
||||
|
||||
.deleteDialogWrapper {
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
width: 80%;
|
||||
height: 100%;
|
||||
max-height: 590px;
|
||||
color: #111827;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
width: 80%;
|
||||
height: 100%;
|
||||
max-height: 590px;
|
||||
color: #111827;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.deleteDialogMessage {
|
||||
background-color: #ea1313;
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
border-radius: 5px;
|
||||
padding: 15px;
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 1.1em;
|
||||
background-color: #ea1313;
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
border-radius: 5px;
|
||||
padding: 15px;
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.cancelButton {
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #c1c1c1;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #c1c1c1;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.cancelButton:hover {
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #9a9a9a;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #9a9a9a;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.cancelButton:active {
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #9a9a9a;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
transform: scale(0.9);
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #9a9a9a;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
.deleteButton {
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #ff0000;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #ff0000;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.deleteButton:hover {
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #ff4b4b;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #ff4b4b;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.deleteButton:active {
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #ff4b4b;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
transform: scale(0.9);
|
||||
border: 0;
|
||||
padding: 10px 15px;
|
||||
background-color: #ff4b4b;
|
||||
color: white;
|
||||
margin: 5px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
.littleDeleteButton {
|
||||
border: none;
|
||||
font-weight: 300;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
font-weight: 300;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.selectAlert {
|
||||
margin: auto auto 35px auto;
|
||||
max-width: 160px;
|
||||
margin: auto auto 35px auto;
|
||||
max-width: 160px;
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ function SetupWizard(props) {
|
|||
const [list, setList] = useState([]);
|
||||
const [listIsLoading, setListIsLoading] = useState(true);
|
||||
const [step, setStep] = useState();
|
||||
const [wizardEnv, setWizardEnv] = useState({});
|
||||
const [selectedOption, setSelectedOption] = useState({
|
||||
id: '#id',
|
||||
repository: 'repo',
|
||||
unixUser: 'user',
|
||||
});
|
||||
|
||||
////LifeCycle
|
||||
|
@ -45,6 +45,21 @@ function SetupWizard(props) {
|
|||
}
|
||||
};
|
||||
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
|
||||
useEffect(() => {
|
||||
|
@ -59,8 +74,7 @@ function SetupWizard(props) {
|
|||
label: `${repo.alias} - #${repo.id}`,
|
||||
value: `${repo.alias} - #${repo.id}`,
|
||||
id: repo.id,
|
||||
repository: repo.repository,
|
||||
unixUser: repo.unixUser,
|
||||
repositoryName: repo.repositoryName,
|
||||
lanCommand: repo.lanCommand,
|
||||
}));
|
||||
|
||||
|
@ -86,11 +100,26 @@ function SetupWizard(props) {
|
|||
if (step == 1) {
|
||||
return <WizardStep1 />;
|
||||
} else if (step == 2) {
|
||||
return <WizardStep2 selectedOption={selectedOption} />;
|
||||
return (
|
||||
<WizardStep2
|
||||
selectedOption={selectedOption}
|
||||
wizardEnv={wizardEnv}
|
||||
/>
|
||||
);
|
||||
} else if (step == 3) {
|
||||
return <WizardStep3 selectedOption={selectedOption} />;
|
||||
return (
|
||||
<WizardStep3
|
||||
selectedOption={selectedOption}
|
||||
wizardEnv={wizardEnv}
|
||||
/>
|
||||
);
|
||||
} 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 [error, setError] = useState(false);
|
||||
const [displayStatelessURL, setDisplayStatelessURL] = useState(false);
|
||||
const [appriseMode, setAppriseMode] = useState('');
|
||||
const [appriseMode, setAppriseMode] = useState('stateless');
|
||||
const [appriseStatelessURL, setAppriseStatelessURL] = useState();
|
||||
|
||||
////LifeCycle
|
||||
|
|
|
@ -86,7 +86,7 @@ export default function PasswordSettings(props) {
|
|||
<p>
|
||||
<input
|
||||
type='password'
|
||||
placeholder='Actual password'
|
||||
placeholder='Current password'
|
||||
{...register('oldPassword', {
|
||||
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">
|
||||
|
||||
[![Next][Next.js]][Next-url]
|
||||
[![React][React.js]][React-url]
|
||||
[![Next][Next.js]][Next-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>
|
||||
|
||||
|
@ -19,7 +24,16 @@
|
|||
</a>
|
||||
</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.**
|
||||
|
||||
|
@ -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.
|
||||
|
||||
## 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**.
|
||||
- `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 ?
|
||||
## ⏬ How to update ?
|
||||
|
||||
Check the online documentation [just here](https://borgwarehouse.com/docs/admin-manual/how-to-update/) !
|
||||
|
||||
<!-- MARKDOWN LINKS & IMAGES -->
|
||||
<!-- 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-url]: https://nextjs.org/
|
||||
[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
|
||||
|
||||
# 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 :
|
||||
# - check if args are present
|
||||
# - check the ssh pub key format
|
||||
# - check if the ssh pub key is already present in authorized_keys
|
||||
# - check if borgbackup package is install
|
||||
# - generate a random username, check if it exists in /etc/passwd
|
||||
# - 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
|
||||
# - generate a random repositoryName
|
||||
# - 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.
|
||||
# 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.
|
||||
|
||||
# Limitation : all SSH pubkey are unique : https://github.com/borgbackup/borg/issues/7757
|
||||
|
||||
# Exit when any command fails
|
||||
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
|
||||
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ];then
|
||||
echo "This shell takes 3 argument : Reponame, SSH Public Key, Quota in Go [e.g. : 10] "
|
||||
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" != "true" ] && [ "$3" != "false" ];then
|
||||
echo -n "This shell takes 3 arguments : SSH Public Key, Quota in Go [e.g. : 10], Append only mode [true|false]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the SSH public key is a valid format
|
||||
# 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.*)?'
|
||||
if [[ ! "$2" =~ $pattern ]]
|
||||
if [[ ! "$1" =~ $pattern ]]
|
||||
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
|
||||
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
|
||||
if ! [ -x "$(command -v borg)" ]; then
|
||||
echo "You must install borgbackup package."
|
||||
exit 3
|
||||
echo -n "You must install borgbackup package."
|
||||
exit 4
|
||||
fi
|
||||
|
||||
# Generation of a random for username
|
||||
randUsername () {
|
||||
# Generation of a random for repositoryName
|
||||
randRepositoryName () {
|
||||
openssl rand -hex 4
|
||||
}
|
||||
user=$(randUsername)
|
||||
repositoryName=$(randRepositoryName)
|
||||
|
||||
# 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
|
||||
# Append only mode
|
||||
if [ "$3" == "true" ]; then
|
||||
appendOnlyMode=" --append-only"
|
||||
else
|
||||
appendOnlyMode=""
|
||||
fi
|
||||
|
||||
## Add ssh public key in authorized_keys with borg restriction for only 1 repository (:$1) and storage quota
|
||||
restricted_authkeys="command=\"cd ${pool};borg serve --restrict-to-repository ${pool}/$1 --storage-quota $3G\",restrict $2"
|
||||
echo "$restricted_authkeys" | sudo tee "${authorized_keys}" >/dev/null
|
||||
## 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 unix user
|
||||
echo "${user}"
|
||||
## Return the repositoryName
|
||||
echo "${repositoryName}"
|
|
@ -1,32 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Shell created by Raven for BorgWarehouse.
|
||||
# This shell takes 1 arg : [user] with 8 char. length only.
|
||||
# This shell **delete the user** in arg and **all his data**.
|
||||
# This shell takes 1 arg : [repositoryName] with 8 char. length only.
|
||||
# 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
|
||||
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
|
||||
if [[ $# -ne 1 || $1 = "" ]]; then
|
||||
echo "You must provide a username in argument."
|
||||
echo -n "You must provide a repositoryName in argument."
|
||||
exit 1
|
||||
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.
|
||||
username=$1
|
||||
if [ ${#username} != 8 ]
|
||||
then
|
||||
echo "Error with the length of the username."
|
||||
repositoryName=$1
|
||||
if [ ${#repositoryName} != 8 ]; then
|
||||
echo -n "Error with the length of the repositoryName."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Delete the user if it exists
|
||||
if id "$1" &>/dev/null; then
|
||||
sudo userdel -rf "$1"
|
||||
echo "The user $1 and all his data have been deleted"
|
||||
# Delete the repository and the line associated in the authorized_keys file
|
||||
if [ -d "${pool}/${repositoryName}" ]; then
|
||||
# Delete the repository
|
||||
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
|
||||
echo "The user $1 does not exist"
|
||||
exit 3
|
||||
fi
|
||||
# Delete the line in the authorized_keys file
|
||||
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
|
|
@ -5,16 +5,12 @@
|
|||
# stdout will be an array like :
|
||||
# [
|
||||
# {
|
||||
# "user": "09d8240f",
|
||||
# "lastSave": 1668513608
|
||||
# "repositoryName": "a7035047",
|
||||
# "lastSave": 1691341603
|
||||
# },
|
||||
# {
|
||||
# "user": "635a6f8b",
|
||||
# "lastSave": 1667910810
|
||||
# },
|
||||
# {
|
||||
# "user": "83bd4ef1",
|
||||
# "lastSave": 1667985985
|
||||
# "repositoryName": "a7035048",
|
||||
# "lastSave": 1691342688
|
||||
# }
|
||||
# ]
|
||||
|
||||
|
@ -22,6 +18,18 @@
|
|||
# Exit when any command fails
|
||||
set -e
|
||||
|
||||
stat --format='{"user":"%U","lastSave":%Y}' \
|
||||
/var/borgwarehouse/*/repos/*/integrity* |
|
||||
jq --slurp
|
||||
# Load .env if exists
|
||||
if [[ -f .env ]]; then
|
||||
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
|
||||
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
|
||||
cd /var/borgwarehouse
|
||||
sudo /usr/bin/du -s -- * | jc --du
|
||||
cd "${home}"/repos
|
||||
du -s -- * | jc --du
|
||||
|
|
|
@ -1,47 +1,79 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Shell created by Raven for BorgWarehouse.
|
||||
# This shell takes 2 args : [user] [new SSH pub key] [quota]
|
||||
# This shell updates the ssh key for a repository.
|
||||
# This shell takes 4 args: [repositoryName] [new SSH pub key] [quota] [append-only mode (boolean)]
|
||||
# This shell updates the SSH key and the quota for a repository.
|
||||
|
||||
# Exit when any command fails
|
||||
set -e
|
||||
|
||||
# Check args
|
||||
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ];then
|
||||
echo "This shell takes 3 args : [user] [new SSH pub key] [quota]"
|
||||
exit 1
|
||||
# Load .env if exists
|
||||
if [[ -f .env ]]; then
|
||||
source .env
|
||||
fi
|
||||
|
||||
# Some variables
|
||||
home="/var/borgwarehouse/$1"
|
||||
# Default value if .env not exists
|
||||
: "${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
|
||||
# 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.*)?'
|
||||
if [[ ! "$2" =~ $pattern ]]
|
||||
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
|
||||
fi
|
||||
|
||||
# Check if username 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.
|
||||
username=$1
|
||||
if [ ${#username} != 8 ]
|
||||
then
|
||||
echo "Error with the length of the username."
|
||||
# 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.
|
||||
repositoryName=$1
|
||||
if [ ${#repositoryName} != 8 ]; then
|
||||
echo -n "Error with the length of the repositoryName."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Check if the user exists
|
||||
if ! id "$1" &>/dev/null; then
|
||||
echo "The user $1 does not exist"
|
||||
# Check if a line in authorized_keys contains repository_name
|
||||
if ! grep -q "command=\".*${repositoryName}.*\",restrict" "$home/.ssh/authorized_keys"; then
|
||||
echo -n "No line containing $repositoryName found in authorized_keys"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
# Modify authorized_keys for the user : only the ssh key is modify with this regex
|
||||
sudo sed -ri "s|(command=\".*\",restrict ).*|\1$2|g" "$home/.ssh/authorized_keys"
|
||||
# Check if the new SSH pub key is already present on a line OTHER than the one corresponding to repositoryName
|
||||
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}')
|
||||
|
||||
if [ "$key1" == "$key2" ]; then
|
||||
# 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
|
||||
|
||||
# Modify authorized_keys for the user : only the quota is modify with this regex
|
||||
sudo sed -ri "s|--storage-quota.*\"|--storage-quota $3G\"|g" "$home/.ssh/authorized_keys"
|
||||
# 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"
|
||||
|
|
3241
package-lock.json
generated
3241
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",
|
||||
"version": "1.5.1",
|
||||
"version": "2.3.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
@ -9,23 +9,23 @@
|
|||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tabler/icons-react": "^2.24.0",
|
||||
"@tabler/icons-react": "^3.6.0",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"chart.js": "^4.3.0",
|
||||
"next": "^13.4.9",
|
||||
"next-auth": "^4.22.1",
|
||||
"nodemailer": "^6.9.3",
|
||||
"react": "^18.2.0",
|
||||
"chart.js": "^4.4.3",
|
||||
"next": "^14.2.4",
|
||||
"next-auth": "^4.24.7",
|
||||
"nodemailer": "^6.9.13",
|
||||
"react": "^18.3.1",
|
||||
"react-chartjs-2": "^5.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-hook-form": "^7.36.1",
|
||||
"react-select": "^5.6.0",
|
||||
"react-toastify": "^9.0.8",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-hook-form": "^7.51.5",
|
||||
"react-select": "^5.8.0",
|
||||
"react-toastify": "^10.0.5",
|
||||
"spinners-react": "^1.0.7",
|
||||
"swr": "^2.2.0"
|
||||
"swr": "^2.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "8.23.1",
|
||||
"eslint-config-next": "^13.4.9"
|
||||
"eslint-config-next": "^14.2.4",
|
||||
"prettier": "^3.3.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ export default function MyApp({ Component, pageProps }) {
|
|||
<link rel='shortcut icon' href='/favicon.ico' />
|
||||
<title>BorgWarehouse</title>
|
||||
</Head>
|
||||
<ToastContainer />
|
||||
<ToastContainer stacked />
|
||||
<Component {...pageProps} />
|
||||
</Layout>
|
||||
</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 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
|
||||
export const authOptions = {
|
||||
providers: [
|
||||
CredentialsProvider({
|
||||
async authorize(credentials) {
|
||||
async authorize(credentials, req) {
|
||||
const { username, password } = credentials;
|
||||
//Read the users file
|
||||
//Find the absolute path of the json directory
|
||||
|
@ -21,12 +30,13 @@ export const authOptions = {
|
|||
JSON.stringify([
|
||||
{
|
||||
id: 0,
|
||||
email: 'admin@demo',
|
||||
email: '',
|
||||
username: 'admin',
|
||||
password:
|
||||
'$2a$12$20yqRnuaDBH6AE0EvIUcEOzqkuBtn1wDzJdw2Beg8w9S.vEqdso0a',
|
||||
roles: ['admin'],
|
||||
emailAlert: 'false',
|
||||
emailAlert: false,
|
||||
appriseAlert: false,
|
||||
},
|
||||
])
|
||||
);
|
||||
|
@ -41,8 +51,9 @@ export const authOptions = {
|
|||
//Step 1 : does the user exist ?
|
||||
const userIndex = usersList
|
||||
.map((user) => user.username)
|
||||
.indexOf(username);
|
||||
.indexOf(username.toLowerCase());
|
||||
if (userIndex === -1) {
|
||||
await logLogin(`Bad username ${req.body.username}`, req);
|
||||
throw new Error('Incorrect credentials.');
|
||||
}
|
||||
const user = usersList[userIndex];
|
||||
|
@ -50,6 +61,10 @@ export const authOptions = {
|
|||
//Step 2 : Is the password correct ?
|
||||
const isValid = await verifyPassword(password, user.password);
|
||||
if (!isValid) {
|
||||
await logLogin(
|
||||
`Wrong password for ${req.body.username}`,
|
||||
req
|
||||
);
|
||||
throw new Error('Incorrect credentials.');
|
||||
}
|
||||
|
||||
|
@ -61,6 +76,7 @@ export const authOptions = {
|
|||
roles: user.roles,
|
||||
};
|
||||
|
||||
await logLogin(req.body.username, req, true);
|
||||
return account;
|
||||
},
|
||||
}),
|
||||
|
|
|
@ -31,6 +31,20 @@ export default async function handler(req, res) {
|
|||
|
||||
////PART 1 : Status
|
||||
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
|
||||
//Find the absolute path of the shells directory
|
||||
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
|
||||
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.
|
||||
newRepoList = repoList;
|
||||
for (let index in newRepoList) {
|
||||
const repoFiltered = lastSave.filter(
|
||||
(x) => x.user === newRepoList[index].unixUser
|
||||
(x) =>
|
||||
x.repositoryName === newRepoList[index].repositoryName
|
||||
);
|
||||
if (repoFiltered.length === 1) {
|
||||
//Write the timestamp of the last save
|
||||
|
@ -95,6 +102,7 @@ export default async function handler(req, res) {
|
|||
for (let index in newRepoList) {
|
||||
if (
|
||||
!newRepoList[index].status &&
|
||||
newRepoList[index].alert !== 0 &&
|
||||
(!newRepoList[index].lastStatusAlertSend ||
|
||||
date - newRepoList[index].lastStatusAlertSend > 90000)
|
||||
) {
|
||||
|
@ -163,12 +171,6 @@ export default async function handler(req, res) {
|
|||
transporter.sendMail(mailData, function (err, info) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
res.status(400).json({
|
||||
message:
|
||||
'An error occured while sending the email : ' +
|
||||
err,
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
console.log(info);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ export default async function handler(req, res) {
|
|||
let newRepoList = repoList;
|
||||
for (let index in newRepoList) {
|
||||
const repoFiltered = storageUsed.filter(
|
||||
(x) => x.name === newRepoList[index].unixUser
|
||||
(x) => x.name === newRepoList[index].repositoryName
|
||||
);
|
||||
if (repoFiltered.length === 1) {
|
||||
newRepoList[index].storageUsed = repoFiltered[0].size;
|
||||
|
|
|
@ -2,6 +2,7 @@ import { promises as fs } from 'fs';
|
|||
import path from 'path';
|
||||
import { authOptions } from '../../../pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import repoHistory from '../../../helpers/functions/repoHistory';
|
||||
const util = require('node:util');
|
||||
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
|
||||
const { alias, sshPublicKey, size, comment, alert, lanCommand } =
|
||||
req.body;
|
||||
const {
|
||||
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.
|
||||
if (!alias || !sshPublicKey || !size || !alert) {
|
||||
if (
|
||||
!alias ||
|
||||
!sshPublicKey ||
|
||||
!size ||
|
||||
typeof appendOnlyMode !== 'boolean' ||
|
||||
(!alert && alert !== 0)
|
||||
) {
|
||||
//If a variable is empty.
|
||||
res.status(422).json({
|
||||
message: 'Unexpected data',
|
||||
|
@ -49,7 +63,7 @@ export default async function handler(req, res) {
|
|||
const newRepo = {
|
||||
id: newID,
|
||||
alias: alias,
|
||||
repository: 'repo' + newID,
|
||||
repositoryName: '',
|
||||
status: false,
|
||||
lastSave: 0,
|
||||
alert: alert,
|
||||
|
@ -58,30 +72,26 @@ export default async function handler(req, res) {
|
|||
sshPublicKey: sshPublicKey,
|
||||
comment: comment,
|
||||
displayDetails: true,
|
||||
unixUser: '',
|
||||
lanCommand: lanCommand,
|
||||
appendOnlyMode: appendOnlyMode,
|
||||
};
|
||||
|
||||
////Call the shell : createRepo.sh
|
||||
//Find the absolute path of the shells directory
|
||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||
//Exec the shell
|
||||
const { stdout, stderr } = await exec(
|
||||
`${shellsDirectory}/shells/createRepo.sh ${newRepo.repository} "${newRepo.sshPublicKey}" ${newRepo.storageSize}`
|
||||
const { stdout } = await exec(
|
||||
`${shellsDirectory}/shells/createRepo.sh "${newRepo.sshPublicKey}" ${newRepo.storageSize} ${newRepo.appendOnlyMode}`
|
||||
);
|
||||
if (stderr) {
|
||||
console.log('stderr:', stderr);
|
||||
res.status(500).json({
|
||||
status: 500,
|
||||
message: 'Error on creation, contact the administrator.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
newRepo.unixUser = stdout.trim();
|
||||
|
||||
newRepo.repositoryName = stdout.trim();
|
||||
|
||||
//Create the new repoList with the new repo
|
||||
let newRepoList = [newRepo, ...repoList];
|
||||
|
||||
//History the new repoList
|
||||
await repoHistory(newRepoList);
|
||||
|
||||
//Stringify the newRepoList to write it into the json file.
|
||||
newRepoList = JSON.stringify(newRepoList);
|
||||
|
||||
|
@ -106,7 +116,7 @@ export default async function handler(req, res) {
|
|||
} else {
|
||||
res.status(500).json({
|
||||
status: 500,
|
||||
message: 'API error, contact the administrator',
|
||||
message: error.stdout,
|
||||
});
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -2,6 +2,7 @@ import { promises as fs } from 'fs';
|
|||
import path from 'path';
|
||||
import { authOptions } from '../../../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import repoHistory from '../../../../../helpers/functions/repoHistory';
|
||||
const util = require('node:util');
|
||||
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
|
||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||
//Exec the shell
|
||||
const { stderr } = await exec(
|
||||
`${shellsDirectory}/shells/deleteRepo.sh ${repoList[indexToDelete].unixUser}`
|
||||
const { stdout, stderr } = await exec(
|
||||
`${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 && !stderr.includes('mail spool')) {
|
||||
if (stderr) {
|
||||
console.log('stderr:', stderr);
|
||||
res.status(500).json({
|
||||
status: 500,
|
||||
|
@ -70,7 +70,8 @@ export default async function handler(req, res) {
|
|||
});
|
||||
return;
|
||||
}
|
||||
|
||||
//History the repoList
|
||||
await repoHistory(repoList);
|
||||
//Stringify the repoList to write it into the json file.
|
||||
repoList = JSON.stringify(repoList);
|
||||
//Write the new json
|
||||
|
@ -81,6 +82,7 @@ export default async function handler(req, res) {
|
|||
if (err) console.log(err);
|
||||
}
|
||||
);
|
||||
|
||||
res.status(200).json({ message: 'Envoi API réussi' });
|
||||
} catch (error) {
|
||||
//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 { authOptions } from '../../../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import repoHistory from '../../../../../helpers/functions/repoHistory';
|
||||
const util = require('node:util');
|
||||
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
|
||||
const { alias, sshPublicKey, size, comment, alert, lanCommand } =
|
||||
req.body;
|
||||
//We check that we receive data for each variable. Only "comment" and "lanCommand" are optional in the form.
|
||||
if (!alias || !sshPublicKey || !size || !alert) {
|
||||
//If a variable is empty.
|
||||
const {
|
||||
alias,
|
||||
sshPublicKey,
|
||||
size,
|
||||
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({
|
||||
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(
|
||||
|
@ -48,17 +59,9 @@ export default async function handler(req, res) {
|
|||
//Find the absolute path of the shells directory
|
||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||
// //Exec the shell
|
||||
const { stderr } = await exec(
|
||||
`${shellsDirectory}/shells/updateRepo.sh ${repoList[repoIndex].unixUser} "${sshPublicKey}" ${size}`
|
||||
await exec(
|
||||
`${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
|
||||
let newRepoList = repoList.map((repo) =>
|
||||
|
@ -67,13 +70,16 @@ export default async function handler(req, res) {
|
|||
...repo,
|
||||
alias: alias,
|
||||
sshPublicKey: sshPublicKey,
|
||||
storageSize: size,
|
||||
storageSize: Number(size),
|
||||
comment: comment,
|
||||
alert: alert,
|
||||
lanCommand: lanCommand,
|
||||
appendOnlyMode: appendOnlyMode,
|
||||
}
|
||||
: repo
|
||||
);
|
||||
//History the new repoList
|
||||
await repoHistory(newRepoList);
|
||||
//Stringify the newRepoList to write it into the json file.
|
||||
newRepoList = JSON.stringify(newRepoList);
|
||||
//Write the new json
|
||||
|
@ -84,6 +90,7 @@ export default async function handler(req, res) {
|
|||
if (err) console.log(err);
|
||||
}
|
||||
);
|
||||
|
||||
res.status(200).json({ message: 'Envoi API réussi' });
|
||||
} catch (error) {
|
||||
//Log for backend
|
||||
|
@ -97,7 +104,7 @@ export default async function handler(req, res) {
|
|||
} else {
|
||||
res.status(500).json({
|
||||
status: 500,
|
||||
message: 'API error, contact the administrator',
|
||||
message: error.stdout,
|
||||
});
|
||||
}
|
||||
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,33 +99,24 @@ export default function Login() {
|
|||
placeholder='Username'
|
||||
className='signInInput'
|
||||
{...register('username', {
|
||||
required: true,
|
||||
required: 'This field is required.',
|
||||
pattern: {
|
||||
value: /^[^\s]+$/g,
|
||||
message: 'No space allowed.',
|
||||
},
|
||||
})}
|
||||
/>
|
||||
{errors.email &&
|
||||
errors.email.type === 'required' && (
|
||||
<small
|
||||
style={{
|
||||
color: 'red',
|
||||
display: 'block',
|
||||
marginTop: '3px',
|
||||
}}
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
)}
|
||||
{errors.email &&
|
||||
errors.email.type === 'pattern' && (
|
||||
<small
|
||||
style={{
|
||||
color: 'red',
|
||||
display: 'block',
|
||||
marginTop: '3px',
|
||||
}}
|
||||
>
|
||||
Incorrect email address format.
|
||||
</small>
|
||||
)}
|
||||
{errors.username && (
|
||||
<small
|
||||
style={{
|
||||
color: 'red',
|
||||
display: 'block',
|
||||
marginTop: '3px',
|
||||
}}
|
||||
>
|
||||
{errors.username.message}
|
||||
</small>
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
<input
|
||||
|
@ -133,7 +124,7 @@ export default function Login() {
|
|||
placeholder='Password'
|
||||
className='signInInput'
|
||||
{...register('password', {
|
||||
required: true,
|
||||
required: 'This field is required.',
|
||||
})}
|
||||
/>
|
||||
{errors.password && (
|
||||
|
@ -144,7 +135,7 @@ export default function Login() {
|
|||
marginTop: '3px',
|
||||
}}
|
||||
>
|
||||
This field is required.
|
||||
{errors.password.message}
|
||||
</small>
|
||||
)}
|
||||
</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