Skip to content

Commit

Permalink
fixed: menu items not being hidden added all logs to Settings backup …
Browse files Browse the repository at this point in the history
…added optional Venus OS firmware update to blindUninstall
  • Loading branch information
kwindrem committed Jan 23, 2023
1 parent 53d87cc commit 87274c4
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 98 deletions.
2 changes: 1 addition & 1 deletion FileSets/PageSettingsPackageAdd.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ MbPage {
editStatus.setValue ( "adding " + packageName)
editActionItem.setValue ('add:' + packageName)
}
model: VisualItemModel
model: VisibleItemModel
{
MbEditBox
{
Expand Down
4 changes: 2 additions & 2 deletions FileSets/PageSettingsPackageEdit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ MbPage {
requestedAction = ''
}

model: VisualItemModel
model: VisibleItemModel
{
MbEditBox
{
Expand Down Expand Up @@ -310,7 +310,7 @@ MbPage {
{
id: downloadButton
width: 110
anchors { right: installButton.left; top: statusMessage.bottom; topMargin: 5 }
anchors { left: nextButton.right; top: statusMessage.bottom; topMargin: 5 }
description: ""
value: qsTr ("Download")
onClicked: gitHubDownload ()
Expand Down
2 changes: 1 addition & 1 deletion FileSets/PageSettingsPackageManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MbPage {
property bool showMediaStatus: mediaStatus.valid && mediaStatus.value != ""
property bool showControls: installStatus.valid

model: VisualItemModel
model: VisibleItemModel
{
MbItemText
{
Expand Down
2 changes: 1 addition & 1 deletion FileSets/PageSettingsPmBackup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MbPage {
VBusItem { id: backupProgressItem; bind: Utils.path(servicePrefix, "/BackupProgress") }
property int backupProgress: backupProgressItem.valid ? backupProgressItem.value : 0

model: VisualItemModel
model: VisibleItemModel
{
MbItemText
{
Expand Down
2 changes: 1 addition & 1 deletion FileSets/PageSettingsPmInitialize.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MbPage {
showInProgress = true
}

model: VisualItemModel
model: VisibleItemModel
{
MbItemText
{
Expand Down
31 changes: 14 additions & 17 deletions PackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2931,29 +2931,26 @@ def settingsBackup (self, backupPath):
logging.error ("settings backup - logo write failure")

# copy log files
logCount = 0
logsWritten = "no logs"
try:
# remove any previous log backups
logDestDir = backupPath + "/logs"
if os.path.isdir (logDestDir):
shutil.rmtree (logDestDir)
if not os.path.isdir (logDestDir):
os.mkdir (logDestDir)

logFile = "/data/log/SetupHelper"
if os.path.exists ( logFile ):
shutil.copy ( logFile, logDestDir )
logCount += 1
logFile = "/data/log/PackageManager"
if os.path.exists ( logFile ):
shutil.copytree ( logFile, logDestDir + "/PackageManager" )
logCount += 1
logFile = "/data/log/gui"
if os.path.exists ( logFile ):
shutil.copytree ( logFile, logDestDir + "/gui" )
logCount += 1

proc = subprocess.Popen ( [ 'zip', '-rq', backupPath + "/logs.zip", "/data/log" ],
stdout=subprocess.PIPE, stderr=subprocess.PIPE )
proc.wait()
stdout, stderr = proc.communicate ()
# convert from binary to string
stdout = stdout.decode ().strip ()
stderr = stderr.decode ().strip ()
returnCode = proc.returncode
logsWritten = "logs"
except:
logging.error ("settings backup - log write failure")
logsWritten = "no logs"



# backup setup script options
Expand All @@ -2971,7 +2968,7 @@ def settingsBackup (self, backupPath):
logging.error ("settings backup - overlays write failure")

logging.warning ("settings backup completed - " + str(settingsCount) + " settings, " + str (overlayCount) + " logos, "
+ str (logCount) + " logs")
+ logsWritten )


def settingsRestore (self, backupPath):
Expand Down
78 changes: 52 additions & 26 deletions ReadMe
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
New: SetupHelper includes a GUI based package manager

The SetupHelper package provides:
a mechanism to automatically reinstall packages following a Venus OS update
an automatic update mechanism to keep packages up to date
Expand All @@ -10,13 +8,16 @@ The SetupHelper package provides:

a "blind" install of SetupHelper from SD/USB media

a blind uninstall mechanism which optionally includes reinstalling Venus OS

backup and restore SOME settings from com.victronenergy.settings
this includes custom logos and copying logs to removable media
SetupHelper
PackageManager
gui

SetupHelper is also required for my other packages
SetupHelper is also required for other packages
SetupHelper includes utilities used by these packages
and must be installed BEFORE running the other package setup scripts

Blind Install:
Expand Down Expand Up @@ -79,52 +80,65 @@ CAUTION:
will continue to function.


ssh access:

Setting up ssh access with ssh keys is highly recommended for any system,
but especially when installing third party extensions to Venus OS.
Attaching a serial terminal for direct console access is another option,
especially if you don't have a network setup.

The following document describes ssh access and also serial terminal connections on Cerbo GX:
https://www.victronenergy.com/live/ccgx:root_access


System Recovery:

It is highly unlikely, but some users have reported a package install leaving their system unresponsive
or with a nonfuncitonal GUI (white screen). In this case, your options depend on the platform and the current state of the system.
or with a nonfuncitonal GUI (white screen). In this case, your options depend on the current state of the system.

First, (as always) reboot
Second, see if you can access the PackageManager menu. If so, you can remove pacakges one at a time from there.
First, (as always) reboot. This may clear the problem.

Second, if you have a functioning GUI (eitehr locally or via remote console, see if you can access the PackageManager menu.
If so, you can remove pacakges one at a time from there.
If you find an offeding package, post an issue to the GitHub repo for that package and include:
Platform (Cerbo, CCGX, Raspberry PI, etc)
Venus OS firmware version
attach logs if you can get to them
Run a Settings backup and post the logs.zip file on the removble media.
Remove SetupHelper last since once you do, you loose the PackageManager menus!

Third, if you have terminal or ssh access, try running the package setup scripts to uninstall packages one at a time.

Fourth, if you have GUI access again, try booting to the previous Venus OS version (in Stored backup formware)
Fourth, try booting to the previous Venus OS version (in Stored backup firmware)
Then perform a fresh Online firmware update to the latest version or use the .swu update via removable media.
These procedures are documented: https://www.victronenergy.com/media/pg/Cerbo_GX/en/gx---how-to-update-firmware.html

Fifth, perform the Blind uninstall procedure below.
Use the Settings / Firmware / Stored backup formware menu if you have GUI access.

Sixth, perform the Victron "restore factory default" procedure:
https://www.victronenergy.com/media/pg/CCGX/en/factory-reset.html
If you don't have GUI access, you can also switch to the backup version from the command line:
/opt/victronenergy/swupdate-scripts/set-version.sh 2

Note: this will wipe out all settings and you'll need to reconfigure the GX device from scratch.
Fifth, perform the Blind uninstall procedure below.

Finally, if you are running on a Raspberry PI, you can reimage the system SD card.

Note: this will wipe out all settings and you'll need to reconfigure the GX device from scratch.

The Victron "restore factory default" procedure can be used to will wipe out all settings.
You'll need to reconfigure the GX device from scratch.
However, it will NOT replace the operating system and Victron application, nor will it uninstall any packages.
You will most likely be locked out of ssh access since log-in information and ssh keys
are stored in the /data partition which is completey erased by this procedure.
For this reason, I do not recommend using this as part of your attempt to recover a system with no GUI.


Blind UNINSTALL:

A blind uninstall mechanism is also provided which is similar to blind install described above.
This can be used in extremely rare ases where a package install leaves the system unaccessible
via GUI or ssh.
This mechanism is a LAST RESORT.
This will run all package setup scripts to uninstall that package from system files,
then remove the package from /data and /data/rcS.local.
A blind uninstall mechanism is provided to recover a system with an unresponsive GUI (white screen)
or no ssh/terminal access.
This will run all package setup scripts to uninstall that package from system files.

CAUTION: Do NOT run the Victron restore to factory defaults script if you have an unresponsive system
after installing one of my packages. Doing so will remove the script that restores the file system
to their factory settings.

Firmware reinstall requires access to the GUI so if you still don't have a working GUI after
the Victron restore to factory defaults, then you are pretty much out of luck.
In addition to uninstalling all packages, the blind uninstall can optionally reinstall VenusOS.
To do so, include a .swu file for the platform and desired firmware version on the removable media containing
the blind uninstall venus-data.tar.gz file.

The archive for this is named venus-data.UninstallPackages.tar.gz.

Expand All @@ -133,7 +147,18 @@ The archive for this is named venus-data.UninstallPackages.tar.gz.
3) Plug the removable media into the GX device
4) Reboot, wait 2 minutes and reboot a second time
5) when the system automatically reboots after the second manual one, remove the media
You should eventually see the GUI on the local display if there is one
or be able to connect via remote console.

Cauton: Removing media or power cycling the GX device during the uninstall,
especially if reinstalling firmware could render the system unresponsive!
Wait to see the GUI before removing media or power cycling.

Note that a firmware update can take several minutes to complete but will eventually reboot.

When the blind uninstall finishes, venus-data-tar.gz file on the removable media
is renamed to venus-data.UninstallPackages.tar.gz so that the blind install will run only once.
This renaming is necessary to prevent a loop where the system uninstalls and reboots.

Description:

Expand Down Expand Up @@ -224,6 +249,7 @@ The Package Manager includes a set of menus on the GX device menu system
Vrmlogger
Any logo files in /data/themes/overlay
Setup script options in /data/setupOptions
All logs stored in /data/log are written to logs.zip on the removable media
The parameters must exist to be saved
The parameters will be created and set to the backed up value during a restore

Expand All @@ -235,7 +261,7 @@ The Package Manager includes a set of menus on the GX device menu system
SETTINGS_AUTO_RESTORE is detected in the root of removable media

CAUTION: LEAVING THIS FLASH DRIVE IN THE SYSTEM WILL TRIGGER A SETTINGS RESTORE WITH EVERY BOOT
YOU MUST REMOVE THE FLASH DRIVE AFTER AUTO RESTORR
YOU MUST REMOVE THE FLASH DRIVE AFTER AUTO RESTORE

microSD / USB:
is a duplicate of the menu item in VRM online portal
Expand Down
2 changes: 1 addition & 1 deletion blindInstall/SetupHelperVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v4.32
v4.33
125 changes: 79 additions & 46 deletions blindInstall/rcS.localForUninstall
Original file line number Diff line number Diff line change
@@ -1,50 +1,83 @@
#!/bin/bash

# this script is part of a "blind UNINSTALL" archive which
# UNINSTALLS AND REMOVES packages

packageDir=/data/SetupHelper
script="$packageDir/setup"
if [ -e $script ]; then
$script uninstall
rm -r $packageDir

packageDir=/data/GuiMods
script="$packageDir/setup"
if [ -e $script ]; then
$script uninstall
rm -r $packageDir

packageDir=/data/GeneratorConnector
script="$packageDir/setup"
if [ -e $script ]; then
$script uninstall deferReboot deferGuiRestart auto
rm -r $packageDir

packageDir=/data/RpiDisplaySetup
script="$packageDir/setup"
if [ -e $script ]; then
$script uninstall deferReboot deferGuiRestart auto
rm -r $packageDir

packageDir=/data/RpiGpioSetup
script="$packageDir/setup"
if [ -e $script ]; then
$script uninstall deferReboot deferGuiRestart auto
rm -r $packageDir

packageDir=/data/ShutDownMonitor
script="$packageDir/setup"
if [ -e $script ]; then
$script uninstall deferReboot deferGuiRestart auto
rm -r $packageDir

packageDir=/data/VeCanSetup
script="$packageDir/setup"
if [ -e $script ]; then
$script uninstall deferReboot deferGuiRestart auto
rm -r $packageDir
# this script is part of a "blind UNINSTALL" archive which UNINSTALLS all packages
# Packages are not removed but marked so PackageManager does not auto intall later
#
# Venus OS will also be reinstalled if a suitable .swu file is found on removable media

rm -f /data/rcS.local
# log activity
logMessage ()
{
echo "blindUninstall: $*"
echo "blindUninstall: $*" | tai64n >> "/data/log/SetupHelper"
}

logMessage "--- starting"

# check to see if Venus OS will be reinstalled - actuall reinstall will be done later
swCheckOutput=$(/opt/victronenergy/swupdate-scripts/check-updates.sh -offline -force -check)
if (( $? == 0 )); then
reinstallVenusOs=true
swUpdateVersion=$(echo $swCheckOutput | awk '{print $NF}')
else
reinstallVenusOs=false
swUpdateVersion="none"
fi

packages=$(ls -d /data/*)
for package in $packages; do
if [ ! -f "$package/version" ]; then
continue
fi
packageName=$(basename $package)
# if not reinstalling Venus OS, uninstall package
if ! $reinstallVenusOs ; then
if [ -f /etc/venus/installedVersion-$packageName ]; then
logMessage "uninstalling $packageName"
"$package/setup" uninstall deferReboot deferGuiRestart auto
fi
fi
# make sure PackageManager does not auto install package
if [ ! -f "$package/DO_NOT_AUTO_INSTALL" ]; then
logMessage "preventing future $packageName auto install"
touch "$package/DO_NOT_AUTO_INSTALL"
fi
done

# insure no packages are reinstalled after boot
if [ -f "/data/reinstallScriptsList" ]; then
logMessage "removing reinstallScriptsList"
rm -f "/data/reinstallScriptsList"
fi

reboot
# remove all installed flags
ls /etc/venus/installed* &> /dev/null
if (( $? == 0 )); then
logMessage "removing installedVersion file for all packages"
rm -f /etc/venus/installedVersion*
fi

# reinstall Venus OS - done in background so this script can clean up and exit without disrupting the software update
if $reinstallVenusOs ; then
logMessage "reinstalling Venus OS $swUpdateVersion"
nohup sh -c 'sleep 1; /opt/victronenergy/swupdate-scripts/check-updates.sh -offline -force -update' > /dev/null &
# reboot if not reinstalling Venus OS
else
logMessage "rebooting ..."
nohup sh -c 'sleep 1; reboot' > /dev/null &
fi

# rename archive on removable media to prevent blindInstall from running again
drives=$(ls /run/media/)
for drive in $drives ; do
archive="/run/media/$drive/venus-data.tar.gz"
if [ -f "$archive" ]; then
logMessage "renaming venus-data.tar.gz so blindUninstall won't run again"
mv $archive "/run/media/$drive/venus-data.UninstallPackages.tar.gz"
fi
done

logMessage "--- ending"

# don't run this script again !
rm -f /data/rcS.local
5 changes: 5 additions & 0 deletions changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v4.32:
fixed: menu items not being hidden
added all logs to Settings backup
added optional Venus OS firmware update to blindUninstall

v4.31:
fixed: PackageManager edit menus not working

Expand Down
Binary file modified service/.DS_Store
Binary file not shown.
Loading

0 comments on commit 87274c4

Please sign in to comment.