A bunch of fixes for timesave.

- Apply shellcheck issues
        - Make timesave working properly on RPi images
This commit is contained in:
Matthias Strubel 2018-02-27 21:38:43 +01:00
parent 5f0d027c26
commit 5be7bcc147
3 changed files with 11 additions and 13 deletions

View File

@ -69,7 +69,7 @@ $(OPENWRT_CONFIG_FOLDER):
sed 's:DROOPY_USE_USER="yes":DROOPY_USE_USER="no":' -i $@/piratebox.conf
sed 's:DROOPY_CHMOD:#DROOPY_CHMOD:' -i $@/piratebox.conf
sed 's:LEASE_FILE_LOCATION=$$PIRATEBOX_FOLDER/tmp/lease.file:LEASE_FILE_LOCATION=/tmp/lease.file:' -i $@/piratebox.conf
sed 's:TIMESAVE_FORMAT="":TIMESAVE_FORMAT="+%C%g%m%d%H%M":' -i $@/piratebox.conf
sed 's:TIMESAVE_FORMAT="+%C%g%m%d %H%M":TIMESAVE_FORMAT="+%C%g%m%d%H%M":' -i $@/piratebox.conf
sed 's:FIREWALL_FETCH_DNS="yes":FIREWALL_FETCH_DNS="no":' -i $@/firewall.conf
sed 's:FIREWALL_FETCH_HTTP="yes":FIREWALL_FETCH_HTTP="no":' -i $@/firewall.conf

View File

@ -19,11 +19,11 @@ get_datetime() {
# Strip spaces from datetime
sanitize_datetime() {
echo $1 | sed s/" "/""/g
echo "$1" | sed s/" "/""/g
}
# Print usage if parameters are not provided
if [ -z $1 ] || [ -z $2 ] ; then
if [ -z "$1" ] || [ -z "$2" ] ; then
echo "Set up a crontab entry for regulary saving the time"
echo "Usage $0 <path to piratebox.conf> <step>"
echo " Valid steps are:"
@ -35,7 +35,7 @@ if [ -z $1 ] || [ -z $2 ] ; then
fi
# Load configfile
. $1
. "$1"
if [ "$2" = "install" ] ; then
crontab -l > $PIRATEBOX_FOLDER/tmp/crontab 2> /dev/null
@ -44,9 +44,9 @@ if [ "$2" = "install" ] ; then
crontab $PIRATEBOX_FOLDER/tmp/crontab
echo "initialize timesave file"
touch $TIMESAVE
chmod a+rw $TIMESAVE
get_datetime > $TIMESAVE
touch "$TIMESAVE"
chmod a+rw "$TIMESAVE"
get_datetime > "$TIMESAVE"
echo "Remember MAY have to cron active..."
echo " on OpenWrt run: /etc/init.d/piratebox enable"
@ -56,14 +56,14 @@ fi
# Save current date-time in a recoverable format
if [ "$2" = "save" ] ; then
if [ -e $TIMESAVE ] ; then
if [ -e "$TIMESAVE" ] ; then
if [ $(sanitize_datetime "$(get_datetime)") -lt $(sanitize_datetime "$(cat $TIMESAVE)") ] ; then
logger -s "$0: Current date-time is lower then saved one. Not saving!"
exit 1
fi
fi
get_datetime > $TIMESAVE
get_datetime > "$TIMESAVE"
exit 0
fi

View File

@ -116,10 +116,8 @@ NODE_CONFIG="$PIRATEBOX_FOLDER/conf/node.conf"
## Timesave file for non-RTC devices
TIMESAVE="$PIRATEBOX_FOLDER/share/timesave_file"
#On non OpenWRT you can use the default output format
# as an input format. For OpenWrt you need to specify +%C%g%m%d%H%M
# The content is exchanged during makefile processing and image build
TIMESAVE_FORMAT=""
## Format for storing & recovering the date&time
TIMESAVE_FORMAT="+%C%g%m%d %H%M"
#Start droopy? - Enable upload?
DROOPY_ENABLED="yes"