Merge "Include factory install flags into factory backup"
This commit is contained in:
@@ -7,6 +7,20 @@
|
|||||||
# Factory install backup triggered during the backup stage
|
# Factory install backup triggered during the backup stage
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Flag files that need to be created if backup is successful
|
||||||
|
BACKUP_FLAG="/var/lib/factory-install/state/backup"
|
||||||
|
FINAL_FLAG="/var/lib/factory-install/stage/final"
|
||||||
|
COMPLETE_FLAG="/var/lib/factory-install/complete"
|
||||||
|
|
||||||
|
# Remove flag files on failure
|
||||||
|
cleanup_on_failure() {
|
||||||
|
log_warn "Backup failed, cleaning up flags..."
|
||||||
|
rm -f "$BACKUP_FLAG" "$FINAL_FLAG" "$COMPLETE_FLAG"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Trap to cleanup flags on any failure
|
||||||
|
trap cleanup_on_failure ERR
|
||||||
|
|
||||||
# Get software version from build info
|
# Get software version from build info
|
||||||
SW_VERSION=$(awk -F= '/^SW_VERSION/ {print $2}' /etc/build.info | tr -d '"')
|
SW_VERSION=$(awk -F= '/^SW_VERSION/ {print $2}' /etc/build.info | tr -d '"')
|
||||||
BACKUP_DIR="/opt/platform-backup/factory/${SW_VERSION}"
|
BACKUP_DIR="/opt/platform-backup/factory/${SW_VERSION}"
|
||||||
@@ -40,6 +54,17 @@ function log_info {
|
|||||||
echo "$(date +"%Y-%m-%d %H:%M:%S,%3N - factory-backup -") INFO: $*"
|
echo "$(date +"%Y-%m-%d %H:%M:%S,%3N - factory-backup -") INFO: $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create flags at the beginning so they are included in the backup
|
||||||
|
log_info "Creating factory install flags..."
|
||||||
|
touch "$BACKUP_FLAG"
|
||||||
|
check_rc_die $? "Failed to create backup flag"
|
||||||
|
|
||||||
|
touch "$FINAL_FLAG"
|
||||||
|
check_rc_die $? "Failed to create final flag"
|
||||||
|
|
||||||
|
touch "$COMPLETE_FLAG"
|
||||||
|
check_rc_die $? "Failed to create complete flag"
|
||||||
|
|
||||||
# Skip the execution of the system-backup script if system_mode is duplex
|
# Skip the execution of the system-backup script if system_mode is duplex
|
||||||
system_mode=$(awk -F= '/system_mode/ {print $2}' /etc/platform/platform.conf)
|
system_mode=$(awk -F= '/system_mode/ {print $2}' /etc/platform/platform.conf)
|
||||||
if [ "$system_mode" != "simplex" ]; then
|
if [ "$system_mode" != "simplex" ]; then
|
||||||
|
|||||||
@@ -9,11 +9,7 @@ After=factory-install-tests.service
|
|||||||
Type=oneshot
|
Type=oneshot
|
||||||
User=root
|
User=root
|
||||||
ExecStart=/usr/bin/run-parts --verbose --exit-on-error /var/lib/factory-install/backup
|
ExecStart=/usr/bin/run-parts --verbose --exit-on-error /var/lib/factory-install/backup
|
||||||
ExecStartPost=+/usr/bin/touch /var/lib/factory-install/state/backup
|
|
||||||
ExecStartPost=+/usr/bin/touch /var/lib/factory-install/stage/final
|
|
||||||
ExecStartPost=+/usr/bin/touch /var/lib/factory-install/complete
|
|
||||||
ExecStartPost=+/var/lib/factory-install/utils/disable-factory-install
|
ExecStartPost=+/var/lib/factory-install/utils/disable-factory-install
|
||||||
|
|
||||||
StandardOutput=append:/var/log/factory-install.log
|
StandardOutput=append:/var/log/factory-install.log
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
Restart=no
|
Restart=no
|
||||||
|
|||||||
Reference in New Issue
Block a user