-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·137 lines (105 loc) · 4.06 KB
/
setup
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# this script installs RemoteGPIO v3.0 following SetupHelper rules (https://github.com/kwindrem/SetupHelper)
#
# this script will accept the following commands on the command line:
# setup install
# setup uninstall
packageLogFile="/var/log/RemoteGPIOv2/current"
#### following lines incorporate helper resources into this script
pkgDir=$( dirname $0 )
pkgName=$( basename $pkgDir )
pkgRoot=$( dirname $pkgDir )
if [ -e "$pkgDir/HelperResources/IncludeHelpers" ]; then
source "$pkgDir/HelperResources/IncludeHelpers"
elif [ -e "$pkgRoot/SetupHelper/HelperResources/IncludeHelpers" ]; then
source "$pkgRoot/SetupHelper/HelperResources/IncludeHelpers"
else
echo "$pkgName: helper files not found - can't continue" | tee -a "/data/log/SetupHelper"
exit 1
fi
#### end of lines to include helper resources
# GitHub account info - fill in as appropriate
# to include this package in SetupHelper automatic updates
packageGitHubUser="drtinaz"
packageGitHubBranch="main"
#### running manually and OK to proceed - prompt for input
if [ $scriptAction == 'NONE' ] ; then
echo
echo "The RemoteGPIOv2 is adding external Relays and Digital Inputs"
echo "with Dingtian IOT Relay devices either connected via TCP"
echo
standardActionPrompt
fi
#### here to do the actual work
if [ $scriptAction == 'INSTALL' ] ; then
logMessage "++ Installing RemoteGPIOv2"
##
## Prepare the devices in /data/RemoteGPIO/sys and conf folder
##############################################################
tar -xvf /data/RemoteGPIOv2/FileSets/VersionIndependent/sys.tar.gz -C /data/RemoteGPIOv2/
tar -xvf /data/RemoteGPIOv2/FileSets/VersionIndependent/bin.tar.gz -C /data/RemoteGPIOv2/
##
## For Large Image only with Node-Red support
#############################################
if [ $(dbus -y com.victronenergy.settings /Settings/System/ImageType GetValue) == 1 ]
then
if [ ! -f /usr/lib/node_modules/@victronenergy/node-red-contrib-victron/src/services/services.json.orig ]
then
cp /usr/lib/node_modules/@victronenergy/node-red-contrib-victron/src/services/services.json /usr/lib/node_modules/@victronenergy/node-red-contrib-victron/src/services/services.json.orig
fi
patch /usr/lib/node_modules/@victronenergy/node-red-contrib-victron/src/services/services.json /data/RemoteGPIOv2/FileSets/PatchSource/services.json.patch
fi
logMessage "++ $packageName installed"
fi
# #### uninstalling - check scriptAction again
# if an install step failed package needs to be removed
if [ $scriptAction == 'UNINSTALL' ] ; then
logMessage "++ Uninstalling RemoteGPIOv2"
##
## For Large Image only with Node-Red support
#############################################
if [ $(dbus -y com.victronenergy.settings /Settings/System/ImageType GetValue) == 1 ]
then
patch -R /usr/lib/node_modules/@victronenergy/node-red-contrib-victron/src/services/services.json /data/RemoteGPIOv2/FileSets/PatchSource/services.json.patch
fi
##
## Delete devices
#################
rm -f /dev/gpio/relay_3
rm -f /dev/gpio/relay_4
rm -f /dev/gpio/relay_5
rm -f /dev/gpio/relay_6
rm -f /dev/gpio/relay_7
rm -f /dev/gpio/relay_8
rm -f /dev/gpio/relay_9
rm -f /dev/gpio/relay_a
rm -f /dev/gpio/relay_b
rm -f /dev/gpio/relay_c
rm -f /dev/gpio/relay_d
rm -f /dev/gpio/relay_e
rm -f /dev/gpio/relay_f
rm -f /dev/gpio/relay_g
rm -f /dev/gpio/relay_h
rm -f /dev/gpio/relay_i
rm -f /dev/gpio/digital_input_5
rm -f /dev/gpio/digital_input_6
rm -f /dev/gpio/digital_input_7
rm -f /dev/gpio/digital_input_8
rm -f /dev/gpio/digital_input_9
rm -f /dev/gpio/digital_input_a
rm -f /dev/gpio/digital_input_b
rm -f /dev/gpio/digital_input_c
rm -f /dev/gpio/digital_input_d
rm -f /dev/gpio/digital_input_e
rm -f /dev/gpio/digital_input_f
rm -f /dev/gpio/digital_input_g
rm -f /dev/gpio/digital_input_h
rm -f /dev/gpio/digital_input_i
rm -f /dev/gpio/digital_input_j
rm -f /dev/gpio/digital_input_k
logMessage "++ $packageName uninstalled"
fi
svc -t /service/dbus-digitalinputs
logMessage "completed"
# thats all folks - SCRIPT EXITS INSIDE THE FUNCTION
endScript INSTALL_FILES ADD_DBUS_SETTINGS INSTALL_SERVICES