forked from kwindrem/SetupHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·207 lines (185 loc) · 8.1 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
# this script sets up the SetupHelper service and other resources associated with package updates
# This service provides automatic and manual updates for Venus modificaiton packages
#
#### following lines incorporate SetupHelper utilities into this script
# Refer to the SetupHelper ReadMe file for details.
source "/data/SetupHelper/CommonResources"
#### end of lines to include SetupHelper
# remove settings no longer used
cleanupDbusSettings ()
{
dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/GitHubAutoUpdate\
com.victronenergy.BusItem.GetValue &> /dev/null
if (( $? == 0 )); then
removeDbusSettings "/Settings/GuiMods/PackageVersions/GeneratorConnector" "/Settings/GuiMods/PackageVersions/GuiMods"\
"/Settings/GuiMods/PackageVersions/GuiMods" "/Settings/GuiMods/PackageVersions/RpiDisplaySetup"\
"/Settings/GuiMods/PackageVersions/RpiGpioSetup" "/Settings/GuiMods/PackageVersions/RpiTemp"\
"/Settings/GuiMods/PackageVersions/SetupHelper" "/Settings/GuiMods/PackageVersions/TankRepeater",\
"/Settings/GuiMods/PackageVersions/VeCanSetup" "/Settings/GuiMods/PackageVersions/ShutdownMonitor"\
"/Settings/GuiMods/CheckingPackage" "/Settings/GuiMods/GitHubAutoUpdate"
fi
}
#### running manually and OK to proceed - prompt for input
if [ $scriptAction == 'NONE' ] ; then
# create dbus Settings if they haven't been set previously
# if one setting exists, assume they are all there
# NOTE: if new settings are added in the future, change test for that one
# to avoid creating that new parameter !!!!
# display initial message
echo
echo "This package provides support functions and utilities for Venus modification packages"
echo "Packages are automatically reinstalled following a Venus OS update"
echo "Packages may also be automatically updated from GitHub"
echo " or a USB stick"
echo "Previously uninstalled packages can also be installed and configured"
echo " as an option from the menu either from GitHub or from a USB stick"
echo
echo "If internet access is not available, you can manually update/install from a USB stick or SD card"
echo
if [ -f "$setupOptionsDir/optionsSet" ]; then
enableReinstall=true
else
enableReinstall=false
fi
response=''
fullPrompt=true
while true; do
if $fullPrompt ; then
echo
echo "Available actions:"
echo " Install and activate (i)"
if $enableReinstall ; then
echo " Reinstall (r) based on options provided at last install"
fi
echo " Uninstall (u) and restores all files to stock"
echo " Quit (q) without further action"
echo " Display setup log (s) outputs the last 100 lines of the log"
echo
echo " Enable/disable automatic GitHub package updates (g)"
echo " Manually install packages from GitHub or USB stick (p)"
echo
fullPrompt=false
fi
/bin/echo -n "Choose an action from the list above: "
read response
case $response in
[iI]*)
scriptAction='INSTALL'
break;;
[rR]*)
if $enableReinstall ; then
scriptAction='INSTALL'
break
fi
;;
[uU]*)
scriptAction='UNINSTALL'
break
;;
[qQ]*)
exit
;;
[sS]*)
displayLog $setupLogFile
;;
[gG]*)
autoUpdate=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings\
/Settings/PackageVersion/GitHubAutoUpdate\
com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}')
case $autoUpdate in
1)
echo "Automatic GitHub updates are at normal rate"
;;
2)
echo "Automatic GitHub updates are at fast rate"
;;
3)
echo "Automatic GitHub updates will occur only once"
;;
*)
echo "Automatic GitHub updates are currently disabled"
;;
esac
echo "Available modes:"
echo " Normal (n) - one package is checked once every 10 minutes"
echo " Fast (f) - one package is checked once every 10 seconds"
echo " Once (o) - each package is checked once then auto updates are turned off"
echo " Disable (d) - auto updates are disabled"
read -p "Choose a mode from the above list: (cr for no change): " response
if [ ! -z $response ]; then
case $response in
[nN]* | [eE]*)
setSetting 1 /Settings/PackageVersion/GitHubAutoUpdate
;;
[fF]*)
setSetting 2 /Settings/PackageVersion/GitHubAutoUpdate
;;
[oO]*)
setSetting 3 /Settings/PackageVersion/GitHubAutoUpdate
;;
[dD]*)
setSetting 0 /Settings/PackageVersion/GitHubAutoUpdate
;;
*)
esac
fi
;;
[pP]*)
"$scriptDir/packageInstaller"
fullPrompt=true
;;
*)
esac
done
fi
if [ $scriptAction == 'INSTALL' ] ; then
if [ ! -f "$packageListFile" ]; then
logMessage "installing default packge list"
cp "$scriptDir/defaultPackageList" "$packageListFile"
fi
# check both parameters to insure they are both created
dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/PackageVersion/CheckingPackage\
com.victronenergy.BusItem.GetValue &> /dev/null
if (( $? != 0 )); then
settingsInstalled=false
# first setting exists, check the second
else
dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/PackageVersion/GitHubAutoUpdate\
com.victronenergy.BusItem.GetValue &> /dev/null
if (( $? != 0 )); then
settingsInstalled=false
else
settingsInstalled=true
fi
fi
if ! $settingsInstalled ; then
logMessage "creating SetupHelper Settings"
dbus -y com.victronenergy.settings /Settings AddSettings\
'%[ {"path": "/PackageVersion/GitHubAutoUpdate", "default":0},\
{"path": "/PackageVersion/CheckingPackage", "default":""},]' > /dev/null
# relocate options and current values
moveSetting "$setupOptionsDir/autoGitHubUpdate" "/Settings/GuiMods/GitHubAutoUpdate" "/Settings/PackageVersion/GitHubAutoUpdate"
rm -f "$setupOptionsDir/autoGitHubUpdate"
moveSetting "" "/Settings/GuiMods/CheckingPackage" "/Settings/PackageVersion/CheckingPackage"
fi
updateActiveFile "$qmlDir/PageSettings.qml"
updateActiveFile "$qmlDir/PageSettingsPackageControl.qml"
updateActiveFile "$qmlDir/PageSettingsPackageVersions.qml"
updateActiveFile "$qmlDir/MbDisplayPackageVersion.qml"
installService $packageName
cleanupDbusSettings
fi
if [ $scriptAction == 'UNINSTALL' ] ; then
restoreActiveFile "$qmlDir/PageSettings.qml"
restoreActiveFile "$qmlDir/PageSettingsPackageControl.qml"
restoreActiveFile "$qmlDir/PageSettingsPackageVersions.qml"
restoreActiveFile "$qmlDir/MbDisplayPackageVersion.qml"
removeService $packageName
cleanupDbusSettings
fi
if $filesUpdated ; then
restartGui=true
fi
# thats all folks - SCRIPT EXITS INSIDE THE FUNCTION
endScript