All pastes #153271 Raw Edit

333

public text v1 · immutable
#153271 ·published 2006-08-29 15:06 UTC
rendered paste body
#!/bin/bash
if [ -x /usr/bin/gpg-agent ]; then
  if [ -f ${HOME}/.gpg-agent-info ]; then
    OLD_GPG_AGENT=`cat ${HOME}/.gpg-agent-info`
    CHECK_PID=`echo ${OLD_GPG_AGENT}|cut -d ":" -f 2`
    PROG=`ps -p ${CHECK_PID} |tail -1| sed -e "s,^[^ ]* *[^ ]* *[^ ]* *,,"`
    if [ "${PROG}x" != "gpg-agentx" ]; then
      rm ${HOME}/.gpg-agent-info
    else
      export GPG_AGENT_INFO=${OLD_GPG_AGENT}
    fi
  fi
  if [ ! -f ${HOME}/.gpg-agent-info ]; then
    killall -9 gpg-agent
    eval "`gpg-agent --daemon`"
    echo $GPG_AGENT_INFO >${HOME}/.gpg-agent-info
  fi
fi