Skip to content

Commit 5be7bcc

Browse files
committed
A bunch of fixes for timesave.
- Apply shellcheck issues - Make timesave working properly on RPi images
1 parent 5f0d027 commit 5be7bcc

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $(OPENWRT_CONFIG_FOLDER):
6969
sed 's:DROOPY_USE_USER="yes":DROOPY_USE_USER="no":' -i $@/piratebox.conf
7070
sed 's:DROOPY_CHMOD:#DROOPY_CHMOD:' -i $@/piratebox.conf
7171
sed 's:LEASE_FILE_LOCATION=$$PIRATEBOX_FOLDER/tmp/lease.file:LEASE_FILE_LOCATION=/tmp/lease.file:' -i $@/piratebox.conf
72-
sed 's:TIMESAVE_FORMAT="":TIMESAVE_FORMAT="+%C%g%m%d%H%M":' -i $@/piratebox.conf
72+
sed 's:TIMESAVE_FORMAT="+%C%g%m%d %H%M":TIMESAVE_FORMAT="+%C%g%m%d%H%M":' -i $@/piratebox.conf
7373
sed 's:FIREWALL_FETCH_DNS="yes":FIREWALL_FETCH_DNS="no":' -i $@/firewall.conf
7474
sed 's:FIREWALL_FETCH_HTTP="yes":FIREWALL_FETCH_HTTP="no":' -i $@/firewall.conf
7575

piratebox/piratebox/bin/timesave.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ get_datetime() {
1919

2020
# Strip spaces from datetime
2121
sanitize_datetime() {
22-
echo $1 | sed s/" "/""/g
22+
echo "$1" | sed s/" "/""/g
2323
}
2424

2525
# Print usage if parameters are not provided
26-
if [ -z $1 ] || [ -z $2 ] ; then
26+
if [ -z "$1" ] || [ -z "$2" ] ; then
2727
echo "Set up a crontab entry for regulary saving the time"
2828
echo "Usage $0 <path to piratebox.conf> <step>"
2929
echo " Valid steps are:"
@@ -35,7 +35,7 @@ if [ -z $1 ] || [ -z $2 ] ; then
3535
fi
3636

3737
# Load configfile
38-
. $1
38+
. "$1"
3939

4040
if [ "$2" = "install" ] ; then
4141
crontab -l > $PIRATEBOX_FOLDER/tmp/crontab 2> /dev/null
@@ -44,9 +44,9 @@ if [ "$2" = "install" ] ; then
4444
crontab $PIRATEBOX_FOLDER/tmp/crontab
4545

4646
echo "initialize timesave file"
47-
touch $TIMESAVE
48-
chmod a+rw $TIMESAVE
49-
get_datetime > $TIMESAVE
47+
touch "$TIMESAVE"
48+
chmod a+rw "$TIMESAVE"
49+
get_datetime > "$TIMESAVE"
5050

5151
echo "Remember MAY have to cron active..."
5252
echo " on OpenWrt run: /etc/init.d/piratebox enable"
@@ -56,14 +56,14 @@ fi
5656

5757
# Save current date-time in a recoverable format
5858
if [ "$2" = "save" ] ; then
59-
if [ -e $TIMESAVE ] ; then
59+
if [ -e "$TIMESAVE" ] ; then
6060
if [ $(sanitize_datetime "$(get_datetime)") -lt $(sanitize_datetime "$(cat $TIMESAVE)") ] ; then
6161
logger -s "$0: Current date-time is lower then saved one. Not saving!"
6262
exit 1
6363
fi
6464
fi
6565

66-
get_datetime > $TIMESAVE
66+
get_datetime > "$TIMESAVE"
6767
exit 0
6868
fi
6969

piratebox/piratebox/conf/piratebox.conf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,8 @@ NODE_CONFIG="$PIRATEBOX_FOLDER/conf/node.conf"
116116
## Timesave file for non-RTC devices
117117
TIMESAVE="$PIRATEBOX_FOLDER/share/timesave_file"
118118

119-
#On non OpenWRT you can use the default output format
120-
# as an input format. For OpenWrt you need to specify +%C%g%m%d%H%M
121-
# The content is exchanged during makefile processing and image build
122-
TIMESAVE_FORMAT=""
119+
## Format for storing & recovering the date&time
120+
TIMESAVE_FORMAT="+%C%g%m%d %H%M"
123121

124122
#Start droopy? - Enable upload?
125123
DROOPY_ENABLED="yes"

0 commit comments

Comments
 (0)