mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-08-05 17:07:49 +00:00
keep waitonnetwork service damn simple
- an exit status is not needed here. we do not care if network is not up in the specified interval. it is up to the user to tune it - VERBOSE is not used.
This commit is contained in:
parent
cc0ab040ea
commit
d21cafecef
@ -9,8 +9,9 @@ ConditionPathExists=/storage/.cache/openelec/network_wait
|
||||
Type=oneshot
|
||||
EnvironmentFile=/storage/.cache/openelec/network_wait
|
||||
ExecStartPre=/bin/sh -c 'echo "waiting on Network to come online ... (max. $WAIT_NETWORK_TIME sec.)"
|
||||
ExecStart=/usr/bin/cm-online --timeout=${WAIT_NETWORK_TIME}
|
||||
ExecStart=/usr/bin/cm-online ${WAIT_NETWORK_TIME}
|
||||
StandardOutput=tty
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=xbmc.service
|
||||
|
@ -20,40 +20,14 @@
|
||||
################################################################################
|
||||
|
||||
# Wait for the network to come up and exit after timeout or if network is online
|
||||
#
|
||||
# Usage:
|
||||
# cm-online [--timeout=n] [--verbose]
|
||||
# --timeout : timeout in sec. (default 30)
|
||||
# --verbose : print status on exit
|
||||
#
|
||||
# Exit status:
|
||||
# (0) Network online
|
||||
# (1) Network not online
|
||||
|
||||
TIMEOUT=30
|
||||
|
||||
for arg in $@; do
|
||||
case $arg in
|
||||
--timeout=*)
|
||||
TIMEOUT="${arg#*=}"
|
||||
;;
|
||||
--verbose)
|
||||
VERBOSE=yes
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# default 30sec
|
||||
[ ! -z $1 ] && TIMEOUT=$1 || TIMEOUT=30
|
||||
|
||||
LOOP_COUNT=$((TIMEOUT * 4))
|
||||
|
||||
for i in $(seq 1 $LOOP_COUNT) ; do
|
||||
STATUS=$(ifconfig | sed -e '/inet addr:/!d' -e '/127.0.0.1/d' |wc -l)
|
||||
if [ "$STATUS" -gt 0 ]; then
|
||||
[ "$VERBOSE" = yes ] && echo "Network is online"
|
||||
exit 0
|
||||
fi
|
||||
[ "$STATUS" -gt 0 ] && break
|
||||
usleep 250000
|
||||
done
|
||||
|
||||
[ "$VERBOSE" = yes ] && echo "Network is down"
|
||||
|
||||
exit 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user