-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp_fhem
99 lines (91 loc) · 2.9 KB
/
wp_fhem
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh
# Copyright (c) 2016 Wolfram Plettscher
# All rights reserved
#
# Author: Wolfram Plettscher, 06.2016
#
# /etc/init.d/wp_fhem
#
### BEGIN INIT INFO
# Provides: wp_fhem
# Required-Start:
# Required-Stop:
#### Should-Start: wp_tinkerforge
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: starts FHEM house automation server
# Description: during start it also reconfigures /dev/ttyACM0 (/dev/ttyUSBx) to rwrwrw rights
# (hardcoded tty for busware CUL device / Watteco V6 Border Router)
# Last maintained for SuSE 11.4, 12.1, 12.3
#
# Installation:
# - copy this file to /etc/init.d
# - be sure, fileformat is unix: "set fileformat=unix"
# - chmod 744 /etc/init.d/wp_fhem
# - ln -s /etc/init.d/wp_fhem /sbin/wp_fhem
# - enable and edit in YAST system services
### END INIT INFO
case "$1" in
start)
echo "Start $0"
# chmod 666 /dev/ttyUSB0
# chmod 666 /dev/ttyUSB1
### CUL only works with /dev/ttyS8 or /dev/ttyUSB2
### due to a bug in OS
# ln -s /dev/ttyACM0 /dev/ttyS8
# ln -s /dev/ttyACM0 /dev/ttyUSB2
# chmod 777 /dev/ttyACM0
# chmod 777 /dev/ttyS8
# chmod 777 /dev/ttyUSB2
### Watteco V6 support
# /usr/bin/pkill tunslip6
# /usr/bin/tunslip6 aaaa::1/72 -s /dev/ttyUSB0 &
### prepare to start fhem
cp /usr/share/fhem/fhem_*.cfg /opt/fhem
cp /usr/share/fhem/gplot/*.gplot /opt/fhem/www/gplot
cp /usr/share/fhem/modules/*.pm /opt/fhem/FHEM
cp /usr/share/fhem/Floorplan/fhem_images/*.png /opt/fhem/www/images/default
cp /usr/share/fhem/Floorplan/woplfloorplanstyle.css /opt/fhem/www/pgm2
/opt/fhem/fhem.pl /opt/fhem/fhem_main.cfg
sleep 5
### start Tinkerforge IO16 (after Tinkerforge service is running)
# cd /home/wopl/FHEM_IO16
# /home/wopl/FHEM_IO16/tf_fenster &
/usr/share/fhem/cfg/tinkerforge/tf_fenster &
;;
stop)
echo "Stop $0"
/usr/share/fhem/fhem.pl 7072 shutdown
/usr/bin/pkill tf_fenster
# /usr/bin/pkill tunslip6
;;
restart)
echo "Restart $0"
/usr/share/fhem/fhem.pl 7072 shutdown
/usr/bin/pkill tf_fenster
# /usr/bin/pkill tunslip6
### now do restart everything
# /usr/bin/tunslip6 aaaa::1/72 -s /dev/ttyUSB0 &
cp /usr/share/fhem/cfg/fhem_*.cfg /etc/fhem
cp /usr/share/fhem/cfg/gplot/*.gplot /usr/share/fhem/www/gplot
cp /usr/share/fhem/cfg/modules/*.pm /usr/share/fhem/FHEM
cp /usr/share/fhem/cfg/Floorplan/fhem_images/*.png /usr/share/fhem/www/images/default
/usr/share/fhem/fhem.pl /etc/fhem/fhem_main.cfg
sleep 5
# cd /home/wopl/FHEM_IO16
# /home/wopl/FHEM_IO16/tf_fenster &
/usr/share/fhem/cfg/tinkerforge/tf_fenster &
;;
status)
cnt=`ps -ef | grep "fhem.pl" | grep -v grep | wc -l`
if [ "$cnt" -eq "0" ] ; then
echo "$0 is not running"
else
echo "$0 is running"
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0