Skip to content

Commit

Permalink
add automatic install/uninstall, PM initialize, blind uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindrem committed Jun 11, 2022
1 parent 3a25822 commit 7ace87a
Show file tree
Hide file tree
Showing 25 changed files with 1,064 additions and 165 deletions.
29 changes: 18 additions & 11 deletions CommonResources
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ endScript ()
if [ $scriptAction == 'INSTALL' ] ; then
# assume that if we get this far, any command line opitons have already been set
touch "$setupOptionsDir/optionsSet"

# clear flag preventing auto installs in PackageManager
if $userInteraction ; then
rm -f "$setupOptionsDir/DO_NOT_AUTO_INSTALL"
fi

# set up reinstallMods to run this script again after a VenusOS update
if [ ! -f "$reinstallScriptsList" ] || [ $(grep -c "$fullScriptName" "$reinstallScriptsList") == 0 ]; then
Expand Down Expand Up @@ -441,6 +446,10 @@ endScript ()
cp "$scriptDir/version" "$installedVersionFile"
fi
elif [ $scriptAction == 'UNINSTALL' ] ; then
# set flag preventing auto installs in PackageManager
if $userInteraction ; then
touch "$setupOptionsDir/DO_NOT_AUTO_INSTALL"
fi
# remove this script from reinstallScriptsList to prevent further calls during boot
if [ -f "$reinstallScriptsList" ] && [ ! $(grep -c "$fullScriptName" "$reinstallScriptsList") == 0 ]; then
logMessage removing "$shortScriptName" from $(basename "$reinstallScriptsList")
Expand Down Expand Up @@ -468,7 +477,7 @@ endScript ()
logMessage "platform not compatible - exiting"
exit $EXIT_INCOMPATIBLE_PLATFOM
elif $rebootNeeded ; then
if $logToConsole ; then
if $userInteraction ; then
yesNoPrompt "Reboot system now (y) or do it manually later (n): "
if $yesResponse ; then
echo "rebooting ..."
Expand All @@ -482,14 +491,14 @@ endScript ()
exit $EXIT_REBOOT
fi
elif $restartGui ; then
if $logToConsole ; then
if $userInteraction ; then
yesNoPrompt "Restart the GUI now (y) or issue a do it manually later (n): "
if $yesResponse ; then
echo "restarting GUI ..."
svc -t /service/gui
exit $EXIT_SUCCESS
else
echo "GUI must be restarted activate components"
echo "GUI must be restarted to activate components"
exit $EXIT_RESTART_GUI
fi
else
Expand Down Expand Up @@ -533,22 +542,19 @@ endScript ()
#
#
# logToConsole is set to true in the LogHandler script
# It is set to false here if the command line parameters suggest
# the setup script is being run without the aid of the command line interface
# in which case the user will not be prompted and apprporiate actions are taken automatically
# exit code returned by the setup script indicates additional actions that
# need to be taken by the caller (if any) or the reason the script could not be completed
# It is set to false here the 'auto' parameter is passed on the command line
# which indicates this script is NOT being run from the command line

# collect command line options
reinstall=false
force=false
deferReboot=false
deferGuiRestart=false
userInteraction=true
while [ $# -gt 0 ]; do
case $1 in
$reinstallParam)
reinstall=true
logToConsole=false
;;
"force")
force=true
Expand All @@ -561,11 +567,13 @@ while [ $# -gt 0 ]; do
;;
"install")
scriptAction='INSTALL'
logToConsole=false
;;
"uninstall")
scriptAction='UNINSTALL'
;;
"auto")
logToConsole=false
userInteraction=false
;;
*)
esac
Expand Down Expand Up @@ -642,7 +650,6 @@ if $reinstall ; then
else
exit $EXIT_SUCCESS
fi
logToConsole=false

# not running from reinstallMods
else
Expand Down
2 changes: 2 additions & 0 deletions DbusSettingsResources
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# need to make settings changes
# These functions check to see if the settings system is operational and defer
# the set/create/remove activity so the calling script may continue
#
# as of v2.90~3 changes to

source "/data/SetupHelper/EssentialResources"
source "/data/SetupHelper/LogHandler"
Expand Down
9 changes: 9 additions & 0 deletions FileSets/PageSettingsPackageManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ MbPage {
description: qsTr("Backup & restore settings")
subpage: Component { PageSettingsPmBackup {} }
show: showControls
}
MbMountState {
description: qsTr("microSD / USB")
}
MbSubMenu
{
description: qsTr("Initialize PackageManager ...")
subpage: Component { PageSettingsPmInitialize {} }
show: showControls
}
}
}
52 changes: 52 additions & 0 deletions FileSets/PageSettingsPmInitialize.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/////// new menu for PackageManager initialize

import QtQuick 1.1
import "utils.js" as Utils
import com.victron.velib 1.0

MbPage {
id: root
title: pmRunning ? qsTr("Intialize Package Manager") : qsTr ("Package manager not running")
property string settingsPrefix: "com.victronenergy.settings/Settings/PackageManager"
property bool pmRunning: installStatus.valid

property VBusItem editAction: VBusItem { bind: Utils.path(servicePrefix, "/GuiEditAction") }
VBusItem { id: installStatus; bind: Utils.path(servicePrefix, "/InstallStatus") }
property bool showInProgress: false

onPmRunningChanged: { showInProgress = false }

function sendInitialize ()
{
// provide local confirmation of action - takes PackageManager too long
editAction.setValue ("INITIALIZE")
showInProgress = true
}

model: VisualItemModel
{
MbItemText
{
id: info
text: qsTr ("Initializing PackageManager will reset persistent storage\nto an empty state\nGit Hub user and branch info is lost")
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
}
MbOK
{
description: qsTr("Initialize")
value: qsTr("Press to Initialize")
onClicked: sendInitialize ()
writeAccessLevel: User.AccessInstaller
visible: ! showInProgress
}
MbItemText
{
id: initializingMessage
text: qsTr ("... initializing and restarting")
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
visible: showInProgress
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7ace87a

Please sign in to comment.