-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsetup
executable file
·135 lines (113 loc) · 5.73 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
#!/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
cleanup ()
{
# cleanup from older versions
restoreActiveFile "$qmlDir/PageSettingsPackageControl.qml"
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 > /dev/null
removeDbusSettings /Settings/PackageVersion/Count /Settings/PackageVersion/New/GitHubUser \
/Settings/PackageVersion/New/GitHubBranch /Settings/PackageVersion/New/InstalledVersion \
/Settings/PackageVersion/New/PackageName /Settings/PackageVersion/New/PackageVersion \
/Settings/PackageVersion/GitHubAutoUpdate /Settings/PackageVersion/EditAction \
/Settings/PackageVersion/CheckingPackage > /dev/null
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 "All actions are controlled via /Settings/PackageMonitor in the GUI"
echo " Packages may be automatically updated from GitHub or a USB stick"
echo " Previously uninstalled packages can also be downloaded an installed"
echo
standardActionPrompt
fi
if [ $scriptAction == 'INSTALL' ] ; then
# modify PageSettings here so SetupHelper is independent of Venus OS verison
if [ -f "$qmlDir/PageSettings.qml.orig" ]; then
origFile="$qmlDir/PageSettings.qml.orig"
else
origFile="$qmlDir/PageSettings.qml"
fi
if (( $(grep -c "PackageManager" $origFile) > 0)); then
logMessage "ERROR: PageSettings.qml already modified for PackageManager -- skipping that modification"
else
rm -f "/var/volatile/tmp/PageSettings.qml"
echo "//////// modified to insert PackageManager menu" > "/var/volatile/tmp/PageSettings.qml"
# find line with second to last }
insertBefore=$(awk '{print NR " " $s}' "$origFile" | grep '}' | tail -2 | head -n 1 | awk '{print $1}')
((insertBefore -= 1))
# include all lines before that one
head -n $insertBefore $origFile >> "/var/volatile/tmp/PageSettings.qml"
# file with PackageManager menu code includes the last two }
cat "$pkgFileSets/PackageManagerMenu.txt" >> "/var/volatile/tmp/PageSettings.qml"
updateActiveFile "/var/volatile/tmp/PageSettings.qml" "$qmlDir/PageSettings.qml"
rm -f "/var/volatile/tmp/PageSettings.qml"
fi
updateActiveFile "$qmlDir/PageSettingsPackageManager.qml"
updateActiveFile "$qmlDir/PageSettingsPackageVersions.qml"
updateActiveFile "$qmlDir/PageSettingsPackageEdit.qml"
updateActiveFile "$qmlDir/MbDisplayPackageVersion.qml"
updateActiveFile "$qmlDir/PageSettingsAddPackageList.qml"
updateActiveFile "$qmlDir/PageSettingsPackageAdd.qml"
updateActiveFile "$qmlDir/MbDisplayDefaultPackage.qml"
updateActiveFile "$qmlDir/PageSettingsPmBackup.qml"
updateActiveFile "$qmlDir/PageSettingsPmInitialize.qml"
# revert to VisualItemModel if before v3.00~14 (v3,00~14 uses VisibleItemModel)
versionStringToNumber "v3.00~14"
if (( $venusVersionNumber < $versionNumber )); then
logMessage "replacing VisibleItemModel with VisualItemModel"
fileList="$qmlDir/PageSettingsPackageManager.qml"
fileList+=" $qmlDir/PageSettingsPackageVersions.qml"
fileList+=" $qmlDir/PageSettingsPackageEdit.qml"
fileList+=" $qmlDir/PageSettingsAddPackageList.qml"
fileList+=" $qmlDir/PageSettingsPackageAdd.qml"
fileList+=" $qmlDir/PageSettingsPmBackup.qml"
fileList+=" $qmlDir/PageSettingsPmInitialize.qml"
for file in $fileList ; do
sed -i -e 's/VisibleItemModel/VisualItemModel/' "$file"
done
fi
installService PackageManager
cleanup
fi
if [ $scriptAction == 'UNINSTALL' ] ; then
restoreActiveFile "$qmlDir/PageSettings.qml"
restoreActiveFile "$qmlDir/PageSettingsPackageManager.qml"
restoreActiveFile "$qmlDir/PageSettingsPackageVersions.qml"
restoreActiveFile "$qmlDir/PageSettingsPackageEdit.qml"
restoreActiveFile "$qmlDir/MbDisplayPackageVersion.qml"
restoreActiveFile "$qmlDir/PageSettingsAddPackageList.qml"
restoreActiveFile "$qmlDir/PageSettingsPackageAdd.qml"
restoreActiveFile "$qmlDir/MbDisplayDefaultPackage.qml"
restoreActiveFile "$qmlDir/PageSettingsPmBackup.qml"
restoreActiveFile "$qmlDir/PageSettingsPmInitialize.qml"
removeService PackageManager
cleanup
fi
if $filesUpdated ; then
restartGui=true
fi
# thats all folks - SCRIPT EXITS INSIDE THE FUNCTION
endScript