Skip to content

Commit

Permalink
feat: rc.func review
Browse files Browse the repository at this point in the history
  • Loading branch information
toulousain79 committed Sep 22, 2024
1 parent 35f7d11 commit 7722669
Showing 1 changed file with 34 additions and 16 deletions.
50 changes: 34 additions & 16 deletions root/TEMPLATEs/init/rc.func.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,45 @@ start() {
*)
$PRECMD >/dev/null 2>&1
eval "$PREARGS $PROC $ARGS"
local RES=$?
;;
esac

COUNTER=0
LIMIT=20

while [[ -z $(pidof "$PROC") && $COUNTER -le "$LIMIT" ]]; do
sleep 1
COUNTER=$((COUNTER + 1))
done
case "$PROC" in
'ntpdate') ;;
*)
COUNTER=0
LIMIT=20
while [[ -z $(pidof "$PROC") && $COUNTER -le "$LIMIT" ]]; do
sleep 1
COUNTER=$((COUNTER + 1))
done
;;
esac
$POSTCMD >/dev/null 2>&1

if [[ -z $(pidof "$PROC") ]]; then
echo -e "$ansi_red failed. $ansi_std"
logger "Failed to start $DESC from $CALLER."
return 255
else
echo -e "$ansi_green done. $ansi_std"
logger "Started $DESC from $CALLER."
return 0
fi
case "$PROC" in
'ntpdate')
if [[ ${RES} -ne 0 ]]; then
echo -e "$ansi_red failed. $ansi_std"
return 255
else
echo -e "$ansi_green done. $ansi_std"
return 0
fi
;;
*)
if [[ -z $(pidof "$PROC") ]]; then
echo -e "$ansi_red failed. $ansi_std"
logger "Failed to start $DESC from $CALLER."
return 255
else
echo -e "$ansi_green done. $ansi_std"
logger "Started $DESC from $CALLER."
return 0
fi
;;
esac
}

stop() {
Expand Down

0 comments on commit 7722669

Please sign in to comment.