#!/usr/bin/ruby
#
# This script is called at the first boot after a snapper rollback
# The purpose of this script is, to verify, that after an rollback
# the corret products are registered at SCC/SMT.

require "suse/connect"

VARDIR="/var/lib/rollback"

cmd="rm -f /#{VARDIR}/check-registration"

system cmd

begin
  # TODO: check if repos were actually changed
  if SUSE::Connect::YaST.activated_products.any?
    SUSE::Connect::Migration.rollback
  end
rescue => e
  print "SUSEConnect error: #{e.class}: #{e.message}\n"
end

