-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsetup
executable file
·158 lines (145 loc) · 5.92 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
#!/bin/bash
# this script sets up the SetupHelper service
# 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
#### 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 !!!!
lastSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiModsCheckingPackage\
com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}')
if [ -z $lastSetting ]; then
logMessage "creating SetupHelper Settings"
dbus -y com.victronenergy.settings /Settings AddSettings\
'%[ {"path": "/GuiMods/GitHubAutoUpdate", "default":0},\
{"path": "/GuiMods/CheckingPackage", "default":""},]' > /dev/null
# move setup option flag to dbus setting
if [ -f "$setupOptionsDir/autoGitHubUpdate" ]; then
setSetting 1 /Settings/GuiMods/GitHubAutoUpdate
rm -f "$setupOptionsDir/autoGitHubUpdate"
else
setSetting 0 /Settings/GuiMods/GitHubAutoUpdate
fi
fi
# display innitial message
echo
echo "This package provides support functions and utilities for Venus modificaiton 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 "Prevouslly 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"
echo "Note: installing from a USB stick disables automatic GitHub updates"
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/GuiMods/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/GuiMods/GitHubAutoUpdate
;;
[fF]*)
setSetting 2 /Settings/GuiMods/GitHubAutoUpdate
;;
[oO]*)
setSetting 3 /Settings/GuiMods/GitHubAutoUpdate
;;
[dD]*)
setSetting 0 /Settings/GuiMods/GitHubAutoUpdate
;;
*)
esac
fi
;;
[pP]*)
"$scriptDir/packageInstaller"
fullPrompt=true
;;
*)
esac
done
fi
if [ $scriptAction == 'INSTALL' ] ; then
installService $packageName
fi
if [ $scriptAction == 'UNINSTALL' ] ; then
removeService $packageName
fi
# thats all folks - SCRIPT EXITS INSIDE THE FUNCTION
endScript