diff --git a/attach-disk.ps1 b/attach-disk.ps1 index 26f314e..a191918 100644 --- a/attach-disk.ps1 +++ b/attach-disk.ps1 @@ -11,9 +11,13 @@ function Write-Log { ) $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" if ($level -eq "ERR") { - Write-Err "$timestamp [$level] $message" + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Red + write-host $message }else{ - Write-Log "$timestamp [$level] $message" + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Green + write-host $message } } function Write-Err { diff --git a/configure-k3s.ps1 b/configure-k3s.ps1 index a6a6eae..ffbf034 100644 --- a/configure-k3s.ps1 +++ b/configure-k3s.ps1 @@ -10,7 +10,15 @@ function Write-Log { [string]$level = "INFO" ) $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" - Write-Output "$timestamp [$level] $message" + if ($level -eq "ERR") { + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Red + write-host $message + }else{ + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Green + write-host $message + } } $serviceFilePath = "/etc/systemd/system/k3s.service" diff --git a/firewalls.ps1 b/firewalls.ps1 index 5559229..b347dab 100644 --- a/firewalls.ps1 +++ b/firewalls.ps1 @@ -4,7 +4,15 @@ function Write-Log { [string]$level = "INFO" ) $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" - Write-Output "$timestamp [$level] $message" + if ($level -eq "ERR") { + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Red + write-host $message + }else{ + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Green + write-host $message + } } # install firewall-cmd top open ports apt update diff --git a/k3s-server.ps1 b/k3s-server.ps1 index 2471600..f184c01 100644 --- a/k3s-server.ps1 +++ b/k3s-server.ps1 @@ -24,9 +24,13 @@ function Write-Log { ) $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" if ($level -eq "ERR") { - Write-Err "$timestamp [$level] $message" + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Red + write-host $message }else{ - Write-Output "$timestamp [$level] $message" + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Green + write-host $message } } function Write-Err { diff --git a/k3s-worker.ps1 b/k3s-worker.ps1 index e453c32..fc6c641 100644 --- a/k3s-worker.ps1 +++ b/k3s-worker.ps1 @@ -15,9 +15,13 @@ function Write-Log { ) $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" if ($level -eq "ERR") { - Write-Error "$timestamp [$level] $message" + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Red + write-host $message }else{ - Write-Output "$timestamp [$level] $message" + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Green + write-host $message } } function Write-Err { @@ -49,13 +53,6 @@ if (-not $?) { Write-Err "Failed to join the k3s cluster: $_" exit 1 } -# verify the cluster -Write-Log "Verifying the cluster..." -kubectl get nodes -if (-not $?) { - Write-Err "Failed to verify the cluster: $_" - exit 1 -} # open firewall ports $command = "iex '& ([scriptblock]::Create((iwr $firewall_script)))'" diff --git a/mysql.ps1 b/mysql.ps1 index d608339..82c4c97 100644 --- a/mysql.ps1 +++ b/mysql.ps1 @@ -15,9 +15,13 @@ function Write-Log { ) $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" if ($level -eq "ERR") { - Write-Err "$timestamp [$level] $message" + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Red + write-host $message }else{ - Write-Output "$timestamp [$level] $message" + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Green + write-host $message } } function Write-Err { diff --git a/nerdctl.ps1 b/nerdctl.ps1 index 96ec66f..23b1e2a 100644 --- a/nerdctl.ps1 +++ b/nerdctl.ps1 @@ -3,8 +3,16 @@ function Write-Log { [string]$message, [string]$level = "INFO" ) - $timestamp = Get-Date -FoRemove-Itemat "yyyy-MM-dd HH:mm:ss" - Write-Output "$timestamp [$level] $message" + $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" + if ($level -eq "ERR") { + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Red + write-host $message + }else{ + Write-Host -NoNewline "$timestamp " + Write-Host -NoNewline "[$level] " -ForegroundColor Green + write-host $message + } } # sudo pwsh -Command "iex '& ([scriptblock]::Create((iwr https://raw.githubusercontent.com/abdullahfarook/kube/main/nerdctl.ps1)))'" # download and extract containerd