Добавлена обработка подпроцессов.
[weathermon.git] / init.d / weathermon
index cb1822acb70932ed615cdf9075d01b0cb2d9638a..8553b6ac39c7919111a4a32ac1c4f101d9cd3757 100755 (executable)
@@ -18,30 +18,35 @@ start_service() {
 
        mkdir -p "$WORK_DIR"
 
 
        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
 
        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
         procd_set_param command "$PROG"
         procd_set_param nice "$NICEPRIO"
        fi
 
         procd_open_instance
         procd_set_param command "$PROG"
         procd_set_param nice "$NICEPRIO"
-        procd_set_param respawn ${respawn_threshold:-600} ${respawn_timeout:-5} ${respawn_retry:-5}
+        procd_set_param respawn
         procd_close_instance
 }
 
 stop_service() {
         procd_close_instance
 }
 
 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
 }
 }