Message ID | 1453365593-4098-1-git-send-email-ynezz@true.cz |
---|---|
State | Superseded |
Headers | show |
* Petr Štetiar <ynezz@true.cz> [21.01.2016 12:22]: > boot() { > + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV && exit 0 thank you! can you please do in this line a: && return and introduce a helper (maybe overengineered 8-) deps_ok() { [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] } bye, bastian
On 21/01/2016 12:53, Bastian Bittorf wrote: > * Petr Štetiar <ynezz@true.cz> [21.01.2016 12:22]: >> boot() { >> + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV && exit 0 > > thank you! can you please do in this line a: > && return > > and introduce a helper (maybe overengineered 8-) > > deps_ok() { > [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] > } > > bye, bastian hang on there, this looks like bastel basti scriptowahn
* John Crispin <blogic@openwrt.org> [21.01.2016 13:30]:
> hang on there, this looks like bastel basti scriptowahn
8-) but the 'exit VS. return' is valid...
bye, bastian
Bastian Bittorf <bittorf@bluebottle.com> [2016-01-21 12:53:48]: > * Petr Štetiar <ynezz@true.cz> [21.01.2016 12:22]: > > boot() { > > + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV && exit 0 > > thank you! can you please do in this line a: > && return Like following? deps_ok && $HWCLOCK -s -f $RTC_DEV && exit 0 && return Is it really needed? I've always thought, that exit will terminate the script so the return wouldn't be called anyway. > and introduce a helper (maybe overengineered 8-) Kind of, was thinking about it also so I'll change it, thanks. > deps_ok() { > [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] > } -- ynezz
On 26/01/2016 21:35, Petr Štetiar wrote: > Bastian Bittorf <bittorf@bluebottle.com> [2016-01-21 12:53:48]: > >> * Petr Štetiar <ynezz@true.cz> [21.01.2016 12:22]: >>> boot() { >>> + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV && exit 0 >> >> thank you! can you please do in this line a: >> && return > > Like following? > > deps_ok && $HWCLOCK -s -f $RTC_DEV && exit 0 && return > > Is it really needed? I've always thought, that exit will terminate the script > so the return wouldn't be called anyway. > >> and introduce a helper (maybe overengineered 8-) > > Kind of, was thinking about it also so I'll change it, thanks. > >> deps_ok() { >> [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] >> } > > -- ynezz please don't add a helper. instead just call start from boot, honour its return code and then decide if you want to run the exising code. John > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel >
* Petr Štetiar <ynezz@true.cz> [28.01.2016 11:06]: > Like following? > > deps_ok && $HWCLOCK -s -f $RTC_DEV && exit 0 && return just: deps_ok && $HWCLOCK -s -f $RTC_DEV && return bye, bastian
diff --git a/package/base-files/files/etc/init.d/sysfixtime b/package/base-files/files/etc/init.d/sysfixtime index 4010e06..83e9ee4 100755 --- a/package/base-files/files/etc/init.d/sysfixtime +++ b/package/base-files/files/etc/init.d/sysfixtime @@ -2,10 +2,25 @@ # Copyright (C) 2013-2014 OpenWrt.org START=00 +STOP=90 + +RTC_DEV=/dev/rtc0 +HWCLOCK=/sbin/hwclock boot() { + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV && exit 0 + local curtime="$(date +%s)" local maxtime="$(find /etc -type f -exec date -r {} +%s \; | sort -nr | head -n1)" [ $curtime -lt $maxtime ] && date -s @$maxtime } +start() { + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV +} + +stop() { + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && \ + $HWCLOCK -w -f $RTC_DEV && \ + logger -t sysfixtime "saved '$(date)' to $RTC_DEV" +}