#!/bin/bash2
# PhionVersionString 3.2.0.1
# modified output of "unknown error default value"

ARG=${1:-xxx}

case $ARG in
	headerchange)
		TYPE_ID=4240
		TYPE_NAME="\"Bootloader Configuration Change\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA=""
		;;
	confirmkernupdate)
                TYPE_ID=4242
                TYPE_NAME="\"Automatic Kernel Update\""
                LAYER_ID=1
                LAYER_NAME=OS
                CLASS_ID=3
                CLASS_NAME=bootloader
                DATA=""
		;;
	autokernupdate)
		TYPE_ID=4244
		TYPE_NAME="\"Automatic Kernel Update\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA=""
		;;
	nokernupdate)
		TYPE_ID=4246
		TYPE_NAME="\"Kernel Update Refused\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA="\"Kernel update administratively prohibited. Check configuration.\""
		;;
	manupdate)
		TYPE_ID=4248
		TYPE_NAME="\"Custom Bootloader Configuration Change.\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA="\"Custom bootloader configuration change requested.\""
		;;
	loadertestfailed)
		TYPE_ID=4250
		TYPE_NAME="\"Configuration Test Activation Failed.\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=1
		CLASS_NAME=bootloader
		DATA=""
		;;
	loaderfailed)
		TYPE_ID=4252
		TYPE_NAME="\"Configuration Activation Failed.\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA=""
		;;
	loaderrecovfailed)
                TYPE_ID=4254
                TYPE_NAME="\"Emergency Recovery Failed.\""
                LAYER_ID=1
                LAYER_NAME=OS
                CLASS_ID=3
                CLASS_NAME=bootloader
                DATA="\"Previous working bootloader configuration could not be reactivated. Do NOT reboot the system.\""
                ;;    
	kernupdateactivate)
                TYPE_ID=4260
                TYPE_NAME="\"Pending Kernel Update\""
                LAYER_ID=1
                LAYER_NAME=OS
                CLASS_ID=3
                CLASS_NAME=bootloader
                DATA="\"Successful test activation of kernel update ($2). Manual activation from control required.\""
                ;;        
	kernupdatetrigger)
                TYPE_ID=4261
                TYPE_NAME="\"Activate Pending Kernel Update\""
                LAYER_ID=1
                LAYER_NAME=OS
                CLASS_ID=3
                CLASS_NAME=bootloader
                DATA="\"Activation of pending kernel update triggered.\""
                ;;        
	kernupdatesuccess)
		TYPE_ID=4258
		TYPE_NAME="\"Kernel Update Succeeded\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA="\"Changes will only become effective after rebooting the system.\""
		;;
	kernupdatefailed)
		TYPE_ID=4264
		TYPE_NAME="\"Kernel Update Failed\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA="\"The bootloader configuration changes could not be activated. Check the log files.\""
		;;
	headerupdatesuccess)
		TYPE_ID=4256
		TYPE_NAME="\"Bootloader Configuration Update Succeeded\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA="\"Changes will only become effective after rebooting the system.\""
		;;
	headerchangefailed)
		TYPE_ID=4262
		TYPE_NAME="\"Bootloader Configuration Change Failed.\""
		LAYER_ID=1
		LAYER_NAME=OS
		CLASS_ID=3
		CLASS_NAME=bootloader
		DATA="\"The bootloader configuration changes could not be activated. Check the log files.\""
		;;
esac
	
		
		
if [ -x /etc/phion/bin/events ]; then
	eval /etc/phion/bin/events --layer_id="$LAYER_ID"  --layer_name="$LAYER_NAME" --class_id="$CLASS_ID" --class_name="$CLASS_NAME" --type_id="$TYPE_ID" --type_name="$TYPE_NAME" --data="$DATA" &>/dev/null
fi
