tizen 2.3.1 release
[framework/system/dlog.git] / scripts / dlogctrl
1 #!/bin/sh
2
3 MODE=none
4 OBJ=none
5 VAL=none
6 CONFIG_PATH="/opt/etc"
7
8 function Usage()
9 {
10         /bin/echo "Usage: dlogctrl {get|set} {platformlog | loglimiter } {on|off}"
11         exit 1
12 }
13
14 case "$1" in
15 get)
16         MODE=get
17 ;;
18 set)
19         MODE=set
20 ;;
21 *)
22         Usage
23 esac
24
25 case "$2" in
26 platformlog)
27         OBJ=PlatformLogs
28 ;;
29 loglimiter)
30         OBJ=LogLimiter
31 ;;
32 *)
33         Usage
34 esac
35
36 if [ "$MODE" = "set" ]; then
37         case "$3" in
38         1|on)
39                 VAL=on
40         ;;
41         0|off)
42                 VAL=off
43         ;;
44         *)
45                 Usage
46         esac
47
48         echo "Setting $OBJ=$VAL"
49         /bin/sed "s/$OBJ[\t ]*[onf]*/$OBJ $VAL/" < "$CONFIG_PATH/dlog.conf" > /tmp/dlog.conf.new
50         /bin/cp /tmp/dlog.conf.new "$CONFIG_PATH/dlog.conf"
51         /bin/sync
52         echo "You must reboot this target to apply the change!"
53 else
54         case "$(grep "$OBJ" "$CONFIG_PATH/dlog.conf" | awk '{ print $2 }')" in
55         on)
56                 /bin/echo "1"
57         ;;
58         off)
59                 /bin/echo "0"
60         ;;
61         esac
62 fi
63
64 exit 0