From 5c5bde924409b2c6f677bdc962ed2a06d84844d3 Mon Sep 17 00:00:00 2001 From: jcolebrand Date: Tue, 30 May 2023 23:15:46 -0700 Subject: [PATCH] server build notes and such --- .../Public/Add-LDAPSudoerUser.ps1 | 22 ++++ .../Public/Get-AllAffectingProfilesAsText.ps1 | 14 +++ .../Public/Merge-MkvVideos.ps1 | 70 ++++++++++++ .../Scratch/PS Verbs.txt | 100 ++++++++++++++++++ .../Scratch/Server Build Notes/gocd keys | 2 + .../Scratch/Server Build Notes/sudoers.ldif | 32 ++++++ 6 files changed, 240 insertions(+) create mode 100644 Modules/Cole.PowerShell.Developer/Public/Add-LDAPSudoerUser.ps1 create mode 100644 Modules/Cole.PowerShell.Developer/Public/Get-AllAffectingProfilesAsText.ps1 create mode 100644 Modules/Cole.PowerShell.Developer/Public/Merge-MkvVideos.ps1 create mode 100644 Modules/Cole.PowerShell.Developer/Scratch/PS Verbs.txt create mode 100644 Modules/Cole.PowerShell.Developer/Scratch/Server Build Notes/gocd keys create mode 100644 Modules/Cole.PowerShell.Developer/Scratch/Server Build Notes/sudoers.ldif diff --git a/Modules/Cole.PowerShell.Developer/Public/Add-LDAPSudoerUser.ps1 b/Modules/Cole.PowerShell.Developer/Public/Add-LDAPSudoerUser.ps1 new file mode 100644 index 0000000..a6968fe --- /dev/null +++ b/Modules/Cole.PowerShell.Developer/Public/Add-LDAPSudoerUser.ps1 @@ -0,0 +1,22 @@ +function Add-LDAPSudoerUser { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + $Username + ) + + $logLead = Get-LogLeadName + + Write-Host "$logLead : Adding user to sudoers group in LDAP" + <# +cat > add-to-sudo-role.ldif << 'EOL' +dn: cn=sudo,ou=SUDOers,dc=jcolebrand,dc=info +changetype: modify +add: sudoUser +sudoUser: jgitlin +EOL + +ldapmodify -W -f add-to-sudo-role.ldif -D 'cn=Directory Manager' + #> +} diff --git a/Modules/Cole.PowerShell.Developer/Public/Get-AllAffectingProfilesAsText.ps1 b/Modules/Cole.PowerShell.Developer/Public/Get-AllAffectingProfilesAsText.ps1 new file mode 100644 index 0000000..dc5c023 --- /dev/null +++ b/Modules/Cole.PowerShell.Developer/Public/Get-AllAffectingProfilesAsText.ps1 @@ -0,0 +1,14 @@ +function Get-AllAffectingProfilesAsText { + [CmdletBinding()] + [OutputType([string[]])] + param() + + $resultingProfile = "" + $allProfilePaths = ($profile | Get-Member -MemberType NoteProperty).Name + foreach ($profileName in $allProfilePaths) { + $resultingProfile += "`n #File read from $profileName`n" + $resultingProfile += Get-Content -Path $profile.$profileName -ErrorAction Ignore -Raw + } + + return $resultingProfile +} \ No newline at end of file diff --git a/Modules/Cole.PowerShell.Developer/Public/Merge-MkvVideos.ps1 b/Modules/Cole.PowerShell.Developer/Public/Merge-MkvVideos.ps1 new file mode 100644 index 0000000..8ce5480 --- /dev/null +++ b/Modules/Cole.PowerShell.Developer/Public/Merge-MkvVideos.ps1 @@ -0,0 +1,70 @@ +function Merge-MkvVideos { +<# +.SYNOPSIS + Used to merge two MKV files into one output file + +.PARAMETER OutputFile + Target a single file for output, full name + +.PARAMETER Path + Two or more paths, comma separated, will concatenate in the order presented + +.LINK + https://mkvtoolnix.download/downloads.html +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [Alias('Target')] + [Alias('Output')] + [Alias('o')] + [string[]]$OutputFile, + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [Alias('Source')] + [Alias('Input')] + [string[]]$Path + ) + + $mkvmergePath = "/usr/bin/mkvmerge" + + $alternateMvkMergePath = (which mkvmerge) + + if (-not (Test-Path -Path $mkvmergePath)) { + if ($alternateMvkMergePath.indexOf(": no")) { + Write-Warning "Maybe you should do: [https://mkvtoolnix.download/downloads.html] ?" + throw "Could not find the path for mkvmerge [$mkvmergePath] Is it installed? Is it in the PATH?" + } else { + $mkvmergePath = $alternateMvkMergePath + } + } + + if ($Path.Count -lt 2) { + throw "Must supply more than one path to this function" + } + + if (Test-Path -Path $OutputFile) { + Write-Warning "The specified file already exists. This file will be overwritten." + } + + $commandArguments = @("-o", $OutputFile) + + $firstPath = $true + + foreach ($filePath in $Path) { + $filePath = Resolve-Path -Path $filePath + if (-not $firstPath) { + $commandArguments += "+" + } + $commandArguments += $filePath + $firstPath = $false + } + + $invokeArguments = @{ + Path = $mkvmergePath + Arguments = $commandArguments + } + + Invoke-CallPathWithArguments @invokeArguments +} \ No newline at end of file diff --git a/Modules/Cole.PowerShell.Developer/Scratch/PS Verbs.txt b/Modules/Cole.PowerShell.Developer/Scratch/PS Verbs.txt new file mode 100644 index 0000000..041c9a4 --- /dev/null +++ b/Modules/Cole.PowerShell.Developer/Scratch/PS Verbs.txt @@ -0,0 +1,100 @@ +Add +Approve +Assert +Backup +Block +Build +Checkpoint +Clear +Close +Compare +Complete +Compress +Confirm +Connect +Convert +ConvertFrom +ConvertTo +Copy +Debug +Deny +Deploy +Disable +Disconnect +Dismount +Edit +Enable +Enter +Exit +Expand +Export +Find +Format +Get +Grant +Group +Hide +Import +Initialize +Install +Invoke +Join +Limit +Lock +Measure +Merge +Mount +Move +New +Open +Optimize +Out +Ping +Pop +Protect +Publish +Push +Read +Receive +Redo +Register +Remove +Rename +Repair +Request +Reset +Resize +Resolve +Restart +Restore +Resume +Revoke +Save +Search +Select +Send +Set +Show +Skip +Split +Start +Step +Stop +Submit +Suspend +Switch +Sync +Test +Trace +Unblock +Undo +Uninstall +Unlock +Unprotect +Unpublish +Unregister +Update +Use +Wait +Watch +Write \ No newline at end of file diff --git a/Modules/Cole.PowerShell.Developer/Scratch/Server Build Notes/gocd keys b/Modules/Cole.PowerShell.Developer/Scratch/Server Build Notes/gocd keys new file mode 100644 index 0000000..e7766af --- /dev/null +++ b/Modules/Cole.PowerShell.Developer/Scratch/Server Build Notes/gocd keys @@ -0,0 +1,2 @@ +gogs -> gocd token f2ba5ad47e56620760ee2eba569bcb636061e520 +gocd -> first token dfbb1a530fbf17926b865afe9718219c8f1413b8 diff --git a/Modules/Cole.PowerShell.Developer/Scratch/Server Build Notes/sudoers.ldif b/Modules/Cole.PowerShell.Developer/Scratch/Server Build Notes/sudoers.ldif new file mode 100644 index 0000000..41a7745 --- /dev/null +++ b/Modules/Cole.PowerShell.Developer/Scratch/Server Build Notes/sudoers.ldif @@ -0,0 +1,32 @@ +cvtsudoers -b ou=SUDOers,dc=jcolebrand,dc=info -o ~/sudoers.ldif /etc/sudoers + +dn: ou=SUDOers,dc=jcolebrand,dc=info +objectclass: organizationalunit +ou: SUDOers +description: LDAP SUDO Entry + +dn: cn=defaults,ou=SUDOers,dc=jcolebrand,dc=info +objectClass: top +objectClass: sudoRole +cn: defaults +description: Default sudoOption's go here +sudoOption: !visiblepw +sudoOption: always_set_home +sudoOption: match_group_by_gid +sudoOption: always_query_group_plugin +sudoOption: env_reset +sudoOption: env_keep=COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS +sudoOption: env_keep+=MAIL QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE +sudoOption: env_keep+=LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES +sudoOption: env_keep+=LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE +sudoOption: env_keep+=LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY +sudoOption: secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/snapd/snap/bin + +dn: cn=sudo,ou=SUDOers,dc=jcolebrand,dc=info +objectClass: top +objectClass: sudoRole +cn: sudo +sudoUser: cbrand +sudoHost: ALL +sudoRunAsUser: ALL +sudoCommand: ALL