Skip to content

Commit

Permalink
First 'service fakertc start' can do something reasonable.
Browse files Browse the repository at this point in the history
resolves #1

People tend to run 'service fakertc start' after installation.
This gave a warning about a non-existing file. Create the file
instead. Although this is not needed in the "algorithm" I think
this follows the POLA.
  • Loading branch information
ronaldklop committed Sep 8, 2022
1 parent 9159647 commit eee62ad
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/etc/rc.d/fakertc
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,25 @@ _fakertc_format="+%Y%m%d%H%M.%S"
fakertc_start()
{

echo -n "Set RTC from: ${fakertc_file}: "
if [ ! -s ${fakertc_file} ] ; then
fakertc_save
return 0
fi

echo -n "Set RTC from ${fakertc_file}: "

if [ ! -r ${fakertc_file} ] ; then
warn "${fakertc_file} is not readable"
return 1
fi

date -u $( cat "${fakertc_file}" )
_fakertc_date=$( date -u $( cat "${fakertc_file}" ) )
echo -n "${_fakertc_date}"

echo '.'
}

fakertc_stop()
fakertc_save()
{

echo -n "Writing RTC file: ${fakertc_file}"
Expand All @@ -51,5 +57,11 @@ fakertc_stop()
echo '.'
}

fakertc_stop()
{

fakertc_save
}

load_rc_config $name
run_rc_command "$1"

0 comments on commit eee62ad

Please sign in to comment.