Skip to content

Commit ff7f1f0

Browse files
committed
edit launcher script for linux EOL compatibility
1 parent 5d008ef commit ff7f1f0

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

launcher.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,34 @@ function Get-RunningContainers {
5858
return $null
5959
}
6060

61+
function Convert-ShellScriptsToLF {
62+
Write-Host "Converting shell scripts to Unix line endings (LF)..." -ForegroundColor $InfoColor
63+
64+
$shFiles = Get-ChildItem -Path "." -Recurse -Name "*.sh" -File
65+
$convertedCount = 0
66+
67+
foreach ($file in $shFiles) {
68+
try {
69+
$content = Get-Content -Path $file -Raw
70+
if ($content -and $content.Contains("`r`n")) {
71+
$content = $content -replace "`r`n", "`n"
72+
[System.IO.File]::WriteAllText((Resolve-Path $file).Path, $content)
73+
Write-Host " Converted: $file" -ForegroundColor $GrayColor
74+
$convertedCount++
75+
}
76+
}
77+
catch {
78+
Write-Host " Warning: Failed to convert $file - $($_.Exception.Message)" -ForegroundColor $WarningColor
79+
}
80+
}
81+
82+
if ($convertedCount -gt 0) {
83+
Write-Host "Converted $convertedCount shell script(s) to Unix line endings." -ForegroundColor $SuccessColor
84+
} else {
85+
Write-Host "No shell scripts needed line ending conversion." -ForegroundColor $SuccessColor
86+
}
87+
}
88+
6189
if ($Help) {
6290
Show-Help
6391
exit 0
@@ -75,6 +103,8 @@ switch ($Command.ToLower()) {
75103
exit 1
76104
}
77105

106+
Convert-ShellScriptsToLF
107+
78108
$RunningContainers = Get-RunningContainers
79109

80110
if ($RunningContainers) {
@@ -121,6 +151,8 @@ switch ($Command.ToLower()) {
121151
exit 1
122152
}
123153

154+
Convert-ShellScriptsToLF
155+
124156
Write-Host "Building and starting the Docker stack..." -ForegroundColor $InfoColor
125157
Invoke-Expression "docker compose up -d --build --force-recreate"
126158

launcher.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ get_running_containers() {
6969
docker compose ps -q 2>/dev/null
7070
}
7171

72+
convert_shell_scripts_to_lf() {
73+
echo -e "${INFO_COLOR}Converting shell scripts to Unix line endings (LF)...${RESET_COLOR}"
74+
75+
local converted_count=0
76+
77+
while IFS= read -r -d '' file; do
78+
if [ -f "$file" ]; then
79+
if grep -q $'\r' "$file" 2>/dev/null; then
80+
if sed -i 's/\r$//' "$file" 2>/dev/null; then
81+
echo -e " ${GRAY_COLOR}Converted: $file${RESET_COLOR}"
82+
converted_count=$((converted_count + 1))
83+
else
84+
echo -e " ${WARNING_COLOR}Warning: Failed to convert $file${RESET_COLOR}"
85+
fi
86+
fi
87+
fi
88+
done < <(find . -name "*.sh" -type f -print0 2>/dev/null)
89+
90+
if [ $converted_count -gt 0 ]; then
91+
echo -e "${SUCCESS_COLOR}Converted $converted_count shell script(s) to Unix line endings.${RESET_COLOR}"
92+
else
93+
echo -e "${SUCCESS_COLOR}No shell scripts needed line ending conversion.${RESET_COLOR}"
94+
fi
95+
}
96+
7297
start_sentinel_kit() {
7398
echo ""
7499
echo -e "${HEADER_COLOR}========== STARTING SENTINELKIT ==========${RESET_COLOR}"
@@ -77,6 +102,8 @@ start_sentinel_kit() {
77102
exit 1
78103
fi
79104

105+
convert_shell_scripts_to_lf
106+
80107
echo "--------------------------------------------------------"
81108
local running_containers
82109
running_containers=$(get_running_containers)
@@ -143,6 +170,8 @@ build_sentinel_kit() {
143170
exit 1
144171
fi
145172

173+
convert_shell_scripts_to_lf
174+
146175
echo "--------------------------------------------------------"
147176
local running_containers
148177
running_containers=$(get_running_containers)

0 commit comments

Comments
 (0)