Skip to content

Commit 2fbe766

Browse files
Merge pull request #1023 from yasinBursali/fix/shell-sigpipe-sweep-4scripts
fix(scripts): SIGPIPE-safe first-line selection in 5 scripts
2 parents e86d78c + 533ce08 commit 2fbe766

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

dream-server/installers/macos/dream-macos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ read_env_value() {
155155
local env_file="$1"
156156
local key="$2"
157157
[[ -f "$env_file" ]] || { echo ""; return 0; }
158-
grep -E "^${key}=" "$env_file" 2>/dev/null | head -n 1 | cut -d'=' -f2- | tr -d '\r' || true
158+
grep -E "^${key}=" "$env_file" 2>/dev/null | sed -n '1p' | cut -d'=' -f2- | tr -d '\r' || true
159159
}
160160

161161
upsert_env_value() {

dream-server/installers/macos/lib/env-generator.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ read_env_value() {
3636
local env_path="$1"
3737
local key="$2"
3838
[[ -f "$env_path" ]] || { echo ""; return 0; }
39-
grep -E "^${key}=" "$env_path" 2>/dev/null | head -n 1 | cut -d'=' -f2- | tr -d '\r' || true
39+
grep -E "^${key}=" "$env_path" 2>/dev/null | sed -n '1p' | cut -d'=' -f2- | tr -d '\r' || true
4040
}
4141

4242
# Read SearXNG secret_key from an existing settings.yml file.
@@ -48,7 +48,7 @@ read_searxng_secret() {
4848
[[ -f "$settings_path" ]] || { echo ""; return 0; }
4949
# Expected line format: secret_key: "...."
5050
grep -E '^[[:space:]]*secret_key:[[:space:]]*"' "$settings_path" 2>/dev/null \
51-
| head -n 1 \
51+
| sed -n '1p' \
5252
| sed -E 's/^[[:space:]]*secret_key:[[:space:]]*"([^"]+)".*$/\1/' \
5353
| tr -d '\r' || true
5454
}

dream-server/scripts/check-offline-models.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ MISSING=()
2424

2525
# Check LLM model (GGUF)
2626
if ls data/models/*.gguf &>/dev/null; then
27-
MODEL_FILE=$(ls -1 data/models/*.gguf | head -1)
27+
MODEL_FILE=$(ls -1 data/models/*.gguf | sed -n '1p')
2828
echo -e "${GREEN}${NC} LLM model: $(basename "$MODEL_FILE")"
2929
else
3030
echo -e "${RED}${NC} LLM model (GGUF) - MISSING"

dream-server/scripts/dream-preflight.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fi
8484
# Check GPU if available
8585
echo -n "GPU availability... "
8686
if docker exec "$LLM_CONTAINER" nvidia-smi >/dev/null 2>&1; then
87-
GPU_MEM=$(docker exec "$LLM_CONTAINER" nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits 2>/dev/null | head -1 | tr -d ' ')
87+
GPU_MEM=$(docker exec "$LLM_CONTAINER" nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits 2>/dev/null | sed -n '1p' | tr -d ' ')
8888
echo -e "${GREEN}✓ detected (${GPU_MEM}MB free)${NC}"
8989
else
9090
echo -e "${YELLOW}⚠ not detected (CPU mode)${NC}"

dream-server/scripts/pre-download.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ check_dependencies() {
109109

110110
detect_vram_gb() {
111111
if command -v nvidia-smi &>/dev/null; then
112-
nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits 2>/dev/null | head -1 | awk '{print int($1/1024)}'
112+
nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits 2>/dev/null | sed -n '1p' | awk '{print int($1/1024)}'
113113
else
114114
echo "0"
115115
fi

0 commit comments

Comments
 (0)