#!/bin/sh
#
# $Id: system_update,v 1.1 2004/03/31 11:43:40 jg Exp $
#
# Project     :  SCPM (System Configuration Profile Management)
# Module      :  SCPM Utilities
# File        :  system_update
# Description :  Performs update operations need after OS update
# Author      :  Joachim Gleissner <jg@suse.de>
#
# Copyright 2004 SuSE Linux AG
#
# Released under the terms of the GNU General Public License
# (see file COPYRIGHT in project root directory).
#

INITIALIZED=$( /sbin/scpm status | awk '{ if ($1 == "enabled") print $3 }' )
if [ $INITIALIZED = no ]; then
    echo "SCPM is not initialized, aborting update."
    exit 0
fi

NEEDS_UPDATE=$( /sbin/scpm status | awk '{ if ($1 == "needs") print $4 }'  )
if [ $NEEDS_UPDATE = no ]; then
    echo "SCPM does not need an update."
    exit 0
fi

echo "Updating SCPM"
/sbin/scpm -x db set 'status*system' "`head -n 1 /etc/SuSE-release`"
/sbin/scpm -x -v update_resources
RETVAL=$?

echo
if [ $? -ne 0 ]; then
    echo "FAILED!"
    echo "A full reinit of SCPM may be needed, call 'scpm -f enable' to achive that."
    echo "You need to setup up all profile after that. Please read the documentation!"
else
    echo "SCPM resources were updated and backups were created."
    echo "Please read the section about updating in the usage chapter of the info"
    echo "pages ('info scpm' or launch URL 'info:/scpm' in KDE)."
fi

exit $RETVAL
