- Добавлен процесс для чтения iio-датчиков
[weathermon.git] / init.d / weathermon
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2007-2014 OpenWrt.org
3
4 START=93
5 STOP=45
6
7 USE_PROCD=1
8
9 PROG=/usr/bin/weathermon
10 NICEPRIO=-1
11
12 BACKUP_DIR=`uci get weathermon.process.backup_dir`
13 BACKLOGDB=`uci get weathermon.process.backlogdb` 
14 LOGDB=`uci get weathermon.process.logdb` 
15 WORK_DIR=`uci get weathermon.process.working_dir`
16
17 start_service() {
18
19         mkdir -p "$WORK_DIR"
20
21         if [ ! -z "$BACKLOGDB" ] && [ ! -f "$BACKLOGDB" ]; then
22                 BACKLOG_BASE=$(basename "$BACKLOGDB")
23                 cp "$BACKUP_DIR/$BACKLOG_BASE" "$BACKLOGDB"
24         fi
25
26         if [ ! -z "$LOGDB" ] && [ ! -f "$LOGDB" ]; then
27                 LOG_BASE=$(basename "$LOGDB")
28                 cp "$BACKUP_DIR/$LOG_BASE" "$LOGDB"
29         fi
30
31         procd_open_instance
32         procd_set_param command "$PROG"
33         procd_set_param nice "$NICEPRIO"
34         procd_set_param respawn ${respawn_threshold:-600} ${respawn_timeout:-5} ${respawn_retry:-5}
35         procd_close_instance
36 }
37
38 stop_service() {
39         killall weathermon
40         killall weathermon-iio
41         if [ ! -z "$BACKLOGDB" ] && [ -f "$BACKLOGDB" ]; then
42                 cp "$BACKLOGDB" "$BACKUP_DIR"/
43         fi
44         if [ ! -z "$LOGDB" ] && [ -f "$BACKLOGDB" ]; then
45                 cp "$LOGDB" "$BACKUP_DIR"/
46         fi
47 }