summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/get-eeprom-device-config/init
blob: 0ba5075dd0e7c9475cdab528568987eab2c65f1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/bash

### BEGIN INIT INFO
# Provides:        eeprom-config
# Required-Start:  mts-io
# Default-Start:   2 3 4 5
# Default-Stop:
# Short-Description: Create /run/config with eeprom configuration
### END INIT INFO

GETCONFIG=/sbin/get-eeprom-device-config
JASONFILE=/run/config/device_info.json

case "$1" in
  start)
        if ! [[ -f /run/config/device_info.json ]] ; then
		[[ -d /run/config ]] || mkdir -m 755 -p /run/config
		if [[ -x ${GETCONFIG} ]] ; then
                       	${GETCONFIG} -t1  # Radio might not be found yet.
		fi
	fi
	;;
  stop)
	;;
  force-reload)
  	rm -rf /run/config/*
        ${GETCONFIG}
	;;
  restart)
        ${GETCONFIG}
	;;
  reload)
        ${GETCONFIG}
	;;
  status)         
        if [[ -f ${JASONFILE} ]] ; then
                echo EEPROM Config is populated
                exit 0                  
        else                       
                echo EEPROM Config is not populated
                exit 3                                     
        fi                                                                                                 
        ;;                            
  *)
	echo "Usage: ntpd { start | stop | status | restart | reload | force-reload }" >&2
	exit 1
	;;
esac

exit 0