Skip to content

Commit d0a283b

Browse files
committed
Display 'Failed' if the IP or NTP configuration fails
1 parent 3989539 commit d0a283b

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.8.0 (2017-11-21)
4+
5+
* Display 'Failed' if the IP or NTP configuration fails
6+
37
## 1.7.0 (2017-11-21)
48

59
* [bugfix] Ensure NTP is configured after the interface is configured

module.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[de MODULE_INFO
22
("name" "tinycore-network")
3-
("version" "1.7.0")
3+
("version" "1.8.0")
44
("summary" "TinyCore static/dhcp networking")
55
("source" "https://a1w.ca")
66
("author" "Alexander Williams")

network.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# MIT License
66
# Copyright (c) 2015-2017 Alexander Williams, Unscramble <license@unscramble.jp>
77
#
8-
# VERSION: 1.7.0
8+
# VERSION: 1.8.0
99

1010
. /etc/init.d/tc-functions
1111
set -a
@@ -18,11 +18,22 @@ interface_tries=0
1818

1919
/sbin/udevadm settle --timeout=5
2020

21+
check_status() {
22+
if [ "$?" = 1 ]; then
23+
echo "${RED} Failed.${NORMAL}"
24+
else
25+
echo "${GREEN} Done.${NORMAL}"
26+
fi
27+
}
28+
2129
set_ntpdate() {
2230
if [ ${ntpserver-} ]; then
2331
ntp_tries=$(( $ntp_tries + $ntpretry ))
2432
if [ "$ntp_tries" -le "$ntptimeout" ]; then
33+
echo -n "."
2534
/usr/bin/timeout -t $ntpretry /usr/sbin/ntpd -d -n -q -p "$ntpserver" >>/var/log/ntp.log 2>&1 || set_ntpdate
35+
else
36+
return 1
2637
fi
2738
fi
2839
}
@@ -33,6 +44,8 @@ check_interface() {
3344
echo -n "."
3445
sleep 1
3546
/sbin/ifconfig $interface 2>&1 | grep HWaddr >/dev/null 2>&1 || check_interface
47+
else
48+
return 1
3649
fi
3750
}
3851

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

5669
case "$mode" in
5770
static)
@@ -67,7 +80,7 @@ if [ -f "$config" ]; then
6780
echo -n "${GREEN}Waiting up to ${MAGENTA}${ntptimeout}s${GREEN} for NTP from ${MAGENTA}$ntpserver${NORMAL}"
6881
echo "$ntpserver" > /etc/sysconfig/ntpserver
6982
set_ntpdate
70-
echo "${GREEN} Done.${NORMAL}"
83+
check_status
7184
else
7285
> /etc/sysconfig/ntpserver
7386
fi

0 commit comments

Comments
 (0)