X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/0a2693126165f68131a1d1686a2bee1f1967494d..d563aba7f65b64c452a6e69af6dc92354422bec6:/init.d/weathermon?ds=sidebyside diff --git a/init.d/weathermon b/init.d/weathermon index 802529e..8553b6a 100755 --- a/init.d/weathermon +++ b/init.d/weathermon @@ -18,14 +18,26 @@ start_service() { mkdir -p "$WORK_DIR" - if [ ! -z "$BACKLOGDB" ] && [ ! -f "$BACKLOGDB" ]; then - BACKLOG_BASE=$(basename "$BACKLOGDB") - cp "$BACKUP_DIR/$BACKLOG_BASE" "$BACKLOGDB" + if [ ! -z "$BACKLOGDB" ]; then + + sqlite3 $BACKLOGDB "select * from queue limit 1" > /dev/null + + if [ "$?" != "0" ]; then + BACKLOG_BASE=$(basename "$BACKLOGDB") + cp "$BACKUP_DIR/$BACKLOG_BASE" "$BACKLOGDB" + fi + fi - if [ ! -z "$LOGDB" ] && [ ! -f "$LOGDB" ]; then - LOG_BASE=$(basename "$LOGDB") - cp "$BACKUP_DIR/$LOG_BASE" "$LOGDB" + if [ ! -z "$LOGDB" ]; then + + sqlite3 $LOGDB "select * from log limit 1" > /dev/null + + if [ "$?" != "0" ]; then + LOG_BASE=$(basename "$LOGDB") + cp "$BACKUP_DIR/$LOG_BASE" "$LOGDB" + fi + fi procd_open_instance @@ -36,12 +48,5 @@ start_service() { } stop_service() { - killall weathermon - killall weathermon-iio - if [ ! -z "$BACKLOGDB" ] && [ -f "$BACKLOGDB" ]; then - cp "$BACKLOGDB" "$BACKUP_DIR"/ - fi - if [ ! -z "$LOGDB" ] && [ -f "$BACKLOGDB" ]; then - cp "$LOGDB" "$BACKUP_DIR"/ - fi + /usr/bin/weather-backup }