-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup
More file actions
executable file
·152 lines (119 loc) · 4.71 KB
/
setup
File metadata and controls
executable file
·152 lines (119 loc) · 4.71 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/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/RemoteGPIO/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="Lucifer06"
packageGitHubBranch="main"
#### running manually and OK to proceed - prompt for input
if [ $scriptAction == 'NONE' ] ; then
echo
echo "The RemoteGPIO is adding external Relays and Digital Inputs"
echo "with Dingtian IOT Relay devices either connected via USB or TCP"
echo
standardActionPrompt
fi
#### here to do the actual work
if [ $scriptAction == 'INSTALL' ] ; then
logMessage "++ Installing RemoteGPIO"
##
## Prepare the devices in /data/RemoteGPIO/sys and conf folder
##############################################################
tar -xvf /data/RemoteGPIO/FileSets/VersionIndependent/sys.tar.gz -C /data/RemoteGPIO/
tar -xvf /data/RemoteGPIO/FileSets/VersionIndependent/bin.tar.gz -C /data/RemoteGPIO/
mkdir /data/RemoteGPIO/conf
chmod 777 /data/RemoteGPIO/conf
touch /data/RemoteGPIO/conf/relays.conf
chmod 666 /data/RemoteGPIO/conf/relays.conf
echo "0" > /data/RemoteGPIO/conf/relays.conf
##
## 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/RemoteGPIO/FileSets/PatchSource/services.json.patch
fi
##
## For supports of Cerbo GX MK2
###############################
patch /opt/victronenergy/dbus-digitalinputs/start-digitalinputs.sh /data/RemoteGPIO/FileSets/PatchSource/start-digitalinputs.sh.patch
##
## Add RemoteGPIO menus and remove the limit of 9 Digital Inputs
################################################################
#patch /opt/victronenergy/gui/qml/PageSettingsIo.qml /data/RemoteGPIO/FileSets/PatchSource/PageSettingsIo.qml.patch
logMessage "++ $packageName installed"
fi
# #### uninstalling - check scriptAction again
# if an install step failed package needs to be removed
if [ $scriptAction == 'UNINSTALL' ] ; then
logMessage "++ Uninstalling RemoteGPIO"
##
## 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/RemoteGPIO/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
rm -Rf /data/RemoteGPIO/conf
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