#!/bin/bash

(
 echo "1";
 echo "# Setting up yum variables";
    /usr/libexec/sl-release/set-slrelease7x.sh >/dev/null 2>&1 ;

 # So that the backgrounded script completes
 sleep 3;

 echo "# Reloading repository information";
    pkcon refresh force >/dev/null 2>&1

 echo "# Syncing system-release";
 pkcon -y update sl-release >/dev/null 2>&1
 if [[ $? -eq 0 ]]; then
     # New sl-release installed
     pkcon -y install yum-conf-sl7x >/dev/null 2>&1
     if [[ $? -eq 0 ]]; then
         # You were not actually on 7x so unset it
         pkcon -y remove yum-conf-sl7x >/dev/null 2>&1
     fi
     echo "# Your SL7 system can now upgrade to the latest release";
 else
     echo "# Syncing system-release failed!";
 fi
 sleep 10;

 echo "100" ; sleep 1;
) | zenity --name "Software Update" --title "Setting up SL7 Upgrade" --progress --text "Starting process" --percentage=0 --auto-close --pulsate --no-cancel
