mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-01 13:32:22 +02:00
feat: unixUser is now unique and retrieved by env
This commit is contained in:
parent
a7beb7b37f
commit
a735144a55
|
@ -9,6 +9,7 @@ export default function QuickCommands(props) {
|
||||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||||
let HOSTNAME;
|
let HOSTNAME;
|
||||||
let SSH_SERVER_PORT;
|
let SSH_SERVER_PORT;
|
||||||
|
let UNIX_USER = process.env.NEXT_PUBLIC_UNIX_USER;
|
||||||
if (
|
if (
|
||||||
props.lanCommand &&
|
props.lanCommand &&
|
||||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
||||||
|
@ -29,7 +30,7 @@ export default function QuickCommands(props) {
|
||||||
// Asynchronously call copy to clipboard
|
// Asynchronously call copy to clipboard
|
||||||
navigator.clipboard
|
navigator.clipboard
|
||||||
.writeText(
|
.writeText(
|
||||||
`borg init -e repokey-blake2 ssh://${props.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.repositoryName}`
|
`borg init -e repokey-blake2 ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.repositoryName}`
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// If successful, update the isCopied state value
|
// If successful, update the isCopied state value
|
||||||
|
@ -49,8 +50,8 @@ export default function QuickCommands(props) {
|
||||||
<div className={classes.copyValid}>Copied !</div>
|
<div className={classes.copyValid}>Copied !</div>
|
||||||
) : (
|
) : (
|
||||||
<div className={classes.tooltip}>
|
<div className={classes.tooltip}>
|
||||||
borg init -e repokey-blake2 ssh://{props.unixUser}@
|
borg init -e repokey-blake2 ssh://{UNIX_USER}@{HOSTNAME}:
|
||||||
{HOSTNAME}:{SSH_SERVER_PORT}/./
|
{SSH_SERVER_PORT}/./
|
||||||
{props.repositoryName}
|
{props.repositoryName}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -78,7 +78,6 @@ export default function Repo(props) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<QuickCommands
|
<QuickCommands
|
||||||
unixUser={props.unixUser}
|
|
||||||
repositoryName={props.repositoryName}
|
repositoryName={props.repositoryName}
|
||||||
lanCommand={props.lanCommand}
|
lanCommand={props.lanCommand}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -9,6 +9,7 @@ function WizardStep2(props) {
|
||||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||||
let HOSTNAME;
|
let HOSTNAME;
|
||||||
let SSH_SERVER_PORT;
|
let SSH_SERVER_PORT;
|
||||||
|
let UNIX_USER = process.env.NEXT_PUBLIC_UNIX_USER;
|
||||||
if (
|
if (
|
||||||
props.selectedOption.lanCommand &&
|
props.selectedOption.lanCommand &&
|
||||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
||||||
|
@ -39,12 +40,11 @@ function WizardStep2(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg init -e repokey-blake2 ssh://
|
borg init -e repokey-blake2 ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
|
||||||
{props.selectedOption.repositoryName}
|
{props.selectedOption.repositoryName}
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg init -e repokey-blake2 ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
dataToCopy={`borg init -e repokey-blake2 ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.note}>
|
<div className={classes.note}>
|
||||||
|
@ -95,12 +95,11 @@ function WizardStep2(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
ssh://
|
ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
|
||||||
{props.selectedOption.repositoryName}
|
{props.selectedOption.repositoryName}
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
dataToCopy={`ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
For more information about the Vorta graphical client, please
|
For more information about the Vorta graphical client, please
|
||||||
|
|
|
@ -9,6 +9,7 @@ function WizardStep3(props) {
|
||||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||||
let HOSTNAME;
|
let HOSTNAME;
|
||||||
let SSH_SERVER_PORT;
|
let SSH_SERVER_PORT;
|
||||||
|
let UNIX_USER = process.env.NEXT_PUBLIC_UNIX_USER;
|
||||||
if (
|
if (
|
||||||
props.selectedOption.lanCommand &&
|
props.selectedOption.lanCommand &&
|
||||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
||||||
|
@ -38,13 +39,12 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg create ssh://
|
borg create ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
|
||||||
{props.selectedOption.repositoryName}
|
{props.selectedOption.repositoryName}
|
||||||
::archive1 /your/pathToBackup
|
::archive1 /your/pathToBackup
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg create ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}::archive1 /your/pathToBackup`}
|
dataToCopy={`borg create ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}::archive1 /your/pathToBackup`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -85,12 +85,11 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg check -v --progress ssh://
|
borg check -v --progress ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
|
||||||
{props.selectedOption.repositoryName}
|
{props.selectedOption.repositoryName}
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg check -v --progress ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
dataToCopy={`borg check -v --progress ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<li>List the remote archives with :</li>
|
<li>List the remote archives with :</li>
|
||||||
|
@ -103,12 +102,11 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg list ssh://
|
borg list ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
|
||||||
{props.selectedOption.repositoryName}
|
{props.selectedOption.repositoryName}
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg list ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
dataToCopy={`borg list ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<li>Download a remote archive with the following command :</li>
|
<li>Download a remote archive with the following command :</li>
|
||||||
|
@ -121,13 +119,12 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg export-tar --tar-filter="gzip -9" ssh://
|
borg export-tar --tar-filter="gzip -9" ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
|
||||||
{props.selectedOption.repositoryName}
|
{props.selectedOption.repositoryName}
|
||||||
::archive1 archive1.tar.gz
|
::archive1 archive1.tar.gz
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg export-tar --tar-filter="gzip -9" ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}::archive1 archive1.tar.gz`}
|
dataToCopy={`borg export-tar --tar-filter="gzip -9" ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}::archive1 archive1.tar.gz`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<li>
|
<li>
|
||||||
|
@ -143,13 +140,12 @@ function WizardStep3(props) {
|
||||||
>
|
>
|
||||||
<div className={classes.code}>
|
<div className={classes.code}>
|
||||||
borg mount ssh://
|
borg mount ssh://
|
||||||
{props.selectedOption.unixUser}@{HOSTNAME}:
|
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||||
{SSH_SERVER_PORT}/./
|
|
||||||
{props.selectedOption.repositoryName}
|
{props.selectedOption.repositoryName}
|
||||||
::archive1 /tmp/yourMountPoint
|
::archive1 /tmp/yourMountPoint
|
||||||
</div>
|
</div>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
dataToCopy={`borg mount ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}::archive1 /tmp/yourMountPoint`}
|
dataToCopy={`borg mount ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}::archive1 /tmp/yourMountPoint`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -9,6 +9,7 @@ function WizardStep4(props) {
|
||||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||||
let HOSTNAME;
|
let HOSTNAME;
|
||||||
let SSH_SERVER_PORT;
|
let SSH_SERVER_PORT;
|
||||||
|
let UNIX_USER = process.env.NEXT_PUBLIC_UNIX_USER;
|
||||||
if (
|
if (
|
||||||
props.selectedOption.lanCommand &&
|
props.selectedOption.lanCommand &&
|
||||||
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
|
||||||
|
@ -29,7 +30,7 @@ function WizardStep4(props) {
|
||||||
|
|
||||||
repositories:
|
repositories:
|
||||||
# Paths of local or remote repositories to backup to.
|
# Paths of local or remote repositories to backup to.
|
||||||
- ssh://${props.selectedOption.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}
|
- ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repositoryName}
|
||||||
|
|
||||||
storage:
|
storage:
|
||||||
archive_name_format: '{HOSTNAME}-documents-{now}'
|
archive_name_format: '{HOSTNAME}-documents-{now}'
|
||||||
|
|
|
@ -104,7 +104,6 @@ export default function RepoList() {
|
||||||
storageSize={repo.storageSize}
|
storageSize={repo.storageSize}
|
||||||
storageUsed={repo.storageUsed}
|
storageUsed={repo.storageUsed}
|
||||||
sshPublicKey={repo.sshPublicKey}
|
sshPublicKey={repo.sshPublicKey}
|
||||||
unixUser={repo.unixUser}
|
|
||||||
comment={repo.comment}
|
comment={repo.comment}
|
||||||
lanCommand={repo.lanCommand}
|
lanCommand={repo.lanCommand}
|
||||||
repoManageEditHandler={() => repoManageEditHandler(repo.id)}
|
repoManageEditHandler={() => repoManageEditHandler(repo.id)}
|
||||||
|
|
|
@ -23,7 +23,6 @@ function SetupWizard(props) {
|
||||||
const [selectedOption, setSelectedOption] = useState({
|
const [selectedOption, setSelectedOption] = useState({
|
||||||
id: '#id',
|
id: '#id',
|
||||||
repository: 'repo',
|
repository: 'repo',
|
||||||
unixUser: 'user',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
////LifeCycle
|
////LifeCycle
|
||||||
|
@ -60,7 +59,6 @@ function SetupWizard(props) {
|
||||||
value: `${repo.alias} - #${repo.id}`,
|
value: `${repo.alias} - #${repo.id}`,
|
||||||
id: repo.id,
|
id: repo.id,
|
||||||
repositoryName: repo.repositoryName,
|
repositoryName: repo.repositoryName,
|
||||||
unixUser: repo.unixUser,
|
|
||||||
lanCommand: repo.lanCommand,
|
lanCommand: repo.lanCommand,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,8 @@ export default async function handler(req, res) {
|
||||||
newRepoList = repoList;
|
newRepoList = repoList;
|
||||||
for (let index in newRepoList) {
|
for (let index in newRepoList) {
|
||||||
const repoFiltered = lastSave.filter(
|
const repoFiltered = lastSave.filter(
|
||||||
(x) => x.user === newRepoList[index].unixUser
|
(x) =>
|
||||||
|
x.repositoryName === newRepoList[index].repositoryName
|
||||||
);
|
);
|
||||||
if (repoFiltered.length === 1) {
|
if (repoFiltered.length === 1) {
|
||||||
//Write the timestamp of the last save
|
//Write the timestamp of the last save
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default async function handler(req, res) {
|
||||||
let newRepoList = repoList;
|
let newRepoList = repoList;
|
||||||
for (let index in newRepoList) {
|
for (let index in newRepoList) {
|
||||||
const repoFiltered = storageUsed.filter(
|
const repoFiltered = storageUsed.filter(
|
||||||
(x) => x.name === newRepoList[index].unixUser
|
(x) => x.name === newRepoList[index].repositoryName
|
||||||
);
|
);
|
||||||
if (repoFiltered.length === 1) {
|
if (repoFiltered.length === 1) {
|
||||||
newRepoList[index].storageUsed = repoFiltered[0].size;
|
newRepoList[index].storageUsed = repoFiltered[0].size;
|
||||||
|
|
|
@ -58,7 +58,6 @@ export default async function handler(req, res) {
|
||||||
sshPublicKey: sshPublicKey,
|
sshPublicKey: sshPublicKey,
|
||||||
comment: comment,
|
comment: comment,
|
||||||
displayDetails: true,
|
displayDetails: true,
|
||||||
unixUser: '',
|
|
||||||
lanCommand: lanCommand,
|
lanCommand: lanCommand,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,9 @@ export default async function handler(req, res) {
|
||||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||||
//Exec the shell
|
//Exec the shell
|
||||||
const { stderr } = await exec(
|
const { stderr } = await exec(
|
||||||
`${shellsDirectory}/shells/deleteRepo.sh ${repoList[indexToDelete].unixUser}`
|
`${shellsDirectory}/shells/deleteRepo.sh ${repoList[indexToDelete].repositoryName}`
|
||||||
);
|
);
|
||||||
//Ignore this normal error with the command userdel in the shell : "userdel: USERXXX mail spool (/var/mail/USERXXX) not found".
|
if (stderr) {
|
||||||
if (stderr && !stderr.includes('mail spool')) {
|
|
||||||
console.log('stderr:', stderr);
|
console.log('stderr:', stderr);
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
status: 500,
|
status: 500,
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default async function handler(req, res) {
|
||||||
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
const shellsDirectory = path.join(process.cwd(), '/helpers');
|
||||||
// //Exec the shell
|
// //Exec the shell
|
||||||
const { stderr } = await exec(
|
const { stderr } = await exec(
|
||||||
`${shellsDirectory}/shells/updateRepo.sh ${repoList[repoIndex].unixUser} "${sshPublicKey}" ${size}`
|
`${shellsDirectory}/shells/updateRepo.sh ${repoList[repoIndex].repositoryName} "${sshPublicKey}" ${size}`
|
||||||
);
|
);
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
console.log('stderr:', stderr);
|
console.log('stderr:', stderr);
|
||||||
|
|
Loading…
Reference in a new issue