Skip to content

Commit

Permalink
Display 'Failed' if the IP or NTP configuration fails
Browse files Browse the repository at this point in the history
  • Loading branch information
aw committed Nov 21, 2017
1 parent 3989539 commit d0a283b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.8.0 (2017-11-21)

* Display 'Failed' if the IP or NTP configuration fails

## 1.7.0 (2017-11-21)

* [bugfix] Ensure NTP is configured after the interface is configured
Expand Down
2 changes: 1 addition & 1 deletion module.l
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[de MODULE_INFO
("name" "tinycore-network")
("version" "1.7.0")
("version" "1.8.0")
("summary" "TinyCore static/dhcp networking")
("source" "https://a1w.ca")
("author" "Alexander Williams")
Expand Down
19 changes: 16 additions & 3 deletions network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# MIT License
# Copyright (c) 2015-2017 Alexander Williams, Unscramble <license@unscramble.jp>
#
# VERSION: 1.7.0
# VERSION: 1.8.0

. /etc/init.d/tc-functions
set -a
Expand All @@ -18,11 +18,22 @@ interface_tries=0

/sbin/udevadm settle --timeout=5

check_status() {
if [ "$?" = 1 ]; then
echo "${RED} Failed.${NORMAL}"
else
echo "${GREEN} Done.${NORMAL}"
fi
}

set_ntpdate() {
if [ ${ntpserver-} ]; then
ntp_tries=$(( $ntp_tries + $ntpretry ))
if [ "$ntp_tries" -le "$ntptimeout" ]; then
echo -n "."
/usr/bin/timeout -t $ntpretry /usr/sbin/ntpd -d -n -q -p "$ntpserver" >>/var/log/ntp.log 2>&1 || set_ntpdate
else
return 1
fi
fi
}
Expand All @@ -33,6 +44,8 @@ check_interface() {
echo -n "."
sleep 1
/sbin/ifconfig $interface 2>&1 | grep HWaddr >/dev/null 2>&1 || check_interface
else
return 1
fi
}

Expand All @@ -51,7 +64,7 @@ if [ -f "$config" ]; then
/sbin/ifconfig $interface up
# ensure the interface is actually up
check_interface
echo "${GREEN} Done.${NORMAL}"
check_status

case "$mode" in
static)
Expand All @@ -67,7 +80,7 @@ if [ -f "$config" ]; then
echo -n "${GREEN}Waiting up to ${MAGENTA}${ntptimeout}s${GREEN} for NTP from ${MAGENTA}$ntpserver${NORMAL}"
echo "$ntpserver" > /etc/sysconfig/ntpserver
set_ntpdate
echo "${GREEN} Done.${NORMAL}"
check_status
else
> /etc/sysconfig/ntpserver
fi
Expand Down

0 comments on commit d0a283b

Please sign in to comment.