From e2fe1a8f069f58bd4459551105f6007d9b2f1119 Mon Sep 17 00:00:00 2001 From: lksz Date: Wed, 3 Feb 2021 19:43:12 -0500 Subject: [PATCH] Fixes + ConvertTo-Zip: Added -MuteSkipped * sz-df sorting fixed + -PassThru added, defaulting output to Format-Table unless -PassThru switch is specified which will output the objects raw. * Edit-DockerCompose fixed duplicate 'AdditionalFiles' * dcup and dcreup fixed: added --remove-orphans --- 7zip/ConvertTo-Zip.ps1 | 2 ++ base.linux/sz-df.ps1 | 43 ++++++++++++++++++++++++----------- docker/Edit-DockerCompose.ps1 | 2 +- docker/dcreup.ps1 | 2 +- docker/dcup.ps1 | 2 +- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/7zip/ConvertTo-Zip.ps1 b/7zip/ConvertTo-Zip.ps1 index 6907438..0a8a247 100644 --- a/7zip/ConvertTo-Zip.ps1 +++ b/7zip/ConvertTo-Zip.ps1 @@ -7,6 +7,7 @@ [string]$ZipOptions="-mm=Deflate -mfb=258 -mpass=15", [string]$MoveProcessedTo="done", [switch]$Flatten, + [switch]$MuteSkipped, [switch]$Force ) @@ -115,6 +116,7 @@ foreach( $local:srcFile in $srcSet ) { Move-Item @moveParams } + if( $ActionStatus -eq 'Skipped' -and $MuteSkipped ) { continue } [PSCustomObject]([ordered]@{ Action = $ActionStatus SrcMoved = $(if($DonePath){ $true } else {$false}) diff --git a/base.linux/sz-df.ps1 b/base.linux/sz-df.ps1 index ac49a61..f490dc8 100644 --- a/base.linux/sz-df.ps1 +++ b/base.linux/sz-df.ps1 @@ -1,4 +1,4 @@ -param([ValidateSet('KB','GB','TB')]$SizeUnitName = 'GB') +param([ValidateSet('KB','GB','TB')]$SizeUnitName = 'GB',[switch]$NoFilter,[switch]$PassThru) $local:zpool_cmd = $null $local:excludeType = '' @@ -21,16 +21,33 @@ function NewDataRow{param($Size,$Used,$Available,$Percent,$Source,$FSType,$Targe } } +Set-Alias Out-Default Format-Table +if( $PassThru ) { + Get-Item alias:/Out-Default | Remove-Item +} + +$local:filterParam = [ordered]@{} +if( -not $NoFilter ) { $filterParam.First = 1 } $local:df = @() -& df '--output=size,used,avail,pcent,source,fstype,target' | - Select-Object -Skip 1 | ForEach-Object { - $local:df = $_.Split(' ', [StringSplitOptions]::RemoveEmptyEntries) - NewDataRow $df[0] $df[1] $df[2] $df[3] $df[4] $df[5] $df[6] - } | - Group-Object -Property FSType | - ForEach-Object { - if( $_.Name -eq 'zfs' ) { $_.Group | Group-Object -Property Group | ForEach-Object { $_.Group | Select-Object -First 1 } } - else { $_.Group } - } | - Select-Object -Property "Size$SizeUnitName","Used$SizeUnitName","Available$SizeUnitName",'Used%',Source,FSType,Target | - Sort-Object -Property FSType,Target + +$( + & df '--output=size,used,avail,pcent,source,fstype,target' | + Select-Object -Skip 1 | ForEach-Object { + $local:df = $_.Split(' ', [StringSplitOptions]::RemoveEmptyEntries) + NewDataRow $df[0] $df[1] $df[2] $df[3] $df[4] $df[5] $df[6] + } | + Sort-Object -Property FSType,Target | + Group-Object -Property FSType | + ForEach-Object { + if( $_.Name -eq 'zfs' ) { + $_.Group | + Group-Object -Property Group | + ForEach-Object { + $_.Group | Sort-Object -Property Source | Select-Object @filterParam + } + } + else { $_.Group } + } | + Select-Object -Property "Size$SizeUnitName","Used$SizeUnitName","Available$SizeUnitName",'Used%',Source,FSType,Target +) | + Out-Default diff --git a/docker/Edit-DockerCompose.ps1 b/docker/Edit-DockerCompose.ps1 index 41f332b..d69657e 100644 --- a/docker/Edit-DockerCompose.ps1 +++ b/docker/Edit-DockerCompose.ps1 @@ -47,7 +47,7 @@ $local:FinalEditList = $editFiles | Where-Object {$_} | Sort-Object { $local:n = [System.IO.Path]::GetFileName($_) Join-Path [PSystem.IO.ath]::GetDirectoryName($_) "$(if( $n[0] -eq '.' ) { "9" } else { "1" })$n" } -$FinalEditList = @() + $FinalEditList + @() + $AdditionalFiles +$FinalEditList = (@() + $FinalEditList + @() + $AdditionalFiles) | Select-Object -Unique Edit-TextFile $FinalEditList diff --git a/docker/dcreup.ps1 b/docker/dcreup.ps1 index 1ac180d..e4ec161 100644 --- a/docker/dcreup.ps1 +++ b/docker/dcreup.ps1 @@ -15,7 +15,7 @@ [switch]$NoPull, [array]$PullParams, [array]$LogsParams, - [array]$UpParams=@('-d'), + [array]$UpParams=@('-d','--remove-orphans'), [Parameter(Position = 0, ValueFromRemainingArguments = $true)] [array]$Containers ) diff --git a/docker/dcup.ps1 b/docker/dcup.ps1 index bc989ba..d91d3fb 100644 --- a/docker/dcup.ps1 +++ b/docker/dcup.ps1 @@ -15,7 +15,7 @@ [switch]$NoPull, [array]$PullParams, [array]$LogsParams, - [array]$UpParams=@('-d'), + [array]$UpParams=@('-d','--remove-orphans'), [Parameter(Position = 0, ValueFromRemainingArguments = $true)] [array]$Containers )