-# update an authorized_keys file after first processing the
-# authorized_user_ids file
-update_authorized_keys() {
- local msAuthorizedKeys
- local userAuthorizedKeys
- local cacheDir
-
- msAuthorizedKeys="$1"
- userAuthorizedKeys="$2"
- cacheDir="$3"
-
- process_authorized_ids "$AUTHORIZED_USER_IDS" "$cacheDir"
-
- # write output key file
- log "writing monkeysphere authorized_keys file... "
- touch "$msAuthorizedKeys"
- if [ "$(ls "$cacheDir")" ] ; then
- log -n "adding gpg keys... "
- cat "$cacheDir"/* > "$msAuthorizedKeys"
- echo "done."
- else
- log "no gpg keys to add."
- fi
- if [ "$userAuthorizedKeys" -a -s "$userAuthorizedKeys" ] ; then
- log -n "adding user authorized_keys file... "
- cat "$userAuthorizedKeys" >> "$msAuthorizedKeys"
- echo "done."
- fi
- log "monkeysphere authorized_keys file generated: $msAuthorizedKeys"
-}
-
-# process an authorized_*_ids file
-# go through line-by-line, extract each userid, and process
-process_authorized_ids() {
- local authorizedIDs
- local cacheDir
- local userID
-
- authorizedIDs="$1"
- cacheDir="$2"
-
- # clean out keys file and remake keys directory
- rm -rf "$cacheDir"
- mkdir -p "$cacheDir"