3 CKM_DATA_PATH=/opt/data/ckm
4 VERSION_INFO_PATH=${CKM_DATA_PATH}/version-info
12 # Extract uids from DKEK files
13 for uid in `ls ${CKM_DATA_PATH} | grep "^key-[0-9]*-[0-9]*$" | awk 'BEGIN { FS = "-" }; { print $2 }' | awk '!x[$0]++'`
18 for (( i = 0; i < ${#ARR_UID[@]}; i++ ))
25 # Extract autoincremented index per uids
26 for file in `ls ${CKM_DATA_PATH} | grep "^key-${uid}-[0-9]*$"`
28 idx=`echo $file | awk 'BEGIN { FS = "-" }; { print $3 }'`
32 # Find max index(for key-<uid>) and submax index(for key-backup-<uid>)
33 for idx in ${ARR_IDX[@]}
35 if [ $idx -gt $idx_max ]
43 # smack label setting isn't needed.
44 # (Because not remove/add new file, but just rename file)
45 mv "${CKM_DATA_PATH}/key-${uid}-${idx_max}" "${CKM_DATA_PATH}/key-${uid}"
46 if [ -f "${CKM_DATA_PATH}/key-${uid}-${idx_submax}" ]
48 mv "${CKM_DATA_PATH}/key-${uid}-${idx_submax}" "${CKM_DATA_PATH}/key-backup-${uid}"
51 # [Optional] Remove other key-<uid>-<numeric> files.
52 for file in `ls ${CKM_DATA_PATH} | grep "^key-${uid}-[0-9]*$"`
54 rm ${CKM_DATA_PATH}/${file}
59 if [ ! -f ${VERSION_INFO_PATH} ]
61 echo "CKM VERSION_INFO NOT EXIST."
62 echo "$CURRENT_VERSION" > $VERSION_INFO_PATH