🦈🏠🐜 Initial Commit 🐜🦈🏠

This commit is contained in:
2026-01-29 19:27:26 -05:00
commit ad74c9c42f
21 changed files with 1499 additions and 0 deletions
@@ -0,0 +1,26 @@
# PowerShell script for Windows container initialization
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: MIT
# @Copyright: Copyright 2026 CasjaysDev
# @File: 00-init.ps1
# @Description: Script to run init
$ErrorActionPreference = 'Stop'
$exitCode = 0
# Predefined actions - Clear template directories
if (Test-Path 'C:/ProgramData/template-files/data') {
Get-ChildItem 'C:/ProgramData/template-files/data' -Recurse -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
if (Test-Path 'C:/ProgramData/template-files/config') {
Get-ChildItem 'C:/ProgramData/template-files/config' -Recurse -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
if (Test-Path 'C:/ProgramData/template-files/defaults') {
Get-ChildItem 'C:/ProgramData/template-files/defaults' -Recurse -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
# Main script logic here
exit $exitCode
@@ -0,0 +1,15 @@
# PowerShell script for Windows container system setup
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: MIT
# @Copyright: Copyright 2026 CasjaysDev
# @File: 01-system.ps1
# @Description: Script to run system setup
$ErrorActionPreference = 'Stop'
$exitCode = 0
# System configuration here
exit $exitCode
@@ -0,0 +1,15 @@
# PowerShell script for Windows container package setup
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: MIT
# @Copyright: Copyright 2026 CasjaysDev
# @File: 02-packages.ps1
# @Description: Script to run package initialization
$ErrorActionPreference = 'Stop'
$exitCode = 0
# Package initialization here
exit $exitCode
@@ -0,0 +1,15 @@
# PowerShell script for Windows container files setup
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: MIT
# @Copyright: Copyright 2026 CasjaysDev
# @File: 03-files.ps1
# @Description: Script to configure system files
$ErrorActionPreference = 'Stop'
$exitCode = 0
# File configuration here
exit $exitCode
@@ -0,0 +1,15 @@
# PowerShell script for Windows container user setup
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: MIT
# @Copyright: Copyright 2026 CasjaysDev
# @File: 04-users.ps1
# @Description: Script to configure users
$ErrorActionPreference = 'Stop'
$exitCode = 0
# User configuration here
exit $exitCode
@@ -0,0 +1,15 @@
# PowerShell script for Windows container custom setup
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: MIT
# @Copyright: Copyright 2026 CasjaysDev
# @File: 05-custom.ps1
# @Description: Script for custom configurations
$ErrorActionPreference = 'Stop'
$exitCode = 0
# Custom configuration here
exit $exitCode
@@ -0,0 +1,15 @@
# PowerShell script for Windows container post setup
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: MIT
# @Copyright: Copyright 2026 CasjaysDev
# @File: 06-post.ps1
# @Description: Script for post-installation tasks
$ErrorActionPreference = 'Stop'
$exitCode = 0
# Post-installation tasks here
exit $exitCode
@@ -0,0 +1,23 @@
# PowerShell script for Windows container cleanup
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: MIT
# @Copyright: Copyright 2026 CasjaysDev
# @File: 07-cleanup.ps1
# @Description: Script for cleanup tasks
$ErrorActionPreference = 'Stop'
$exitCode = 0
# Clean Windows temp files
Remove-Item -Path 'C:\Windows\Temp\*' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path 'C:\Users\*\AppData\Local\Temp\*' -Recurse -Force -ErrorAction SilentlyContinue
# Clean package caches
if (Get-Command winget -ErrorAction SilentlyContinue) {
# Winget doesn't have explicit cache clean yet
Write-Host 'Winget cache management'
}
exit $exitCode
+101
View File
@@ -0,0 +1,101 @@
# PowerShell entrypoint for Windows container
# @Version: 202601231310-git
# @Author: CasjaysDev
# @Contact: CasjaysDev <docker-admin@casjaysdev.pro>
# @License: WTFPL
# @Copyright: Copyright (c) 2026 Jason Hempstead, Casjays Developments
# @File: entrypoint.ps1
# @Description: Entrypoint file for windows container
param(
[string]$Command = ""
)
$ErrorActionPreference = 'Stop'
$SERVICE_PID_FILE = "C:\ProgramData\container.pid"
$SERVICE_IS_RUNNING = "no"
# Trap handler for cleanup
trap {
Write-Host "Container received shutdown signal"
if ($SERVICE_IS_RUNNING -ne "yes" -and (Test-Path $SERVICE_PID_FILE)) {
Remove-Item -Path $SERVICE_PID_FILE -Force -ErrorAction SilentlyContinue
}
exit 1
}
# Load debug configuration
if (Test-Path "C:\config\.debug") {
$env:DEBUGGER_OPTIONS = Get-Content "C:\config\.debug" -Raw
} else {
$env:DEBUGGER_OPTIONS = ""
}
if ($env:DEBUGGER -eq "on" -or (Test-Path "C:\config\.debug")) {
$VerbosePreference = 'Continue'
$DebugPreference = 'Continue'
Write-Host "Debugging enabled"
}
# Function to check service health
function Test-ServiceHealth {
# Add health check logic here
# Return $true if healthy, $false otherwise
return $true
}
# Handle commands
switch ($Command.ToLower()) {
"healthcheck" {
if (Test-ServiceHealth) {
Write-Host "Service is healthy"
exit 0
} else {
Write-Host "Service is unhealthy"
exit 1
}
}
"version" {
Write-Host "Windows Container Version: $env:BUILD_VERSION"
Write-Host "Distro: Windows Server Core $env:DISTRO_VERSION"
exit 0
}
default {
# Default startup behavior
Write-Host "Starting Windows container..."
Write-Host "Hostname: $env:HOSTNAME"
Write-Host "Timezone: $env:TIMEZONE"
# Set timezone
try {
if ($env:TIMEZONE) {
& tzutil.exe /s $env:TIMEZONE
Write-Host "Timezone set to: $env:TIMEZONE"
}
} catch {
Write-Warning "Failed to set timezone: $_"
}
# Create PID file
$PID | Out-File -FilePath $SERVICE_PID_FILE -Encoding ASCII
$global:SERVICE_IS_RUNNING = "yes"
# Keep container running
Write-Host "Container started successfully"
Write-Host "Press Ctrl+C to stop"
# Run any startup commands here
# Keep alive loop
try {
while ($true) {
Start-Sleep -Seconds 60
}
} finally {
# Cleanup
if (Test-Path $SERVICE_PID_FILE) {
Remove-Item -Path $SERVICE_PID_FILE -Force -ErrorAction SilentlyContinue
}
}
}
}
+155
View File
@@ -0,0 +1,155 @@
#!/usr/bin/env sh
# shellcheck shell=sh
# shellcheck disable=SC2016
# - - - - - - - - - - - - - - - - - - - - - - - - -
USER_UID="$(id -u 2>/dev/null || echo 0)"
USER_GID="$(id -g 2>/dev/null || echo 0)"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Detect package manager
if [ -x "$(command -v winget 2>/dev/null)" ]; then
pkmgr_cmd="winget"
pkmgr_clean_cmd="true"
pkmgr_mkcache_cmd="true"
pkmgr_update_cmd="$pkmgr_cmd upgrade --all --accept-source-agreements --accept-package-agreements"
pkmgr_install_cmd="$pkmgr_cmd install --accept-source-agreements --accept-package-agreements $PKMGR_OPTS"
elif [ -x "$(command -v choco 2>/dev/null)" ]; then
pkmgr_cmd="choco"
pkmgr_clean_cmd="$pkmgr_cmd cache clean"
pkmgr_mkcache_cmd="true"
pkmgr_update_cmd="$pkmgr_cmd upgrade all -y"
pkmgr_install_cmd="$pkmgr_cmd install -y $PKMGR_OPTS"
elif [ -x "$(command -v apt 2>/dev/null)" ]; then
export DEBIAN_FRONTEND=noninteractive
pkmgr_cmd="apt"
pkmgr_clean_cmd="$pkmgr_cmd clean"
pkmgr_mkcache_cmd="$pkmgr_cmd update"
pkmgr_update_cmd="$pkmgr_cmd upgrade -yy"
pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS"
pkmgr_install_post="$pkmgr_cmd --fix-broken install"
elif [ -x "$(command -v apt-get 2>/dev/null)" ]; then
export DEBIAN_FRONTEND=noninteractive
pkmgr_cmd="apt-get"
pkmgr_clean_cmd="$pkmgr_cmd clean"
pkmgr_mkcache_cmd="$pkmgr_cmd update"
pkmgr_update_cmd="$pkmgr_cmd upgrade -yy"
pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS"
pkmgr_install_post="$pkmgr_cmd --fix-broken install"
elif [ -x "$(command -v dnf 2>/dev/null)" ]; then
pkmgr_cmd="dnf"
pkmgr_clean_cmd="$pkmgr_cmd clean all"
pkmgr_mkcache_cmd="$pkmgr_cmd makecache"
pkmgr_update_cmd="$pkmgr_cmd update -y --skip-broken $PKMGR_OPTS"
pkmgr_install_cmd="$pkmgr_cmd install -y --skip-broken $PKMGR_OPTS"
elif [ -x "$(command -v yum 2>/dev/null)" ]; then
pkmgr_cmd="yum"
pkmgr_clean_cmd="$pkmgr_cmd clean all"
pkmgr_mkcache_cmd="$pkmgr_cmd makecache"
pkmgr_update_cmd="$pkmgr_cmd update -y --skip-broken $PKMGR_OPTS"
pkmgr_install_cmd="$pkmgr_cmd install -y --skip-broken $PKMGR_OPTS"
elif [ -n "$(command -v pacman 2>/dev/null)" ]; then
pkmgr_cmd="pacman"
pkmgr_mkcache_cmd="true"
pkmgr_clean_cmd="$pkmgr_cmd -Scc --noconfirm"
pkmgr_update_cmd="$pkmgr_cmd -Syyu --noconfirm $PKMGR_OPTS"
pkmgr_install_cmd="$pkmgr_cmd -Syy --noconfirm $PKMGR_OPTS"
elif [ -x "$(command -v apk 2>/dev/null)" ]; then
pkmgr_cmd="apk"
pkmgr_mkcache_cmd="true"
pkmgr_clean_cmd="$pkmgr_cmd cache clean"
pkmgr_update_cmd="$pkmgr_cmd -U upgrade --no-cache $PKMGR_OPTS"
pkmgr_install_cmd="$pkmgr_cmd add --no-cache $PKMGR_OPTS"
elif [ -x "$(command -v zypper 2>/dev/null)" ]; then
pkmgr_cmd="zypper"
pkmgr_mkcache_cmd="true"
pkmgr_clean_cmd="$pkmgr_cmd clean --all"
pkmgr_update_cmd="$pkmgr_cmd update -y $PKMGR_OPTS"
pkmgr_install_cmd="$pkmgr_cmd install -y $PKMGR_OPTS"
else
pkmgr_cmd="true"
pkmgr_mkcache_cmd="$pkmgr_cmd"
pkmgr_clean_cmd="$pkmgr_cmd"
pkmgr_update_cmd="$pkmgr_cmd"
pkmgr_install_cmd="$pkmgr_cmd"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -f "C:/config/pkmgr/settings.conf" ]; then
. "C:/config/pkmgr/settings.conf"
elif [ -f "C:/ProgramData/pkmgr/settings.conf" ]; then
. "C:/ProgramData/pkmgr/settings.conf"
else
mkdir -p "C:/config/pkmgr"
cat <<EEOF >"C:/config/pkmgr/settings.conf"
pkmgr_cmd="$pkmgr_cmd"
pkmgr_clean_cmd="$pkmgr_clean_cmd"
pkmgr_update_cmd="$pkmgr_update_cmd"
pkmgr_install_cmd="$pkmgr_install_cmd"
pkmgr_mkcache_cmd="$pkmgr_mkcache_cmd"
EEOF
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
[ -n "$pkmgr_cmd" ] || { echo "Can not determine the package manager" && exit 1; }
# - - - - - - - - - - - - - - - - - - - - - - - - -
case "$1" in
pip)
shift 1
pip_bin="$(command -v python3 2>/dev/null || command -v python2 2>/dev/null || command -v python 2>/dev/null || echo "")"
py_version="$($pip_bin --version | sed 's|[pP]ython ||g' | awk -F '.' '{print $1$2}' | grep '[0-9]' || echo "0")"
[ "$py_version" -gt "310" ] && pip_opts="--break-system-packages " || pip_opts=""
case "$1" in
install)
shift 1
pkg_list="$*"
for pkg in $pkg_list; do
$pip_bin -m pip $pip_opts "$pkg"
done
;;
*)
for pkg in "$@"; do
$pip_bin -m pip "$pkg"
done
;;
esac
exit
;;
install)
shift 1
[ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd"
if [ -f "$1" ]; then
install_list="$(cat "$1")"
else
install_list="$*"
fi
for pkg in $install_list;do
echo "installing packages command: $pkmgr_install_cmd $pkg"
$pkmgr_install_cmd $pkg
if [ -n "$pkmgr_install_post" ]; then eval $pkmgr_install_post; fi
done
exit
;;
update | upgrade)
shift $#
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_update_cmd="sudo $pkmgr_install_cmd"
echo "Updating packages command: $pkmgr_update_cmd"
$pkmgr_mkcache_cmd
$pkmgr_update_cmd
exit $?
;;
clean)
shift $#
[ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_clean_cmd="sudo $pkmgr_clean_cmd"
echo "Cleaning package cache: $pkmgr_clean_cmd"
$pkmgr_clean_cmd
exit $?
;;
*)
[ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_cmd="sudo $pkmgr_cmd"
echo "executing packages command: $pkmgr_cmd $*"
$pkmgr_cmd "$@"
exit $?
;;
esac
# - - - - - - - - - - - - - - - - - - - - - - - - -
# end
+102
View File
@@ -0,0 +1,102 @@
# PowerShell Package Manager Wrapper
# Supports winget, chocolatey, and can be extended
param(
[Parameter(Mandatory=$false)]
[string]$Action = "",
[Parameter(ValueFromRemainingArguments=$true)]
[string[]]$Packages
)
$ErrorActionPreference = 'Stop'
# Detect package manager
$pkgMgr = $null
$installCmd = $null
$updateCmd = $null
$cleanCmd = $null
if (Get-Command winget -ErrorAction SilentlyContinue) {
$pkgMgr = "winget"
$installCmd = { param($pkg) & winget install --id $pkg --accept-source-agreements --accept-package-agreements --silent }
$updateCmd = { & winget upgrade --all --accept-source-agreements --accept-package-agreements --silent }
$cleanCmd = { Write-Host "Winget cache management" }
} elseif (Get-Command choco -ErrorAction SilentlyContinue) {
$pkgMgr = "chocolatey"
$installCmd = { param($pkg) & choco install $pkg -y }
$updateCmd = { & choco upgrade all -y }
$cleanCmd = { & choco cache clean }
} else {
Write-Error "No package manager found. Please install winget or chocolatey."
exit 1
}
Write-Host "Using package manager: $pkgMgr"
# Load config if exists
$configPath = "C:\config\pkmgr\settings.ps1"
if (Test-Path $configPath) {
. $configPath
}
# Handle commands
switch ($Action.ToLower()) {
"install" {
if (-not $Packages -or $Packages.Count -eq 0) {
Write-Warning "No packages specified"
exit 0
}
foreach ($pkg in $Packages) {
if ($pkg.Trim() -ne "") {
Write-Host "Installing package: $pkg"
try {
& $installCmd $pkg
} catch {
Write-Error "Failed to install $pkg : $_"
}
}
}
}
"update" {
Write-Host "Updating all packages"
& $updateCmd
}
"upgrade" {
Write-Host "Upgrading all packages"
& $updateCmd
}
"clean" {
Write-Host "Cleaning package cache"
& $cleanCmd
# Clean Windows temp
Remove-Item -Path 'C:\Windows\Temp\*' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Users\$env:USERNAME\AppData\Local\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue
}
"version" {
if ($pkgMgr -eq "winget") {
& winget --version
} elseif ($pkgMgr -eq "chocolatey") {
& choco --version
}
}
default {
Write-Host "pkmgr - Package Manager Wrapper for Windows Containers"
Write-Host ""
Write-Host "Usage: pkmgr <action> [packages...]"
Write-Host ""
Write-Host "Actions:"
Write-Host " install <pkg> - Install package(s)"
Write-Host " update - Update all packages"
Write-Host " upgrade - Upgrade all packages"
Write-Host " clean - Clean package cache"
Write-Host " version - Show package manager version"
Write-Host ""
Write-Host "Current package manager: $pkgMgr"
}
}