mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Adds switch to skip mkdir on scp repo sync
This commit is contained in:
parent
0e68cfafd0
commit
8924f77c58
2 changed files with 28 additions and 23 deletions
|
|
@ -6,15 +6,16 @@ Like with [adding existing repositories](01-Add-Existing-Repositories.md), each
|
||||||
|
|
||||||
## Available Arguments
|
## Available Arguments
|
||||||
|
|
||||||
| Argument | Type | Description |
|
| Argument | Type | Description |
|
||||||
| --- |--- | --- |
|
| --- |--- | --- |
|
||||||
| Name | String | The unique name of the repository. This name can only exist once on your system |
|
| Name | String | The unique name of the repository. This name can only exist once on your system |
|
||||||
| Path | String | The location on where the files from the remote repository will be synced to. This can either be a local path, a network share or a Linux path, including user and hostname like `icinga@example.com:/vaw/www/icingarepo/`
|
| Path | String | The location on where the files from the remote repository will be synced to. This can either be a local path, a network share or a Linux path, including user and hostname like `icinga@example.com:/vaw/www/icingarepo/`
|
||||||
| RemotePath | String | The path pointing to the location Icinga for Windows tries to lookup all your files. You can either replicate the `Path` variable for network shares for example, or use a web url which is made available based on `Path` to fetch and download files from. If left empty, it will default to the `Path` variable content |
|
| RemotePath | String | The path pointing to the location Icinga for Windows tries to lookup all your files. You can either replicate the `Path` variable for network shares for example, or use a web url which is made available based on `Path` to fetch and download files from. If left empty, it will default to the `Path` variable content |
|
||||||
| Source | String | The source from where the repository will be synced from. This can either be pointing directly to the `ifw.repo.json` or the root directory, as long as the file is fetch able from this point. A source can be a web, local or network share |
|
| Source | String | The source from where the repository will be synced from. This can either be pointing directly to the `ifw.repo.json` or the root directory, as long as the file is fetch able from this point. A source can be a web, local or network share |
|
||||||
| UseSCP | Switch | If you set `Path` to a Linux path as mentioned in the first example, you will have to enable this switch to use SCP to copy files from the source to the Linux system. Requires `scp` and `ssh` being installed on the system |
|
| UseSCP | Switch | If you set `Path` to a Linux path as mentioned in the first example, you will have to enable this switch to use SCP to copy files from the source to the Linux system. Requires `scp` and `ssh` being installed on the system |
|
||||||
| Force | Switch | This will force the creation of the repository, even if the name of the repository is already assigned. Should be used with caution |
|
| SkipSCPMkdir | Switch | Allows you to skip the `mkdir` operation while using `-UseSCP` and relies on the folder already existing |
|
||||||
| ForceTrust | Switch | By default repositories are validated with a hash, based on all files present inside the repository. If a repository is not providing a hash, it will be disabled after the sync for security reasons. In case the hash does not match with all files synced afterwards, the repository files will be deleted and the sync aborted. You can use this flag to ignore both states and always add the repository, regardless if the hash matches or the hash is not given |
|
| Force | Switch | This will force the creation of the repository, even if the name of the repository is already assigned. Should be used with caution |
|
||||||
|
| ForceTrust | Switch | By default repositories are validated with a hash, based on all files present inside the repository. If a repository is not providing a hash, it will be disabled after the sync for security reasons. In case the hash does not match with all files synced afterwards, the repository files will be deleted and the sync aborted. You can use this flag to ignore both states and always add the repository, regardless if the hash matches or the hash is not given |
|
||||||
|
|
||||||
## Sync Public Repository
|
## Sync Public Repository
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
function Sync-IcingaRepository()
|
function Sync-IcingaRepository()
|
||||||
{
|
{
|
||||||
param (
|
param (
|
||||||
[string]$Name = $null,
|
[string]$Name = $null,
|
||||||
[string]$Path = $null,
|
[string]$Path = $null,
|
||||||
[string]$RemotePath = $null,
|
[string]$RemotePath = $null,
|
||||||
[string]$Source = $null,
|
[string]$Source = $null,
|
||||||
[switch]$UseSCP = $FALSE,
|
[switch]$UseSCP = $FALSE,
|
||||||
[switch]$Force = $FALSE,
|
[switch]$Force = $FALSE,
|
||||||
[switch]$ForceTrust = $FALSE
|
[switch]$ForceTrust = $FALSE,
|
||||||
|
[switch]$SkipSCPMkdir = $FALSE
|
||||||
);
|
);
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty($Name)) {
|
if ([string]::IsNullOrEmpty($Name)) {
|
||||||
|
|
@ -205,14 +206,17 @@ function Sync-IcingaRepository()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else { # Linux target
|
} else { # Linux target
|
||||||
Write-IcingaConsoleNotice 'Creating directory over SSH for host and user "{0}" and path "{1}"' -Objects $SSHAuth, $Path;
|
|
||||||
|
|
||||||
$Result = Start-IcingaProcess -Executable 'ssh' -Arguments ([string]::Format('{0} mkdir -p "{1}"', $SSHAuth, $Path));
|
if ($SkipSCPMkdir -eq $FALSE) {
|
||||||
if ($Result.ExitCode -ne 0) {
|
Write-IcingaConsoleNotice 'Creating directory over SSH for host and user "{0}" and path "{1}"' -Objects $SSHAuth, $Path;
|
||||||
# TODO: Add link to setup docs
|
|
||||||
Write-IcingaConsoleError 'SSH Error on directory creation: {0}' -Objects $Result.Error;
|
$Result = Start-IcingaProcess -Executable 'ssh' -Arguments ([string]::Format('{0} mkdir -p "{1}"', $SSHAuth, $Path));
|
||||||
$Success = Remove-Item -Path $TmpDir -Recurse -Force;
|
if ($Result.ExitCode -ne 0) {
|
||||||
return;
|
# TODO: Add link to setup docs
|
||||||
|
Write-IcingaConsoleError 'SSH Error on directory creation: {0}' -Objects $Result.Error;
|
||||||
|
$Success = Remove-Item -Path $TmpDir -Recurse -Force;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-IcingaConsoleNotice 'Removing old repository files from "{0}"' -Objects $Path;
|
Write-IcingaConsoleNotice 'Removing old repository files from "{0}"' -Objects $Path;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue