mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-05-17 21:16:39 +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.
|
||||
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>
|
||||
)}
|
||||
|
|
|
@ -78,7 +78,6 @@ export default function Repo(props) {
|
|||
</div>
|
||||
)}
|
||||
<QuickCommands
|
||||
unixUser={props.unixUser}
|
||||
repositoryName={props.repositoryName}
|
||||
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.
|
||||
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
|
||||
|
|
|
@ -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 />
|
||||
|
|
|
@ -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}'
|
||||
|
|
|
@ -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)}
|
||||
|
|
|
@ -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,
|
||||
}));
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -58,7 +58,6 @@ export default async function handler(req, res) {
|
|||
sshPublicKey: sshPublicKey,
|
||||
comment: comment,
|
||||
displayDetails: true,
|
||||
unixUser: '',
|
||||
lanCommand: lanCommand,
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue