initial commit via gitinitshit

This commit is contained in:
2025-08-02 12:42:31 -06:00
commit f3b8d793a7
63 changed files with 2173 additions and 0 deletions
@@ -0,0 +1 @@
donkeydicks:pope:
+17
View File
@@ -0,0 +1,17 @@
if ($args) {
$message=$args -join ' '
} else {
if(test-path './version.txt') {
$message = $(get-content './version.txt')
} else {
$message = $(Get-Date -uformat "%s")
}
}
echo "git commit message: '$message'"
git add .
git commit -m "$message"
git push
echo "Done :3"
+20
View File
@@ -0,0 +1,20 @@
# todo, param and defaults these up
$remote_dir = "/var/www/html/Media-Viewer"
$remote_host = "pi3"
$remote_cmd = "echo REMOTE pull $remote_dir; git -C $remote_dir pull; echo REMOTE add $remote_diradding; git -C $remote_dir add .; echo REMOTE commit $remote_dir; git -C $remote_dir commit -m `$(date +%s); echo REMOTE push $remote_dir; git -C $remote_dir push; echo -e `"\nREMOTE status $remote_dir\n`"; git -C $remote_dir status;"
echo "`nLOCAL pulling`n"
git pull
echo "`nLOCAL adding, comitting and pushing`n"
gitshit # usin gitshit here lmfao maybe make message a param
echo "`nLOCAL status`n"
git status
# run da REMOTE
echo "`nREMOTE running sync"
ssh $remote_host "/bin/bash -c $remote_cmd"
echo "`nLOCAL status`n"
git status
+6
View File
@@ -0,0 +1,6 @@
param (
[Parameter(Mandatory=$true)]
[string]$infile
)
Invoke-Expression "$PSScriptRoot\winhash.ps1 $infile MD5"
+25
View File
@@ -0,0 +1,25 @@
$counter = 1;
$paths_file = ".\paths.txt"
$destination_dir = ""
$sleep_seconds = 90
# infinite loop to run through to and loop every $sleep_seconds seconeds
while($true) {
Write-Host "`n`nNew Rotation!`n`tRotation $counter `n`tCopying...`n`n"
# loop through paths in $paths_file
foreach($line in Get-Content "$paths_file") {
Clear-Host
Write-Host "Handling $line on rotation $counter"
# copy the path
$path = $line
# split $line by \ and return last element
$dirname = $line -split "\\" | Select-Object -Last 1
# do the copy
robocopy /e /z $path $destination_dir\$dirname
}
Clear-Host
Write-Host "`n`nFinished Rotation $counter`n`tSleeping 90 Seconds...`n`n"
# sleep wont start until robopy loop is finished
Start-Sleep -Seconds $sleep_seconds # sleep $sleep_seconds seconds
$counter++;
}
+74
View File
@@ -0,0 +1,74 @@
# `pwsh.exe -c "`"C:\path\to\redundant-backup.ps1`" -logFile `"`" -simpleLogFile `"`""`
# `Start-Process -filepath "C:\path\to\redundant-backup.ps1" -logFile "" -simpleLogFile ""`
# `redundant-backup -logFile "" -simpleLogFile ""`
param([string] $logFile,
[string] $simpleLogFile
)
$startUnixSeconds = get-date -uformat "%s" # unix epoch seconds for duration
$startDateHuman = get-date # human readable begin date
$startDateFilename = get-date -format 'yyyy-MM-dd-hhmm' # filename friendly date format
$warningFile = "C:\Users\human\OneDrive\Desktop\backup_error_$startDateFilename.log" # file to create to notify of a failure
$jobName = "Weekly-Backup-$startDateFilename" # name for job in case wanna restart an interrupted one
$resticRunning = "E:\restic_backups_rolling" # from dir (restic)
$redundantLocal = "D:\restic_backups_redundancy_rolling" # to dir (local drive)
$redundantLocalNetwork = "R:\restics_backups_redundancy_rolling" # to dir (network mapped drive location)
$redundantAirGap = "S:\restic_backups_redundancy_rolling" # set backup usb to use S
$logGuideString = "Verb | Current Date and Time (Current Time Unix Seconds) | Start Date and Time (Start Time Unix Seconds) | Time Elapsed in Seconds | From Directory | To Directory | Job Name | Exit Status"
function appendToLog {
param([string]$verb="INFO", [string]$exitCode="NONE", [string]$log="$logFile", [string]$fromDir="NONE", [string]$toDir="NONE")
$timeCalc = $(Get-Date -uformat "%s")-$startUnixSeconds
# Verb | Current Date and Time (Current Time Unix Seconds) | Start Date and Time (Start Time Unix Seconds) | Time Elapsed in Seconds | From Directory | To Directory | Job Name | Exit Status
$logString = "$verb | $(Get-Date) ($(Get-Date -uformat "%s")) | $startDateHuman ($startUnixSeconds) | $timeCalc | $fromDir | $toDir | $jobName | $exitCode"
echo "$logString"
echo "$logString" >> "$log"
}
function appendToErrorLog {
param ( $exceptionMessage, $part )
$errorString = "`nFAIL on $part`nException: $exceptionMessage`nVars:`n`tstartDateHuman: $startDateHuman`n`tstart: $startUnixSecondsUnixSecons`n`tappendToErrorLog: $appendToErrorLog`n`tlogFile: $logFile`n`twarningFile: $warningFile`n`tresticRunning: $resticRunning`n`tredundantLocal: $redundantLocal`n`tredundantLocalNetwork: $redundantLocalNetwork`n`tjobName: $jobName"
echo "$errorString"
try { echo "$errorString" > "$warningFile" } catch { echo "Error: $warningFile Not Found" }
}
function doBackup {
param ( [string]$fromDir="NONE", [string]$toDir="NONE", [string]$tagString="INFO" )
echo "`n$tagString"
echo "`tFollow log with:`n`t`tGet-Content `"$logFile`" -Wait -Tail 10`n"
appendToLog -verb "START-$tagString" -log "$logFile" -toDir "$toDir" -fromDir "$fromDir"
robocopy "$fromDir" "$toDir" /E /Z /FP /NP /R:2 /W:1 /SAVE:"$jobString" /LOG+:"$logFile"
appendToLog -verb "FINISH-$tagString" -exitCode "$?" -log "$logFile" -toDir "$toDir" -fromDir "$fromDir"
}
echo "Initializing Logs"
touch "$runningFile"
echo "$logGuideString" > "$logFile"
appendToLog -verb "INITIALIZE-LOG-FILES" -exitCode "$?" -log "$logFile"
echo "`n$logGuideString`n"
# run da backupssss
doBackup -fromDir "$resticRunning" -toDir "$redundantLocal" -tagString "COPY-LOCAL" -jobString "$jobName" # local
appendToLog -verb "COPY-LOCAL" -exitCode "$?" -log "$logFile" -fromDir "$resticRunning" -toDir "$redundantLocal"
doBackup -fromDir "$resticRunning" -toDir "$redundantLocalNetwork" -tagString "COPY-LOCAL-NETWORK" -jobString "$jobName" # network
appendToLog -verb "COPY-LOCAL-NETWORK" -exitCode "$?" -log "$logFile" -fromDir "$resticRunning" -toDir "$redundantLocalNetwork"
doBackup -fromDir "$resticRunning" -toDir "$redundantAirGap" -tagString "COPY-AIRGAP" -jobString "$jobName" # airgap
appendToLog -verb "COPY-AIRGAP" -exitCode "$?" -log "$logFile" -fromDir "$resticRunning" -toDir "$redundantAirGap"
appendToLog -verb "DONE" -log "$logFile"
+6
View File
@@ -0,0 +1,6 @@
param (
[Parameter(Mandatory=$true)]
[string]$infile
)
Invoke-Expression "$PSScriptRoot\winhash.ps1 $infile SHA1"
+6
View File
@@ -0,0 +1,6 @@
param (
[Parameter(Mandatory=$true)]
[string]$infile
)
Invoke-Expression "$PSScriptRoot\winhash.ps1 $infile SHA256"
+6
View File
@@ -0,0 +1,6 @@
param (
[Parameter(Mandatory=$true)]
[string]$infile
)
Invoke-Expression "$PSScriptRoot\winhash.ps1 $infile SHA384"
+6
View File
@@ -0,0 +1,6 @@
param (
[Parameter(Mandatory=$true)]
[string]$infile
)
Invoke-Expression "$PSScriptRoot\winhash.ps1 $infile SHA512"
+11
View File
@@ -0,0 +1,11 @@
param(
[string]
$session = 'pi3'
)
while($True) {
ssh $session
echo "Waiting 5 Seconds..."
sleep 5
wait-on-host -hostname $session
}
+10
View File
@@ -0,0 +1,10 @@
$remote_host = "pi3"
$remote_dir = "/var/www/html/Media-Viewer"
echo "LOCAL: pulling"
git pull
echo "LOCAL: status"
git status
ssh $remote_host "echo 'REMOTE: pulling'; git -C $remote_dir pull; echo 'REMOTE: status'; git -C $remote_dir status"
+7
View File
@@ -0,0 +1,7 @@
# usage:
# testtime "some powershell command string"
param([string] $cmd)
$start=$(get-date -uformat "%s")
invoke-expression "$cmd"
$end=$(get-date -uformat "%s")
echo "`n`ntime: $($end - $start)`n`n"
+85
View File
@@ -0,0 +1,85 @@
# usage:
# `.\wait-on-host.ps1 -hostname <DOMAIN_NAME_OR_IP> -sleep <SECONDS_TO_SLEEP_PER_CYCLE> -pingcount <NUMBER_OF_TIMES_TO_PING_PER_ITERATION> -max <MAX_NUMBER_OF_ITERATIONS> -hold <SECONDS_TO_WAIT_AFTER_FIRST_RESPONSE>`
#
# defaults:
# hostname: cable-wind.local
# sleep: 25
# pingcount: 1
# max: 500
# hold: 30
# ex. `.\wait-on-host.ps1 -hostname google.com -sleep 10 -pingcount 5`
param(
[string]
$hostname = "cable-wind.local",
[int]
$sleep = 25,
[int]
$pingcount = 1,
[int]
$max = 500,
[bool]
$loop = 0, # 1 to loop
[int]
$hold = 30
)
if($hostname -eq 'help') {
echo "usage:`n`twait-on-host [help] -hostname <DOMAIN_NAME_OR_IP> -sleep <SECONDS_TO_SLEEP_PER_CYCLE> -pingcount <NUMBER_OF_TIMES_TO_PING_PER_ITERATION> -max <MAX_NUMBER_OF_ITERATIONS> -hold <SECONDS_TO_WAIT_AFTER_FIRST_RESPONSE>`n`twait-on-host help`n`t`tthis help message`n`twait-on-host 8.8.8.8`n`t`twait on 8.8.8.8 with defaults`n`tdefaults:`n`t`thostname: cable-wind.local`n`t`tsleep: 25`n`t`tpingcount: 1`n`t`tmax: 500`n`t`thold: 30`n`tex. wait-on-host -hostname google.com -sleep 10 -pingcount 5`n";
exit;
}
$iterations = 0;
while(1 -eq 1) { # infinite loop
echo "`nHost: $hostname" # Iterations: $iterations Count: $pingcount Sleep: $sleep Max: $max`n`tFlushing dns..."
echo "`tFlushing DNS"
ipconfig /flushdns >NUL 2>&1 # redirects output nowhere
if($?) {
echo "`t`tDone."
} else {
echo "`t`tFAILED TO FLUSH DNS! EXITING!"
exit
}
echo "`tPinging..."
# $pingObj = Test-Connection -Count $pingcount -TargetName "$hostname" # powershell Test-Connection -Ping is default and redundant
$pingObj = Test-Connection -Count $pingcount -TargetName "$hostname" 2>&1
if($pingObj.Status -eq "Success") { # if return status of abopve (ping -n 1...) is True
# $pingObj = Test-Connection -Count $pingcount -TargetName "$hostname" # powershell Test-Connection -Ping is default and redundant
$ip = $pingObj.Address.IPAddressToString # get the bare ip out
echo "`t`tSuccess!`n`t`tIP: $ip`n`t`tHost: $hostname`n`t`tURL (host): http://$hostname`n`t`tURL (IP): http://$ip"
if($loop) {
echo "Sleeping $sleep Seconds..."
sleep $sleep # sleepy time
} else {
echo "`nWaiting $hold Seconds to Make Sure..."
sleep $hold
echo "`nReady!`n"
break
}
} else {
echo "`t`tNOT FOUND YET"
echo "`nSleeping $sleep Seconds..."
sleep $sleep # sleepy time
}
if($iterations -gt $max) {
echo "`nMAX ITERATIONS OF $max REACHED! EXITINTG`n"
exit
}
$iterations++
}
+2
View File
@@ -0,0 +1,2 @@
git add .
git commit -m "waypoint"
+5
View File
@@ -0,0 +1,5 @@
@ECHO OFF
mrt
sfc /scannow
DISM /Online /Cleanup-Image /RestoreHealth
chkdsk /r C:
+38
View File
@@ -0,0 +1,38 @@
# Usage:
## .\winhash.ps1 <FILE> <ALGO>
## Algos Supported:
### MD5
### SHA1
### SHA256
### SHA384
### SHA512
## Example:
### .\winhash.ps1 sillyfilly.bin SHA256
## Outputs to terminal and to a text file
### Text file name format <input filepath>.<unix epoch microseconds>.<hashing algorithm>.txt
param (
[Parameter(Mandatory=$true)] # prompt for input if not specified via cli
[string]$infile,
[Parameter(Mandatory=$true)] # this 1 2 :pope:
[string]$algo
)
function Get-UnixMicroseconds {
$unixEpoch = [DateTimeOffset]'1970-01-01T00:00:00Z' # unix epoch constant
$currentTime = [DateTimeOffset]::UtcNow # current utc time
$timeDifferenceTicks = $currentTime.Ticks - $unixEpoch.Ticks # subtract current time from unix epoch constant in ticks
$microseconds = [Int64]($timeDifferenceTicks / 10) # use 64bit int, divide ticks by 10 to give microseconds
# I am literally using Unix microseconds because they are more fun than Unix seconds :pinkie:
return $microseconds
}
# jesus fuckin analbeads the selection of hash algos in powershell is weird and limited
# probably because Bill Gates and Satya Nadella get together with the other C-suite executives
# and hypergoon to leagelese in clickwrap agreements that absolves them of liability and
# lets them sell our private data and other assorted dickpics or sumtin idk man lmao
$hash = $(Get-FileHash -Path $infile -Algorithm $algo | Format-List) # do da fookin hashin right dafucc here
echo $hash # show user
echo $hash > "$infile.$(Get-UnixMicroseconds).$algo.txt" # make the txt file