-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/add status sh file #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9a8a8ca
d438a7b
e1bbf7e
222f534
b00dc05
652ea3b
87e5aef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Lint Scripts | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, master, "feature/**" ] | ||
| pull_request: | ||
| branches: [ main, master ] | ||
|
Comment on lines
+3
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Align the trigger filters with the documented CI scope.
🤖 Prompt for AI Agents |
||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| shellcheck: | ||
| name: ShellCheck (Bash) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| with: | ||
| persist-credentials: false | ||
|
|
||
|
|
||
| - name: Run ShellCheck | ||
| uses: ludeeus/action-shellcheck@master | ||
| with: | ||
| scandir: '.' | ||
| severity: style | ||
|
|
||
| psscriptanalyzer: | ||
| name: PSScriptAnalyzer (PowerShell) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Run PSScriptAnalyzer | ||
| uses: microsoft/psscriptanalyzer-action@v1.1 | ||
| with: | ||
| path: './PowerShell' | ||
| recurse: true | ||
| settings: PSGallery | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,11 @@ | ||
| # DeleteEmptyFolders.ps1 | ||
|
|
||
| [CmdletBinding()] | ||
| Param ( | ||
| <# | ||
| .SYNOPSIS | ||
| Deletes empty subdirectories within a specified path (wrapper for ManageEmptyFolders.ps1). | ||
| #> | ||
| [CmdletBinding(SupportsShouldProcess = $true)] | ||
| param ( | ||
| [Parameter(Mandatory = $true, Position = 0, HelpMessage = "The root path to search for empty folders.")] | ||
| [string]$Path | ||
| ) | ||
|
|
||
| # Validate that the path exists and is a directory | ||
| if (-not (Test-Path -Path $Path -PathType Container)) { | ||
| Write-Error "The path '$Path' does not exist or is not a folder." | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Verbose "Searching for empty folders under '$Path'..." | ||
|
|
||
| # Get all directories recursively, then filter for those that have no child items (files or folders). | ||
| # The results are sorted by the length of the FullName in descending order to ensure subdirectories are deleted before their parents. | ||
| Get-ChildItem -Path $Path -Recurse -Directory | Where-Object { -not $_.GetFileSystemInfos() } | Sort-Object { $_.FullName.Length } -Descending | Remove-Item -Force -Verbose | ||
|
|
||
| Write-Host "Finished deleting empty folders." | ||
| & "$PSScriptRoot/ManageEmptyFolders.ps1" -Path $Path -Delete | ||
|
Comment on lines
+5
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- tracked PowerShell files ---'
git ls-files 'PowerShell/*'
printf '%s\n' '--- DeleteEmptyFolders.ps1 ---'
cat -n PowerShell/DeleteEmptyFolders.ps1
printf '%s\n' '--- ManageEmptyFolders.ps1 ---'
cat -n PowerShell/ManageEmptyFolders.ps1
printf '%s\n' '--- related ShouldProcess/delegation patterns ---'
rg -n -C 3 'ShouldProcess|SupportsShouldProcess|ManageEmptyFolders|DeleteEmptyFolders|WhatIf|Confirm' PowerShellRepository: terjeinnerdal/scripts Length of output: 10026 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- PowerShell runtime availability ---'
if command -v pwsh >/dev/null 2>&1; then
pwsh --version
printf '%s\n' '--- common-parameter preference propagation probe ---'
pwsh -NoProfile -NonInteractive -Command '
function Child {
[CmdletBinding(SupportsShouldProcess = $true)]
param()
[pscustomobject]@{
WhatIfPreference = $WhatIfPreference
ConfirmPreference = $ConfirmPreference
ShouldProcess = $PSCmdlet.ShouldProcess("target", "action")
}
}
function Wrapper {
[CmdletBinding(SupportsShouldProcess = $true)]
param()
Child
}
"normal:"
Wrapper | Format-List
"whatif:"
Wrapper -WhatIf | Format-List
"confirm:"
Wrapper -Confirm:$false | Format-List
'
else
echo 'pwsh is unavailable'
fi
printf '%s\n' '--- reusable function implementation ---'
cat -n PowerShell/ManageEmptyFolders.Function.ps1Repository: terjeinnerdal/scripts Length of output: 3325 🏁 Script executed: #!/bin/bash
set -eu
pwsh -NoProfile -NonInteractive -Command '
$child = {
[CmdletBinding(SupportsShouldProcess = $true)]
param()
[pscustomobject]@{
WhatIfPreference = $WhatIfPreference
ConfirmPreference = $ConfirmPreference
}
}
$wrapper = {
[CmdletBinding(SupportsShouldProcess = $true)]
param()
& $child
}
"normal:"
& $wrapper | Format-List
"whatif:"
& $wrapper -WhatIf | Format-List
"confirm:"
& $wrapper -Confirm | Format-List
'Repository: terjeinnerdal/scripts Length of output: 341 Call
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Deletes files based on path, filter, and age with safety dry-run support (-WhatIf). | ||
|
|
||
| .DESCRIPTION | ||
| Safely removes files matching specified patterns and optionally older than a given number of days. | ||
| Supports -WhatIf and -Confirm standard PowerShell switches. | ||
|
|
||
| .EXAMPLE | ||
| .\DeleteFiles.ps1 -Path "C:\Logs" -Filter "*.log" -DaysOld 30 -Recurse -WhatIf | ||
| #> | ||
|
|
||
| [CmdletBinding(SupportsShouldProcess = $true)] | ||
| param( | ||
| [Parameter(Mandatory = $false, Position = 0)] | ||
| [string]$Path = ".", | ||
|
|
||
| [Parameter(Mandatory = $false)] | ||
| [string]$Filter = "*", | ||
|
|
||
| [Parameter(Mandatory = $false)] | ||
| [int]$DaysOld = 0, | ||
|
Comment on lines
+21
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
file=$(git ls-files | rg '^PowerShell/DeleteFiles\.ps1$')
cat -n "$file"
printf '\n--- references to DaysOld and cutoff ---\n'
rg -n -C 3 '\$DaysOld|cutoffDate|AddDays|ShouldProcess|Remove-Item|Test-Path' "$file"Repository: terjeinnerdal/scripts Length of output: 3317 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- PowerShell runtime availability ---'
if command -v pwsh >/dev/null 2>&1; then
pwsh -NoProfile -NonInteractive -Command '
$now = Get-Date
foreach ($days in @(-1, 0, 30)) {
$cutoff = $now.AddDays(-$days)
[pscustomobject]@{
DaysOld = $days
CutoffRelativeToNow = $cutoff - $now
OlderThanCutoff = ((New-TimeSpan -Start $now.AddDays(-365) -End $cutoff).TotalDays -gt 0)
}
} | ConvertTo-Json -Compress
'
else
echo 'pwsh unavailable'
fi
printf '%s\n' '--- deterministic date comparison model ---'
python3 - <<'PY'
from datetime import datetime, timedelta, timezone
now = datetime(2026, 8, 1, tzinfo=timezone.utc)
for days in (-1, 0, 30):
cutoff = now - timedelta(days=days)
old_file = now - timedelta(days=365)
print({
"DaysOld": days,
"cutoff_delta_days": (cutoff - now).days,
"old_file_is_selected": old_file < cutoff,
})
PYRepository: terjeinnerdal/scripts Length of output: 322 🏁 Script executed: #!/bin/bash
set -eu
if command -v pwsh >/dev/null 2>&1; then
pwsh -NoProfile -NonInteractive -Command '
$now = Get-Date
$results = foreach ($days in @(-1, 0, 30)) {
$cutoff = $now.AddDays(-$days)
[pscustomobject]@{
DaysOld = $days
CutoffDeltaDays = ($cutoff - $now).TotalDays
OldFileSelected = (($now.AddDays(-365)) -lt $cutoff)
}
}
$results | ConvertTo-Json -Compress
'
else
echo 'pwsh unavailable'
fiRepository: terjeinnerdal/scripts Length of output: 342 Reject negative When 🤖 Prompt for AI Agents |
||
|
|
||
| [Parameter(Mandatory = $false)] | ||
| [switch]$Recurse | ||
| ) | ||
|
|
||
| if (-not (Test-Path -Path $Path)) { | ||
| Write-Error "Target path '$Path' does not exist." | ||
| exit 1 | ||
| } | ||
|
|
||
| $cutoffDate = (Get-Date).AddDays(-$DaysOld) | ||
|
|
||
| $getParams = @{ | ||
| Path = $Path | ||
| Filter = $Filter | ||
| File = $true | ||
| Recurse = $Recurse | ||
|
Comment on lines
+28
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- file list ---'
git ls-files 'PowerShell/DeleteFiles.ps1'
printf '%s\n' '--- file outline ---'
ast-grep outline PowerShell/DeleteFiles.ps1 --lang powershell 2>/dev/null || true
printf '%s\n' '--- relevant source ---'
cat -n PowerShell/DeleteFiles.ps1Repository: terjeinnerdal/scripts Length of output: 2131 🏁 Script executed: #!/bin/bash
set -eu
if command -v pwsh >/dev/null 2>&1; then
pwsh -NoProfile -NonInteractive -Command '
[pscustomobject]@{
FileAcceptedByTestPath = Test-Path -Path "/etc/passwd"
DirectoryAcceptedByTestPath = Test-Path -Path "/etc"
WildcardAcceptedByTestPath = Test-Path -Path "/etc/pass*"
WildcardChildItems = @((Get-ChildItem -Path "/etc/pass*" -File -ErrorAction Stop).FullName)
LiteralFileIsContainer = Test-Path -LiteralPath "/etc/passwd" -PathType Container
LiteralDirectoryIsContainer = Test-Path -LiteralPath "/etc" -PathType Container
} | ConvertTo-Json -Compress
'
elif command -v powershell >/dev/null 2>&1; then
powershell -NoProfile -NonInteractive -Command '
[pscustomobject]@{
FileAcceptedByTestPath = Test-Path -Path "/etc/passwd"
DirectoryAcceptedByTestPath = Test-Path -Path "/etc"
WildcardAcceptedByTestPath = Test-Path -Path "/etc/pass*"
WildcardChildItems = @((Get-ChildItem -Path "/etc/pass*" -File -ErrorAction Stop).FullName)
LiteralFileIsContainer = Test-Path -LiteralPath "/etc/passwd" -PathType Container
LiteralDirectoryIsContainer = Test-Path -LiteralPath "/etc" -PathType Container
} | ConvertTo-Json -Compress
'
else
printf '%s\n' 'No PowerShell runtime is available; source-level verification only.'
fiRepository: terjeinnerdal/scripts Length of output: 363 Require a directory and use literal paths.
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| } | ||
|
|
||
| $filesToDelete = Get-ChildItem @getParams | Where-Object { $_.LastWriteTime -lt $cutoffDate } | ||
|
Comment on lines
+35
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- tracked file ---'
git ls-files -- 'PowerShell/DeleteFiles.ps1'
printf '%s\n' '--- outline ---'
ast-grep outline 'PowerShell/DeleteFiles.ps1' --lang powershell 2>/dev/null || true
printf '%s\n' '--- relevant source ---'
cat -n 'PowerShell/DeleteFiles.ps1'Repository: terjeinnerdal/scripts Length of output: 2129 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- PowerShell runtimes available ---'
command -v pwsh || true
command -v powershell || true
printf '%s\n' '--- enumeration and deletion calls ---'
rg -n -C 3 'Get-ChildItem|filesToDelete|Remove-Item|ShouldProcess|Test-Path' -- 'PowerShell/DeleteFiles.ps1'
printf '%s\n' '--- repository-wide callers or wrappers ---'
rg -n 'DeleteFiles\.ps1|Get-ChildItem `@getParams`' . --glob '!PowerShell/DeleteFiles.ps1' || trueRepository: terjeinnerdal/scripts Length of output: 1592 🏁 Script executed: pwsh -NoProfile -NonInteractive -Command '
$valid = [System.IO.Path]::GetTempPath()
$missing = Join-Path $valid "__coderabbit_missing_path__"
$records = @(Get-ChildItem -Path @($valid, $missing) -File -ErrorAction Continue 2>$null)
"partial_count=$($records.Count)"
try {
$records = @(Get-ChildItem -Path @($valid, $missing) -File -ErrorAction Stop)
"stop_threw=False"
}
catch {
"stop_threw=True"
"exception_type=$($_.Exception.GetType().FullName)"
}
'Repository: terjeinnerdal/scripts Length of output: 258 Fail closed when enumeration reports an error.
🤖 Prompt for AI Agents |
||
|
|
||
| if ($filesToDelete.Count -eq 0) { | ||
| Write-Host "No files found matching criteria in '$Path'." -ForegroundColor Yellow | ||
| return | ||
| } | ||
|
|
||
| Write-Host "Found $($filesToDelete.Count) file(s) to process." -ForegroundColor Cyan | ||
|
|
||
| foreach ($file in $filesToDelete) { | ||
| if ($PSCmdlet.ShouldProcess($file.FullName, "Delete file")) { | ||
| Remove-Item -Path $file.FullName -Force | ||
|
Comment on lines
+52
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- file inventory ---'
git ls-files 'PowerShell/DeleteFiles.ps1'
printf '%s\n' '--- script outline ---'
if command -v ast-grep >/dev/null 2>&1; then
ast-grep outline PowerShell/DeleteFiles.ps1 --lang powershell || true
fi
printf '%s\n' '--- relevant source ---'
nl -ba PowerShell/DeleteFiles.ps1 | sed -n '1,130p'
printf '%s\n' '--- runtime availability ---'
command -v pwsh || true
command -v powershell || trueRepository: terjeinnerdal/scripts Length of output: 457 🏁 Script executed: #!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
p = Path("PowerShell/DeleteFiles.ps1")
text = p.read_text()
for term in ("Remove-Item -Path", "Remove-Item -LiteralPath", "ShouldProcess", "Get-ChildItem"):
print(f"{term}: {text.count(term)} occurrence(s)")
PYRepository: terjeinnerdal/scripts Length of output: 298 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- relevant source ---'
sed -n '1,130p' PowerShell/DeleteFiles.ps1
printf '%s\n' '--- PowerShell parameter semantics ---'
pwsh -NoProfile -NonInteractive -Command '
$cmd = Get-Command Remove-Item
$path = $cmd.Parameters["Path"]
$literal = $cmd.Parameters["LiteralPath"]
[pscustomobject]@{
PathPosition = $path.Attributes.Position
PathValueFromRemainingArguments = $path.Attributes.ValueFromRemainingArguments
LiteralPathPosition = $literal.Attributes.Position
LiteralPathValueFromRemainingArguments = $literal.Attributes.ValueFromRemainingArguments
} | Format-List
Get-Help Remove-Item -Parameter Path -ErrorAction SilentlyContinue |
Out-String -Width 200
Get-Help Remove-Item -Parameter LiteralPath -ErrorAction SilentlyContinue |
Out-String -Width 200
'Repository: terjeinnerdal/scripts Length of output: 2563 🏁 Script executed: #!/bin/bash
set -eu
pwsh -NoProfile -NonInteractive -Command '
Set-Location (Get-Location).Path
$wildcard = Join-Path (Get-Location) "PowerShell/[D]eleteFiles.ps1"
$literal = Join-Path (Get-Location) "PowerShell/DeleteFiles.ps1"
Write-Output "--- -Path wildcard probe ---"
Remove-Item -Path $wildcard -Force -WhatIf -ErrorAction Continue
Write-Output "--- -LiteralPath wildcard probe ---"
Remove-Item -LiteralPath $wildcard -Force -WhatIf -ErrorAction Continue
Write-Output "--- exact path probe ---"
Remove-Item -Path $literal -Force -WhatIf -ErrorAction Continue
'Repository: terjeinnerdal/scripts Length of output: 743 Use
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| Write-Host "Deleted: $($file.FullName)" -ForegroundColor Green | ||
|
Comment on lines
+52
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/sh
set -eu
printf '%s\n' '--- file list ---'
git ls-files 'PowerShell/DeleteFiles.ps1'
printf '%s\n' '--- relevant source ---'
cat -n PowerShell/DeleteFiles.ps1 | sed -n '1,110p'
printf '%s\n' '--- deletion and error handling references ---'
rg -n -C 3 'Remove-Item|ErrorAction|try|catch|ShouldProcess|Write-Host' PowerShell/DeleteFiles.ps1Repository: terjeinnerdal/scripts Length of output: 2986 🏁 Script executed: #!/bin/sh
set -eu
if command -v pwsh >/dev/null 2>&1; then
PS= pwsh
elif command -v powershell >/dev/null 2>&1; then
PS= powershell
else
printf '%s\n' 'No PowerShell executable is available in the sandbox.'
exit 0
fi
"$PS" -NoProfile -NonInteractive -Command '
$Error.Clear()
Remove-Item -Path "/path/that/does/not/exist/coderabbit-probe" -Force
Write-Output ("success-message-reached; error-count=" + $Error.Count + "; last-success=" + $?)
'Repository: terjeinnerdal/scripts Length of output: 868 Stop on
🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,11 @@ | ||
| # findEmptySubDirectories.ps1 | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Finds empty subdirectories within a specified path (wrapper for ManageEmptyFolders.ps1). | ||
| #> | ||
| [CmdletBinding()] | ||
| Param( | ||
| param ( | ||
| [Parameter(Mandatory = $true, Position = 0, HelpMessage = "The root path to search for empty directories.")] | ||
| [string]$Path | ||
| ) | ||
|
|
||
| if (-not (Test-Path -Path $Path -PathType Container)) { | ||
| Write-Error "The path '$Path' does not exist or is not a folder." | ||
| exit 1 | ||
| } | ||
|
|
||
| # Get all directories recursively, then filter for those that have no child items (files or folders). | ||
| Get-ChildItem -Path $Path -Recurse -Directory | Where-Object { -not $_.GetFileSystemInfos() } | Select-Object -ExpandProperty FullName | ||
| & "$PSScriptRoot/ManageEmptyFolders.ps1" -Path $Path |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,11 +1,107 @@ | ||||||
| # scripts | ||||||
| # Scripts Repository | ||||||
|
|
||||||
| PowerShell (.ps1), python (.py), bash (.sh) | ||||||
| A curated collection of automation scripts, tools, and utility modules for **Bash**, **PowerShell**, and **Docker**. | ||||||
|
|
||||||
| ## Bash | ||||||
| --- | ||||||
|
|
||||||
| Different bash scripts | ||||||
| ## 🛠️ Repository Overview | ||||||
|
|
||||||
| ### NordVPN | ||||||
| ``` | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Add a language to the repository-tree code fence.
Proposed fix-```
+```text📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.23.2)[warning] 9-9: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||
| . | ||||||
| ├── .github/ | ||||||
| │ └── workflows/ | ||||||
| │ └── lint.yml # GitHub Actions CI workflow (ShellCheck & PSScriptAnalyzer) | ||||||
| ├── bash/ | ||||||
| │ ├── AutoRemoveSnapd.sh # Removes snapd and associated packages on Debian/Ubuntu | ||||||
| │ ├── countLines.sh # Counts lines in a text file with line numbers | ||||||
| │ ├── import-kali.sh # Imports Kali Linux package repositories and GPG keys | ||||||
| │ ├── docker/ | ||||||
| │ │ └── compose.yaml # Docker Compose setup | ||||||
| │ ├── encryption/ | ||||||
| │ │ ├── encrypt_file.sh # AES-256-CBC file encryption (OpenSSL + PBKDF2) | ||||||
| │ │ └── decrypt_file.sh # AES-256-CBC file decryption (OpenSSL) | ||||||
| │ └── nord/ # NordVPN Meshnet control scripts | ||||||
| │ ├── config.sh # NordVPN configuration helper | ||||||
| │ ├── connect.sh # Connects to NordVPN | ||||||
| │ ├── copy_scripts.sh # Deployment helper script | ||||||
| │ ├── exit_node.sh # Manages and sets Meshnet exit node routing | ||||||
| │ ├── list_peers.sh # Lists Meshnet peers filtered by status | ||||||
| │ ├── login.sh # Interactive NordVPN login | ||||||
| │ ├── logout.sh # NordVPN logout | ||||||
| │ ├── nord_watchdog.sh # NordVPN connection watchdog daemon | ||||||
| │ ├── reset.sh # NordVPN settings reset | ||||||
| │ └── set_nickname.sh # Sets peer nickname in Meshnet | ||||||
| └── PowerShell/ | ||||||
| ├── CreateFile.ps1 # Creates test files of a specified size | ||||||
| ├── DeleteEmptyFolders.ps1 # Wrapper to delete empty subdirectories | ||||||
| ├── DeleteFiles.ps1 # Safe file deletion with age filtering & -WhatIf dry-run | ||||||
| ├── FindEmptySubDirectories.ps1 # Wrapper to find empty subdirectories | ||||||
| ├── ManageEmptyFolders.ps1 # Primary script for listing and removing empty folders | ||||||
| ├── ManageEmptyFolders.Function.ps1 # Reusable PowerShell function module | ||||||
| └── NextPVR.ps1 # NextPVR media recorder helper | ||||||
| ``` | ||||||
|
|
||||||
| Make me an exit_node god damn it! | ||||||
| --- | ||||||
|
|
||||||
| ## 🚀 Usage Guide | ||||||
|
|
||||||
| ### Bash Scripts (`bash/`) | ||||||
|
|
||||||
| #### 🔐 File Encryption & Decryption (`bash/encryption/`) | ||||||
| Encrypt and decrypt files using OpenSSL AES-256-CBC with PBKDF2 key derivation (100,000 iterations): | ||||||
|
|
||||||
| ```bash | ||||||
| # Encrypt a file (prompts securely for passphrase) | ||||||
| ./bash/encryption/encrypt_file.sh document.pdf | ||||||
|
|
||||||
| # Decrypt an encrypted file | ||||||
| ./bash/encryption/decrypt_file.sh document.pdf.enc | ||||||
| ``` | ||||||
|
|
||||||
| #### 🌐 NordVPN Meshnet Tools (`bash/nord/`) | ||||||
| Manage NordVPN connections and Meshnet exit nodes: | ||||||
|
|
||||||
| ```bash | ||||||
| # List online Meshnet peers | ||||||
| ./bash/nord/list_peers.sh online | ||||||
|
|
||||||
| # Configure an exit node | ||||||
| ./bash/nord/exit_node.sh | ||||||
|
|
||||||
| # Run watchdog daemon to monitor and maintain VPN connectivity | ||||||
| ./bash/nord/nord_watchdog.sh | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ### PowerShell Scripts (`PowerShell/`) | ||||||
|
|
||||||
| #### 📁 Empty Folder Cleanup (`PowerShell/ManageEmptyFolders.ps1`) | ||||||
| Find or delete empty folder hierarchies (deepest nested folders deleted first): | ||||||
|
|
||||||
| ```powershell | ||||||
| # List all empty subdirectories under a path | ||||||
| .\PowerShell\ManageEmptyFolders.ps1 -Path "C:\Data" | ||||||
|
|
||||||
| # Delete empty subdirectories safely with confirmation | ||||||
| .\PowerShell\ManageEmptyFolders.ps1 -Path "C:\Data" -Delete | ||||||
|
|
||||||
| # Dry-run deletion using -WhatIf | ||||||
| .\PowerShell\ManageEmptyFolders.ps1 -Path "C:\Data" -Delete -WhatIf | ||||||
|
Comment on lines
+86
to
+90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- README excerpt ---'
sed -n '70,100p' README.md
printf '%s\n' '--- candidate script files ---'
fd -i 'ManageEmptyFolders.ps1' .
printf '%s\n' '--- parameter and deletion logic ---'
script="$(fd -i -t f 'ManageEmptyFolders.ps1' . | head -n 1)"
if [ -n "$script" ]; then
rg -n -C 4 'param|Confirm|WhatIf|ShouldProcess|Delete|Remove-Item|SupportsShouldProcess|ConfirmImpact' "$script"
fi
printf '%s\n' '--- related documentation references ---'
rg -n -i -C 3 'ManageEmptyFolders|WhatIf|Confirm|confirmation|empty subdirector' README.md PowerShell 2>/dev/null || trueRepository: terjeinnerdal/scripts Length of output: 10569 🌐 Web query:
💡 Result: In PowerShell, the automatic confirmation behavior is governed by the interaction between the ConfirmImpact of a command and the $ConfirmPreference preference variable [1][2]. The default values are: - $ConfirmPreference: High [2][3][4] - ConfirmImpact (for a function using [CmdletBinding(SupportsShouldProcess)] without an explicit ConfirmImpact specified): Medium [1][5] Automatic confirmation behavior: PowerShell automatically prompts the user for confirmation when a command's assigned ConfirmImpact level is equal to or greater than the current value of the $ConfirmPreference variable [2][6]. Because the default $ConfirmPreference is High and the default ConfirmImpact for a function supporting ShouldProcess is Medium, functions with the default impact do not prompt the user for confirmation by default [1][5][6]. To trigger an automatic confirmation prompt for such a function, you must either explicitly set the function's ConfirmImpact to High or lower the user's $ConfirmPreference to Medium or Low [1][5]. If the $ConfirmPreference variable is set to None, PowerShell will never automatically prompt for confirmation, regardless of the command's ConfirmImpact [2]. Users can always override this behavior for a single command by using the -Confirm or -Confirm:$false parameters [2]. Citations:
Add
🤖 Prompt for AI Agents |
||||||
| ``` | ||||||
|
|
||||||
| #### 🧹 Safe File Cleanup (`PowerShell/DeleteFiles.ps1`) | ||||||
| Remove files matching a filter pattern and age threshold: | ||||||
|
|
||||||
| ```powershell | ||||||
| # Delete .log files older than 30 days under C:\Logs (dry-run mode) | ||||||
| .\PowerShell\DeleteFiles.ps1 -Path "C:\Logs" -Filter "*.log" -DaysOld 30 -Recurse -WhatIf | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## 🤖 Code Quality & CI | ||||||
|
|
||||||
| This repository uses [GitHub Actions](file:///.github/workflows/lint.yml) to ensure code quality on every push and pull request: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Use a repository-relative workflow link.
Proposed fix-This repository uses [GitHub Actions](file:///.github/workflows/lint.yml) to ensure code quality on every push and pull request:
+This repository uses [GitHub Actions](./.github/workflows/lint.yml) to ensure code quality on every push and pull request:📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| - **ShellCheck**: Static analysis for all `.sh` scripts. | ||||||
| - **PSScriptAnalyzer**: Best-practice rules for `.ps1` scripts. | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #! /usr/bin/bash | ||
| #!/usr/bin/env bash | ||
|
|
||
| sudo apt autoremove snapd | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #! /usr/bin/bash | ||
| #!/usr/bin/env bash | ||
| FILENAME="$1" | ||
| echo "$FILENAME" | ||
| COUNTER=0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: terjeinnerdal/scripts
Length of output: 7842
🌐 Web query:
site:docs.github.com GitHub Actions GITHUB_TOKEN permissions unspecified permissions contents read default repository organization settings💡 Result:
When you explicitly define the permissions key in a GitHub Actions workflow file, any permissions not listed in that key are automatically set to none (no access), with the sole exception of the metadata scope, which always retains read access [1][2]. This behavior applies whether you are configuring permissions at the workflow level or the job level [1]. By default, if the permissions key is omitted entirely, the GITHUB_TOKEN receives permissions based on the settings configured at the enterprise, organization, or repository level [1][3][4]. These repository and organization settings offer two primary modes [5][6]: 1. Permissive: Grants read/write access to most scopes, including contents and packages. 2. Restricted: Limits the GITHUB_TOKEN to read-only access for contents and packages, with all other scopes set to none. Because the explicit use of the permissions key overrides these defaults and sets unspecified permissions to none, it is considered a security best practice to use this key to follow the principle of least privilege, explicitly granting only the access required for your specific workflow or job [7][1][2].
Citations:
🌐 Web query:
site:github.com/actions/checkout README token contents read permission💡 Result:
The phrase "README token contents read permission" refers to a common configuration requirement for GitHub Actions workflows, specifically when using the actions/checkout action [1][2][3]. In GitHub Actions, when you define the permissions key within a workflow file, all permissions not explicitly specified are set to none [4]. Because the actions/checkout action requires access to the repository's files to clone them, it specifically necessitates the contents: read permission [1][5][6]. If you configure other permissions for your job (like pages: write or id-token: write) but fail to include contents: read, the checkout action will fail because the GITHUB_TOKEN used by the runner will lack the necessary access to read the repository's contents [4][6]. To ensure the action functions correctly, it is recommended to include the following in your workflow YAML [1][7][3]: permissions: contents: read This setting provides the minimum required scope for the action to pull the code from the repository [8][3]. If you are using a Personal Access Token (PAT) instead of the default GITHUB_TOKEN, that token must also be granted at least read access to Contents and Metadata [8].
Citations:
🏁 Script executed:
Repository: terjeinnerdal/scripts
Length of output: 630
Restrict the workflow token permissions.
Because
permissionsis omitted,GITHUB_TOKENuses repository, organization, or enterprise defaults, which can grant write access. The jobs only check out and analyze source files. Set workflow-levelcontents: read; unspecified permissions then remain unavailable.🧰 Tools
🪛 zizmor (1.29.0)
[warning] 1-37: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents
Source: Linters/SAST tools