]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
util: health-check - Made bash script compatible with dash shell
authorSimon Rupf <simon@rupf.net>
Sat, 23 Jan 2021 10:07:36 +0000 (11:07 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 12 Feb 2021 09:50:31 +0000 (09:50 +0000)
src/util/health-check.sh

index 119990fb422d9ca7c554b433b1050c40f4e7fcf3..add4928959cf079d75a404b04810ce3a1751c7c4 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 #
 # Copyright (c) 2019 Dovecot authors, see the included COPYING file */
 #
 
 TIMEOUT=10
 
-read -t ${TIMEOUT} -r input
+# prefer read with timeout (bash, busybox sh) or fall back to POSIX read (dash)
+read -t ${TIMEOUT} -r input 2>/dev/null || read -r input
 
 exit_code=$?
-cleaned_input=${input//[^a-zA-Z0-9]/}
+cleaned_input=$(echo $input | sed "s/[^a-zA-Z0-9]//g")
 
 if [ $exit_code -eq 0 ] && [ "$cleaned_input" = "PING" ];then
        echo "PONG"