diff --git a/HelperResources/CommonResources b/HelperResources/CommonResources index e0497ea..6caca66 100755 --- a/HelperResources/CommonResources +++ b/HelperResources/CommonResources @@ -51,13 +51,6 @@ fileListAll=() ######## skip to bottom of file for remainder of code executed when script is sourced -installFailed=false -installExitReason=$EXIT_ERROR -installFailMessage="" -installPreChecks=true -installFailCount=0 -uninstallFailed=false - # cleanup on any exit exitCleanup () { @@ -67,77 +60,6 @@ exitCleanup () trap exitCleanup EXIT - -# setInstallFailed sets flags to prevent further install steps -# and insure the package is uninstalled completely -# -# $1 indicates the reason for the failure and will evenutally be uused -# report the failure reason when exiting the script -# -# any remaining paremeters are passed to logMessage -# and also saved in installFailMessage for others to use -# the message is also sent to stderr if not running from the command line -# this allows PackageManager to report the full reason for failure -# -# a setup script can be run from the console, or from another script or program (unattended) -# when running from the console -# setInstallFailed will report errors and return to the caller -# -# if running unattended and if the script action is INSTALL -# during the precheck period (before any system modification) -# setInstallFailed WILL EXIT WITHOUT RETURNING TO THE CALLER !!!!! -# after the precheck period, system modifications may have been made so -# the scriptAction is changed to UNINSTALL so the modifictions can be reversed -# otherwise, setInstallFailed just logs the error -# -# note that PackageManager makes most of the pre-check tests -# before calling the setup script -# the only exception is file set checks made in checkFileSets -# -# installFailed is set here so that additional install operations will not be performed - - -setInstallFailed () -{ - (( installFailCount += 1 )) - if [ ! -z "$1" ]; then - installExitReason=$1 - # no reson specified - use the generaic error exit code - else - installExitReason=EXIT_ERROR - fi - message="${@:2}" - if [ ! -z "$message" ]; then - installFailMessage="$message" - logMessage "ERROR: $message" - # if not running from console, output error to stderr - if ! $logToConsole ; then - echo "$message" >&2 - fi - else - installFailMessage="" - fi - - if [ $scriptAction == 'UNINSTALL' ]; then - uninstallFailed=true - else - installFailed=true - fi - if ! $userInteraction && [ $scriptAction == 'INSTALL' ]; then - # during "pre-checks" failures occur before any system mofifications - # EXIT NOW - DO NOT RETURN TO THE CALLER !!!!! - if $installPreChecks ; then - exit $installExitReason - # after "pre-checks" system mofifications may already have occured - # so an uninstall needs to follow the install - else - scriptAction='UNINSTALL' - fi - fi -} - - - # checkPackageDependencies checks the packageDependencies file in the package directory # # all unmet dependencies are reported to the command line/log @@ -356,7 +278,7 @@ standardActionPrompt () exit $EXIT_SUCCESS ;; [lL]*) - displayLog $setupLogFile + tail -100 "$logFile" | tai64nlocal ;; *) esac @@ -1347,14 +1269,6 @@ endScript () # cleanup from previous versions - reinstallScriptsList no loner used rm -f "/data/reinstallScriptsList" -# set global machine type -if [ -f /etc/venus/machine ]; then - machine=$(cat /etc/venus/machine) -else - machine="" - setInstallFailed $EXIT_INCOMPATIBLE_PLATFORM "can't determine Venus device type" -fi - # initialize version strings and numbers for future checks if [ -f "$installedVersionFile" ]; then installedVersion=$(cat "$installedVersionFile") @@ -1742,50 +1656,13 @@ if [ $scriptAction == 'CHECK' ]; then exit $EXIT_SUCCESS fi -# make sure rootfs is mounted R/W & and resized to allow space for replacement files -# arbitrary minimum size of 3 MB -if ! $installFailed; then - rootMinimumSize=3 - availableSpace=$(df -m / | tail -1 | awk '{print $4}') - - # remount read-write - if (( $(mount | grep ' / ' | grep -c 'rw') == 0 )); then - # only remount read-write for CCGX - if [ "$machine" == "ccgx" ]; then - if [ -f /opt/victronenergy/swupdate-scripts/remount-rw.sh ]; then - logMessage "remounting root read-write" - /opt/victronenergy/swupdate-scripts/remount-rw.sh - fi - # remount and resize for other platforms - elif [ -f /opt/victronenergy/swupdate-scripts/resize2fs.sh ]; then - /opt/victronenergy/swupdate-scripts/resize2fs.sh - availableSpace=$(df -m / | tail -1 | awk '{print $4}') - logMessage "remounting read-write root and resizing - $availableSpace MB now available" - fi - # check to see if remount was successful - if (( $(mount | grep ' / ' | grep -c 'rw') == 0 )); then - setInstallFailed $EXIT_ROOT_FULL "ERROR: unable to remount root read-write - can't continue" - fi - # root already read-write, attempt to resize if space is limited (CCGX can't resize) - elif (( $availableSpace < $rootMinimumSize )); then - if [ "$machine" == "ccgx" ]; then - logMessage "can't resize root on CCGX" - else - if [ -f /opt/victronenergy/swupdate-scripts/resize2fs.sh ]; then - /opt/victronenergy/swupdate-scripts/resize2fs.sh - availableSpace=$(df -m / | tail -1 | awk '{print $4}') - logMessage "resized root - $availableSpace MB now available" - fi - fi - fi -fi -if ! $installFailed; then - # make sure the root partition has space for the package - if (( $availableSpace < $rootMinimumSize )); then - setInstallFailed $EXIT_ROOT_FULL "no room for modified files on root ($availableSpace MB remaining) - can't continue" - fi -fi +# in the Victron images, the root FS is read-only and is a minimum size +# in order to install modificaitons, the root partition needs to be +# remounted read-write and resized to allow mods to be added +# updateRootToReadWrite calls remount-rw.sh or resize2fs.sh +# then check to make sure there is sufficient space before allowing installs +updateRootToReadWrite # done with pre checks # prior to this no system mofications have been made diff --git a/HelperResources/EssentialResources b/HelperResources/EssentialResources index 585790a..3c264b1 100755 --- a/HelperResources/EssentialResources +++ b/HelperResources/EssentialResources @@ -44,6 +44,42 @@ altOrigFileDir="$pkgFileSets/AlternateOriginals" servicesDir="$scriptDir/services" +# LogHandler functions and variables + +logDir="/var/log/PackageManager" +logFile="$logDir/current" +if ! [ "$logDir" ]; then + mkdir -P "$logDir" + touch "$logFile" +fi + +oldLogFile="/var/log/SetupHelper" +if [ -e "$oldLogFile" ]; then + if (( $( tail -5 "$oldLogFile" | grep -c "WARNING: this log file no longer used" ) == 0 )); then + echo "WARNING: this log file no longer used" >> "$oldLogFile" + echo " SetupHelper now logged to /var/log/PackageManager/current" >> "$oldLogFile" + fi +fi + +# enable logging to console +# scripts can disable logging by setting +# logToConsole to false AFTER sourcing EssentialResources +logToConsole=true + +# write a message to log file and console + +logMessage () +{ + # to console + if $logToConsole ; then + echo "$*" + fi + + # to setup helper log + echo "$shortScriptName: $*" | tai64n >> $logFile +} + + # rc local file that calls reinstallMods # rcS.local avoids conflicts with mods that blindly replace /data/rc.local rcLocal="/data/rcS.local" @@ -66,10 +102,6 @@ EXIT_PACKAGE_CONFLICT=246 EXIT_PATCH_ERROR=245 -# old variables - keep for compatibility -exitReboot=$EXIT_REBOOT -exitSuccess=$EXIT_SUCCESS - # directory that holds script's options # options were removed from the script directory so they are preserved when the package is reinstalled setupOptionsRoot="/data/setupOptions" @@ -81,3 +113,265 @@ packageListFile="/data/packageList" qmlDir=/opt/victronenergy/gui/qml +# setInstallFailed sets flags to prevent further install steps +# and insure the package is uninstalled completely +# +# $1 indicates the reason for the failure and will evenutally be uused +# report the failure reason when exiting the script +# +# any remaining paremeters are passed to logMessage +# and also saved in installFailMessage for others to use +# the message is also sent to stderr if not running from the command line +# this allows PackageManager to report the full reason for failure +# +# a setup script can be run from the console, or from another script or program (unattended) +# when running from the console +# setInstallFailed will report errors and return to the caller +# +# if running unattended and if the script action is INSTALL +# during the precheck period (before any system modification) +# setInstallFailed will EXIT WITHOUT RETURNING TO THE CALLER !!!!! +# after the precheck period, system modifications may have been made so +# the scriptAction is changed to UNINSTALL so the modifictions can be reversed +# otherwise, setInstallFailed just logs the error +# +# installFailed is set here so that additional install operations will not be performed + +installFailed=false +installExitReason=$EXIT_ERROR +installFailMessage="" +installPreChecks=true +installFailCount=0 +uninstallFailed=false + +setInstallFailed () +{ + (( installFailCount += 1 )) + if [ ! -z "$1" ]; then + installExitReason=$1 + # no reson specified - use the generaic error exit code + else + installExitReason=EXIT_ERROR + fi + message="${@:2}" + if [ ! -z "$message" ]; then + installFailMessage="$message" + logMessage "ERROR: $message" + # if not running from console, output error to stderr + if ! $logToConsole ; then + echo "$message" >&2 + fi + else + installFailMessage="" + fi + + if [ $scriptAction == 'UNINSTALL' ]; then + uninstallFailed=true + else + installFailed=true + fi + if ! $userInteraction && [ $scriptAction == 'INSTALL' ]; then + # during "pre-checks" failures occur before any system mofifications + # EXIT NOW - DO NOT RETURN TO THE CALLER !!!!! + if $installPreChecks ; then + exit $installExitReason + # after "pre-checks" system mofifications may already have occured + # so an uninstall needs to follow the install + else + scriptAction='UNINSTALL' + fi + fi +} + +# set global machine type +if [ -f /etc/venus/machine ]; then + machine=$(cat /etc/venus/machine) +else + machine="" + setInstallFailed $EXIT_INCOMPATIBLE_PLATFORM "can't determine Venus device type" +fi + +# make sure rootfs is mounted R/W & and resized to allow space for replacement files +# arbitrary minimum size of 3 MB +# this needs to be called before root fs mods are made. +# CommonResources calls this but if you source a subset of helper resources +# that script needs to find a place to call updateRootToRW + +updateRootToReadWrite () +{ + if ! $installFailed; then + rootMinimumSize=3 + availableSpace=$(df -m / | tail -1 | awk '{print $4}') + + # remount read-write + if (( $(mount | grep ' / ' | grep -c 'rw') == 0 )); then + # only remount read-write for CCGX + if [ "$machine" == "ccgx" ]; then + if [ -f /opt/victronenergy/swupdate-scripts/remount-rw.sh ]; then + logMessage "remounting root read-write" + /opt/victronenergy/swupdate-scripts/remount-rw.sh + fi + # remount and resize for other platforms + elif [ -f /opt/victronenergy/swupdate-scripts/resize2fs.sh ]; then + /opt/victronenergy/swupdate-scripts/resize2fs.sh + availableSpace=$(df -m / | tail -1 | awk '{print $4}') + logMessage "remounting read-write root and resizing - $availableSpace MB now available" + fi + # check to see if remount was successful + if (( $(mount | grep ' / ' | grep -c 'rw') == 0 )); then + setInstallFailed $EXIT_ROOT_FULL "ERROR: unable to remount root read-write - can't continue" + fi + # root already read-write, attempt to resize if space is limited (CCGX can't resize) + elif (( $availableSpace < $rootMinimumSize )); then + if [ "$machine" == "ccgx" ]; then + logMessage "can't resize root on CCGX" + else + if [ -f /opt/victronenergy/swupdate-scripts/resize2fs.sh ]; then + /opt/victronenergy/swupdate-scripts/resize2fs.sh + availableSpace=$(df -m / | tail -1 | awk '{print $4}') + logMessage "resized root - $availableSpace MB now available" + fi + fi + fi + fi + if ! $installFailed; then + # make sure the root partition has space for the package + if (( $availableSpace < $rootMinimumSize )); then + setInstallFailed $EXIT_ROOT_FULL "no room for modified files on root ($availableSpace MB remaining) - can't continue" + fi + fi +} + + +# convert a version string to an integer to make comparisions easier +# the Victron format for version numbers is: vX.Y~Z-large-W +# the ~Z portion indicates a pre-release version so a version without it is "newer" than a version with it +# the -W portion has been abandoned but was like the ~Z for large builds and is IGNORED !!!! +# large builds now have the same version number as the "normal" build +# +# the version string passed to this function allows for quite a bit of flexibility +# any alpha characters are permitted prior to the first digit +# up to 3 version parts PLUS a prerelease part are permitted +# each with up to 4 digits each -- MORE THAN 4 digits is indeterminate +# that is: v0.0.0d0 up to v9999.9999.9999b9999 and then v9999.9999.9999 as the highest priority +# any non-numeric character can be used to separate main versions +# special significance is assigned to single caracter separators between the numeric strings +# b or ~ indicates a beta release +# a indicates an alpha release +# d indicates an development release +# these offset the pre-release number so that b/~ has higher numeric value than any a +# and a has higher value than d separator +# +# a blank version or one without at least one number part is considered invalid +# alpha and beta seperators require at least two number parts +# +# returns 0 if conversion succeeeded, 1 if not +# the value integer is returned in $versionNumber +# a status text string is returned in $versionStringToNumberStatus +# and will include the string passed to the function +# as well as the converted number if successful and the type of release detected +# or an error reason if not +# + + +function versionStringToNumber () +{ + local version="$*" + local numberParts + local versionParts + local numberParts + local otherParts + local other + local number=0 + local type='release' + + # split incoming string into + # an array of numbers: major, minor, prerelease, etc + # and an array of other substrings + # the other array is searched for releasy type strings and the related offest added to the version number + + read -a numberParts <<< $(echo $version | tr -cs '0-9' ' ') + numberPartsLength=${#numberParts[@]} + if (( $numberPartsLength == 0 )); then + versionNumber=0 + versionStringToNumberStatus="$version: invalid, missing major version" + return 1 + fi + if (( $numberPartsLength >= 2 )); then + read -a otherParts <<< $(echo $version | tr -s '0-9' ' ') + + for other in ${otherParts[@]}; do + case $other in + 'b' | '~') + type='beta' + (( number += 60000 )) + break ;; + 'a') + type='alpha' + (( number += 30000 )) + break ;; + 'd') + type='develop' + break ;; + esac + done + fi + + # if release all parts contribute to the main version number + # and offset is greater than all prerelease versions + if [ "$type" == "release" ] ; then + (( number += 90000 )) + # if pre-release, last part will be the pre release part + # and others part will be part the main version number + else + (( numberPartsLength-- )) + (( number += 10#${numberParts[$numberPartsLength]} )) + fi + # include core version number + (( number += 10#${numberParts[0]} * 10000000000000 )) + if (( numberPartsLength >= 2)); then + (( number += 10#${numberParts[1]} * 1000000000 )) + fi + if (( numberPartsLength >= 3)); then + (( number += 10#${numberParts[2]} * 100000 )) + fi + + versionNumber=$number + versionStringToNumberStatus="$version:$number $type" + return 0 +} + + + +# compares two version strings +# +# missing verions are treated as 0 +# +# returns 0 if they are equal +# returns 1 if the first is newer than the second +# returns -1 if the second is newer than the first + +function compareVersions () +{ + local versionNumber2 + + if [ -z $2 ]; then + versionNumber2=0 + else + versionStringToNumber $2 + versionNumber2=$versionNumber + fi + if [ -z $1 ]; then + versionNumber=0 + else + versionStringToNumber $1 + fi + + if (( versionNumber == versionNumber2 ));then + return 0 + elif (( versionNumber > versionNumber2 ));then + return 1 + else + return -1 + fi +} diff --git a/HelperResources/IncludeHelpers b/HelperResources/IncludeHelpers index 0a574fb..30e8086 100755 --- a/HelperResources/IncludeHelpers +++ b/HelperResources/IncludeHelpers @@ -17,6 +17,8 @@ pkgDir="$( cd "$(dirname $0)" >/dev/null 2>&1 ; /bin/pwd -P )" pkgRoot="$( dirname "$pkgDir")" pkgName=$( basename $pkgDir ) helperResourcesDir="$pkgRoot/SetupHelper/HelperResources" +logDir="/var/log/PackageManager" +logFile="$logDir/current" if ! [ -e "$helperResourcesDir" ]; then echo "$pkgName: helper files not found - can't continue" | tee -a "/data/log/SetupHelper" @@ -24,13 +26,12 @@ if ! [ -e "$helperResourcesDir" ]; then fi # if we get here, helper files were located - source the files -helperFileList=( EssentialResources LogHandler VersionResources \ - DbusSettingsResources ServiceResources ) +helperFileList=( EssentialResources ServiceResources DbusSettingsResources ) for file in ${helperFileList[@]}; do if [ -f "$helperResourcesDir/$file" ]; then source "$helperResourcesDir/$file" else - echo "$pkgName: helper file $file not found - can't continue" | tee -a "/data/log/SetupHelper" + echo "$pkgName: helper file $file not found - can't continue" | tee -a "$logFile" exit 1 fi done @@ -39,7 +40,7 @@ done if [ -f "$helperResourcesDir/CommonResources" ]; then source "$helperResourcesDir/CommonResources" else - echo "$pkgName: helper file CommonResources not found - can't continue" | tee -a "/data/log/SetupHelper" + echo "$pkgName: helper file CommonResources not found - can't continue" | tee -a "$logFile" exit 1 fi diff --git a/HelperResources/LogHandler b/HelperResources/LogHandler deleted file mode 100755 index ed75905..0000000 --- a/HelperResources/LogHandler +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -# LogHandler for SetupHelper -# contains a functions and variables necessarey to write to and output logs -# -# Refer to the SetupHelper ReadMe file for details on how to use these resources -# - -logDir="/var/log/PackageManager" -logFile="$logDir/current" -if ! [ "$logDir" ]; then - mkdir -P "$logDir" - touch "$logFile" -fi - -oldLogFile="/var/log/SetupHelper" -if [ -e "$oldLogFile" ]; then - if (( $( tail -5 "$oldLogFile" | grep -c "WARNING: this log file no longer used" ) == 0 )); then - echo "WARNING: this log file no longer used" >> "$oldLogFile" - echo " SetupHelper now logged to /var/log/PackageManager/current" >> "$oldLogFile" - fi -fi - -# enable logging to console -# scripts can disable logging by setting -# logToConsole to false AFTER sourcing LogHandler -logToConsole=true - -# output the last 100 lines of the log file to the console -# the full path to the log file should be passed in $1 -# converts the tai64 time stamp to human readable form - -displayLog () -{ - tail -100 "$logFile" | tai64nlocal -} - - -# write a message to log file and console - -logMessage () -{ - # to console - if $logToConsole ; then - echo "$*" - fi - - # to setup helper log - echo "$shortScriptName: $*" | tai64n >> $logFile -} diff --git a/HelperResources/VersionResources b/HelperResources/VersionResources deleted file mode 100755 index c4a1439..0000000 --- a/HelperResources/VersionResources +++ /dev/null @@ -1,139 +0,0 @@ -#!/bin/sh - -# this file contains functions for comparing version numbers -# -# NOTE: this script does NOT rely on other helper files - - -# convert a version string to an integer to make comparisions easier -# the Victron format for version numbers is: vX.Y~Z-large-W -# the ~Z portion indicates a pre-release version so a version without it is "newer" than a version with it -# the -W portion has been abandoned but was like the ~Z for large builds and is IGNORED !!!! -# large builds now have the same version number as the "normal" build -# -# the version string passed to this function allows for quite a bit of flexibility -# any alpha characters are permitted prior to the first digit -# up to 3 version parts PLUS a prerelease part are permitted -# each with up to 4 digits each -- MORE THAN 4 digits is indeterminate -# that is: v0.0.0d0 up to v9999.9999.9999b9999 and then v9999.9999.9999 as the highest priority -# any non-numeric character can be used to separate main versions -# special significance is assigned to single caracter separators between the numeric strings -# b or ~ indicates a beta release -# a indicates an alpha release -# d indicates an development release -# these offset the pre-release number so that b/~ has higher numeric value than any a -# and a has higher value than d separator -# -# a blank version or one without at least one number part is considered invalid -# alpha and beta seperators require at least two number parts -# -# returns 0 if conversion succeeeded, 1 if not -# the value integer is returned in $versionNumber -# a status text string is returned in $versionStringToNumberStatus -# and will include the string passed to the function -# as well as the converted number if successful and the type of release detected -# or an error reason if not -# - - -function versionStringToNumber () -{ - local version="$*" - local numberParts - local versionParts - local numberParts - local otherParts - local other - local number=0 - local type='release' - - # split incoming string into - # an array of numbers: major, minor, prerelease, etc - # and an array of other substrings - # the other array is searched for releasy type strings and the related offest added to the version number - - read -a numberParts <<< $(echo $version | tr -cs '0-9' ' ') - numberPartsLength=${#numberParts[@]} - if (( $numberPartsLength == 0 )); then - versionNumber=0 - versionStringToNumberStatus="$version: invalid, missing major version" - return 1 - fi - if (( $numberPartsLength >= 2 )); then - read -a otherParts <<< $(echo $version | tr -s '0-9' ' ') - - for other in ${otherParts[@]}; do - case $other in - 'b' | '~') - type='beta' - (( number += 60000 )) - break ;; - 'a') - type='alpha' - (( number += 30000 )) - break ;; - 'd') - type='develop' - break ;; - esac - done - fi - - # if release all parts contribute to the main version number - # and offset is greater than all prerelease versions - if [ "$type" == "release" ] ; then - (( number += 90000 )) - # if pre-release, last part will be the pre release part - # and others part will be part the main version number - else - (( numberPartsLength-- )) - (( number += 10#${numberParts[$numberPartsLength]} )) - fi - # include core version number - (( number += 10#${numberParts[0]} * 10000000000000 )) - if (( numberPartsLength >= 2)); then - (( number += 10#${numberParts[1]} * 1000000000 )) - fi - if (( numberPartsLength >= 3)); then - (( number += 10#${numberParts[2]} * 100000 )) - fi - - versionNumber=$number - versionStringToNumberStatus="$version:$number $type" - return 0 -} - - - -# compares two version strings -# -# missing verions are treated as 0 -# -# returns 0 if they are equal -# returns 1 if the first is newer than the second -# returns -1 if the second is newer than the first - -function compareVersions () -{ - local versionNumber2 - - if [ -z $2 ]; then - versionNumber2=0 - else - versionStringToNumber $2 - versionNumber2=$versionNumber - fi - if [ -z $1 ]; then - versionNumber=0 - else - versionStringToNumber $1 - fi - - if (( versionNumber == versionNumber2 ));then - return 0 - elif (( versionNumber > versionNumber2 ));then - return 1 - else - return -1 - fi -} diff --git a/reinstallMods b/reinstallMods index 1a3dac4..fdfeb01 100755 --- a/reinstallMods +++ b/reinstallMods @@ -1,16 +1,15 @@ #!/bin/sh # this script is called from /data/rcS.local during system boot -# it checks to see if SetupHelper and the PackageManager service -# are installed and if not, will install the PackageManager service +# it checks to see the PackageManager service is installed and if not, +# will install the PackageManager service # -# the REINSTALL_PACKAGES flag file is then set so that when -# PackageManger runs, it will do boot-time reinstall checks for all packages +# the REINSTALL_PACKAGES flag file is then set so that +# when PackageManger runs, it will do boot-time reinstall checks for all packages scriptDir="$( cd "$(dirname $0)" >/dev/null 2>&1 ; /bin/pwd -P )" helperResourcesDir="$scriptDir/HelperResources" source "$helperResourcesDir/EssentialResources" -source "$helperResourcesDir/LogHandler" source "$helperResourcesDir/ServiceResources" # disable outputting log messages to console @@ -21,19 +20,27 @@ logMessage "reinstallMods starting" if [ -f "$setupOptionsDir/DO_NOT_AUTO_INSTALL" ]; then logMessage "CRITICAL: SetupHelper was manually uninstalled therefore it was not reinstalled" logMessage " other packages will NOT BE REINSTALLED either !" - rm -f "/etc/venus/REINSTALL_PACKAGES" # install PackageManager service if not yet installed else - # install PackageManager service if not yet installed - if ! [ -e "$serviceDir/PackageManager" ]; then - logMessage "installing PackageManager service - PackageManager will reinstall all packages" - installService PackageManager + # installing the PackageManager service requires remounting root R/W + updateRootToReadWrite + + if ! $installFailed ; then + # install PackageManager service if not yet installed + if ! [ -e "$serviceDir/PackageManager" ]; then + logMessage "installing PackageManager service - PackageManager will reinstall all packages" + installService PackageManager + fi + fi + if ! $installFailed ; then + # notify PackageManager that it needs to check all packages for possible reinstall + # flag file is cleared in PackageManager when all install checks have been made + touch "/etc/venus/REINSTALL_PACKAGES" + logMessage "reinstallMods finished" + else + logMessage "reinstallMods not completed - packages will not be reinstalled" fi - # notify PackageManager that it needs to check all packages for possible reinstall - # flag file is cleared in PackageManager when all install checks have been made - touch "/etc/venus/REINSTALL_PACKAGES" fi -logMessage "reinstallMods finished" diff --git a/reinstallMods copy b/reinstallMods copy deleted file mode 100755 index 4b64220..0000000 --- a/reinstallMods copy +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/sh - -# reinstalMods will reinstall SetupHelper if a Venus OS update removes it -# -# other packages will then be reinstalled by PackageManager -# - -# this script is called from /data/rcS.local during system boot -# it checks to see if SetupHelper and the PackageManager service -# are installed and if not, will install the PackageManager service -# -# the REINSTALL_PACKAGES flag file is then set so that when -# PackageManger runs, it will do boot-time reinstall checks of all packages - -scriptDir="$( cd "$(dirname $0)" >/dev/null 2>&1 ; /bin/pwd -P )" -helperResourcesDir="$scriptDir/HelperResources" -source "$helperResourcesDir/EssentialResources" -source "$helperResourcesDir/LogHandler" - -# disable outputting log messages to console -runningAtBoot=true - -logMessage "reinstallMods starting" - - - - - - - - - -command="$scriptDir/setup" - -installSetupHelper=true -# SetupHelper already installed, nothing to do -if [ -f "$installedVersionFile" ]; then - logMessage "SetupHelper already installed" - installSetupHelper=false -elif [ -f "$setupOptionsDir/DO_NOT_AUTO_INSTALL" ]; then - logMessage "CRITICAL: SetupHelper was manually uninstalled therefore it was not reinstalled" - logMessage " other packages will NOT BE REINSTALLED either !" - installSetupHelper=false -elif ! [ -f $command ] ; then - logMessage "ERROR: SetupHelper setup script not found - can't reinstall" - installSetupHelper=false -fi - -rebootNeeded=false - -if $installSetupHelper; then - # hold off PackageManager processing - # this is unlikely since SetupHelper isn't installed yet - touch "/etc/venus/REINSTALL_MODS_RUNNING" - waitReported=false - # wait until PM is no longer running - # or is waiting for this script to finish - while true ; do - if [ -n $( pgrep -f PackageManager.py ) ]; then - pmStatus=$( dbus -y com.victronenergy.packageManager /PmStatus GetValue ) - if [[ "$pmStatus" == *"boot reinstall"* ]]; then - if $waitReported ; then - logMessage "PackageManager waiting for reinstallMods to finish" - fi - break - elif ! $waitReported ; then - logMessage "waiting for PackageManager to complete operations" - waitReported=true - fi - else - if $waitReported ; then - logMessage "PackageManager no longer running" - fi - break - fi - sleep 2 - done - - # run setup script - installOtherPackages=false - $command reinstall auto deferReboot - returnCode=$? - - case $returnCode in - $EXIT_SUCCESS ) - installOtherPackages=true - ;; - $EXIT_REBOOT ) - installOtherPackages=true - rebootNeeded=true - ;; - $EXIT_NO_GUI_V1 ) - logMessage "ERROR: SetupHelper install failed - no GUI v1 installed" - ;; - $EXIT_ROOT_FULL ) - logMessage "ERROR: SetupHelper install failed - no room in root partition" - ;; - *) - logMessage "ERROR: SetupHelper install failed - reason $returnCode" - ;; - esac - - if $installOtherPackages ; then - logMessage "SetupHelper installed - PackageManager will reinstall remaining packages" - # flag file is cleared in PackageManager when all install checks have been made - touch "/etc/venus/REINSTALL_PACKAGES" - fi -fi - -# reboot now if signaled from setup script -# if rebooting, PackageManager processing will be held until -# this script runs on next boot and clears the flag below. -if $rebootNeeded ; then - logMessage "rebooting ..." - reboot -# allow PackageManager to continue processing -else - rm -f "/etc/venus/REINSTALL_MODS_RUNNING" - logMessage "reinstallMods finished" -fi - diff --git a/version b/version index 549dce5..e9e8b80 100644 --- a/version +++ b/version @@ -1 +1 @@ -v8.0~35 +v8.0~36