Deepa Karthikeyan | a96df3e | 2024-04-16 11:22:29 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | base_dir="/var/lib/phosphor-software-manager/hostfw" |
| 4 | ro_dir="/media/hostfw/running-ro" |
| 5 | running_dir="${base_dir}/running" |
| 6 | file_recovered=0 |
| 7 | |
| 8 | if [ -f "${ro_dir}/81e00994.lid" ]; then |
| 9 | #look for the DEVTREE and the preserved files |
| 10 | filesList=$(grep 'PRESERVED\|DEVTREE' "${ro_dir}/81e00994.lid") |
| 11 | for eachFile in ${filesList}; do |
| 12 | eachFile=${eachFile##partition*=} |
| 13 | eachFile=$(echo "${eachFile}" | cut -d "," -f 1) |
| 14 | #check if it is a symbolic link |
| 15 | if [ -L "${running_dir}/${eachFile}" ]; then |
| 16 | # get the symlink target file |
| 17 | eachFile="$(readlink "${running_dir}/${eachFile}")" |
| 18 | if [ -f "${running_dir}/${eachFile}" ] && [ -f "${ro_dir}/${eachFile}" ]; then |
| 19 | runsize="$(stat -c '%s' "${running_dir}/${eachFile}")" |
| 20 | rosize="$(stat -c '%s' "${ro_dir}/${eachFile}")" |
| 21 | # Partition size may have changed or became corrupted |
| 22 | # restoring the file from the readonly copy |
| 23 | if [ "$runsize" != "$rosize" ]; then |
| 24 | cp -p ${ro_dir}/"${eachFile}" ${running_dir}/"${eachFile}" |
| 25 | # Log PEL to indicate such |
| 26 | busctl call xyz.openbmc_project.Logging \ |
| 27 | /xyz/openbmc_project/logging \ |
| 28 | xyz.openbmc_project.Logging.Create Create "ssa{ss}" \ |
| 29 | xyz.openbmc_project.Software.Version.Error.HostFile \ |
| 30 | xyz.openbmc_project.Logging.Entry.Level.Error 3 "FILE_NAME" \ |
| 31 | "${eachFile}" "CURRENT_FILE_SIZE" "${runsize}" "EXPECTED_FILE_SIZE" \ |
| 32 | "${rosize}" |
| 33 | |
| 34 | file_recovered=1 |
| 35 | fi |
| 36 | fi |
| 37 | fi |
| 38 | done |
| 39 | #one or more files could be recovered. So trigger dump outside the while loop |
| 40 | if [ $file_recovered -eq 1 ]; then |
| 41 | # Initiate dump |
| 42 | busctl call xyz.openbmc_project.Dump.Manager \ |
| 43 | /xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create \ |
| 44 | CreateDump "a{sv}" 0 |
| 45 | fi |
| 46 | fi |