feat: unixUser is now unique and retrieved by env

This commit is contained in:
bsourisse 2023-08-20 22:00:57 +02:00 committed by Ravinou
parent a7beb7b37f
commit a735144a55
No known key found for this signature in database
GPG key ID: EEEE670C40F6A4D7
12 changed files with 28 additions and 36 deletions

View file

@ -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.
let HOSTNAME;
let SSH_SERVER_PORT;
let UNIX_USER = process.env.NEXT_PUBLIC_UNIX_USER;
if (
props.lanCommand &&
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
@ -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.repositoryName}`
`borg init -e repokey-blake2 ssh://${UNIX_USER}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.repositoryName}`
)
.then(() => {
// 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.tooltip}>
borg init -e repokey-blake2 ssh://{props.unixUser}@
{HOSTNAME}:{SSH_SERVER_PORT}/./
borg init -e repokey-blake2 ssh://{UNIX_USER}@{HOSTNAME}:
{SSH_SERVER_PORT}/./
{props.repositoryName}
</div>
)}

View file

@ -78,7 +78,6 @@ export default function Repo(props) {
</div>
)}
<QuickCommands
unixUser={props.unixUser}
repositoryName={props.repositoryName}
lanCommand={props.lanCommand}
/>

View file

@ -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.
let HOSTNAME;
let SSH_SERVER_PORT;
let UNIX_USER = process.env.NEXT_PUBLIC_UNIX_USER;
if (
props.selectedOption.lanCommand &&
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
@ -39,12 +40,11 @@ function WizardStep2(props) {
>
<div className={classes.code}>
borg init -e repokey-blake2 ssh://
{props.selectedOption.unixUser}@{HOSTNAME}:
{SSH_SERVER_PORT}/./
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
{props.selectedOption.repositoryName}
</div>
<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 className={classes.note}>
@ -95,12 +95,11 @@ function WizardStep2(props) {
>
<div className={classes.code}>
ssh://
{props.selectedOption.unixUser}@{HOSTNAME}:
{SSH_SERVER_PORT}/./
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
{props.selectedOption.repositoryName}
</div>
<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>
For more information about the Vorta graphical client, please

View file

@ -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.
let HOSTNAME;
let SSH_SERVER_PORT;
let UNIX_USER = process.env.NEXT_PUBLIC_UNIX_USER;
if (
props.selectedOption.lanCommand &&
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
@ -38,13 +39,12 @@ function WizardStep3(props) {
>
<div className={classes.code}>
borg create ssh://
{props.selectedOption.unixUser}@{HOSTNAME}:
{SSH_SERVER_PORT}/./
{UNIX_USER}@{HOSTNAME}:{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}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.selectedOption.repository}::archive1 /your/pathToBackup`}
/>
</div>
</div>
@ -85,12 +85,11 @@ function WizardStep3(props) {
>
<div className={classes.code}>
borg check -v --progress ssh://
{props.selectedOption.unixUser}@{HOSTNAME}:
{SSH_SERVER_PORT}/./
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
{props.selectedOption.repositoryName}
</div>
<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>
<li>List the remote archives with :</li>
@ -103,12 +102,11 @@ function WizardStep3(props) {
>
<div className={classes.code}>
borg list ssh://
{props.selectedOption.unixUser}@{HOSTNAME}:
{SSH_SERVER_PORT}/./
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
{props.selectedOption.repositoryName}
</div>
<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>
<li>Download a remote archive with the following command :</li>
@ -121,13 +119,12 @@ function WizardStep3(props) {
>
<div className={classes.code}>
borg export-tar --tar-filter="gzip -9" ssh://
{props.selectedOption.unixUser}@{HOSTNAME}:
{SSH_SERVER_PORT}/./
{UNIX_USER}@{HOSTNAME}:{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.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>
<li>
@ -143,13 +140,12 @@ function WizardStep3(props) {
>
<div className={classes.code}>
borg mount ssh://
{props.selectedOption.unixUser}@{HOSTNAME}:
{SSH_SERVER_PORT}/./
{UNIX_USER}@{HOSTNAME}:{SSH_SERVER_PORT}/./
{props.selectedOption.repositoryName}
::archive1 /tmp/yourMountPoint
</div>
<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>
<br />

View file

@ -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.
let HOSTNAME;
let SSH_SERVER_PORT;
let UNIX_USER = process.env.NEXT_PUBLIC_UNIX_USER;
if (
props.selectedOption.lanCommand &&
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
@ -29,7 +30,7 @@ function WizardStep4(props) {
repositories:
# 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:
archive_name_format: '{HOSTNAME}-documents-{now}'

View file

@ -104,7 +104,6 @@ export default function RepoList() {
storageSize={repo.storageSize}
storageUsed={repo.storageUsed}
sshPublicKey={repo.sshPublicKey}
unixUser={repo.unixUser}
comment={repo.comment}
lanCommand={repo.lanCommand}
repoManageEditHandler={() => repoManageEditHandler(repo.id)}

View file

@ -23,7 +23,6 @@ function SetupWizard(props) {
const [selectedOption, setSelectedOption] = useState({
id: '#id',
repository: 'repo',
unixUser: 'user',
});
////LifeCycle
@ -60,7 +59,6 @@ function SetupWizard(props) {
value: `${repo.alias} - #${repo.id}`,
id: repo.id,
repositoryName: repo.repositoryName,
unixUser: repo.unixUser,
lanCommand: repo.lanCommand,
}));

View file

@ -62,7 +62,8 @@ export default async function handler(req, res) {
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

View file

@ -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;

View file

@ -58,7 +58,6 @@ export default async function handler(req, res) {
sshPublicKey: sshPublicKey,
comment: comment,
displayDetails: true,
unixUser: '',
lanCommand: lanCommand,
};

View file

@ -47,10 +47,9 @@ export default async function handler(req, res) {
const shellsDirectory = path.join(process.cwd(), '/helpers');
//Exec the shell
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 && !stderr.includes('mail spool')) {
if (stderr) {
console.log('stderr:', stderr);
res.status(500).json({
status: 500,

View file

@ -49,7 +49,7 @@ export default async function handler(req, res) {
const shellsDirectory = path.join(process.cwd(), '/helpers');
// //Exec the shell
const { stderr } = await exec(
`${shellsDirectory}/shells/updateRepo.sh ${repoList[repoIndex].unixUser} "${sshPublicKey}" ${size}`
`${shellsDirectory}/shells/updateRepo.sh ${repoList[repoIndex].repositoryName} "${sshPublicKey}" ${size}`
);
if (stderr) {
console.log('stderr:', stderr);