-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrestgetprofile
executable file
·39 lines (32 loc) · 1.19 KB
/
restgetprofile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
#
# restgetprofile: tool for getting iRMC/BIOS profile via RESTful API
#
# (c) Juergen Orth - Fujitsu Technology Solutions GmbH
#
# $Id: restgetprofile 70 2020-08-11 05:59:24Z HMBJOrth $
. ${0%/*}/restoptions
. ${0%/*}/resttool
PROFILE=${1:-$DEFAULTPROFILE}
showinfo retrieving $PROFILE from $IRMC
ProfileStoreList | awk -F/ '/odata/ {print $(NF)}' | tr -d '"' | grep -q ${PROFILE##*/}
if [ $? -eq 0 ]
then
# Delete already existing profile in store
showinfo Delete existing $PROFILE in store
ProfileStoreDelete $PROFILE >/dev/null
fi
# Copy running profile to store
showinfo Reading profile - be patient ...
SESSION=$(ProfileStoreAdd Server/SystemConfig/$PROFILE)
[ -z "$SESSION" ] && error 1 ProfileStoreAdd failed
showinfo Waiting for session $SESSION to terminate - be patient ...
SessionWait $SESSION
# Read profile from store, add execute attribute and write it to file
ProfileStoreGet $PROFILE | awk '/^\{/ {flag=1}
flag>0 {print}' | sed -E '/\"IrmcConfig|\"BiosConfig/ a \\t"@Processing":"execute",' >$JSON
showinfo Profile stored in $JSON
# Delete profile in store and session from session list
showinfo Cleaning up
ProfileStoreDelete $PROFILE >/dev/null
SessionDelete $SESSION >/dev/null