init 843 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. CERTS_DIR="${SNAP_DATA}/certs"
  3. SSL_DIR="${SNAP_DATA}/.ssl"
  4. UUID_FILE="${SNAP_DATA}/.install-id"
  5. if ! [[ -f "${UUID_FILE}" ]]; then
  6. logger "Generate UUID for ${SNAP_NAME}"
  7. uuid > "${UUID_FILE}"
  8. logger "${SNAP_NAME} (uuid: `cat ${UUID_FILE}`)"
  9. fi
  10. UUID=`cat ${UUID_FILE}`
  11. function gpg_start_agent {
  12. gpg-agent 2> /dev/null
  13. if [ $? -ne 0 ]; then
  14. logger "GPG-agent not here"
  15. gpg-agent --daemon 2> /dev/null
  16. if [ $? -eq 0 ]; then
  17. logger "GPG-agent started"
  18. else
  19. logger "Failed starting GPG-agent, trying anyway"
  20. fi
  21. fi
  22. return 0
  23. }
  24. function gpg_close_agent {
  25. PID=`ps -T | grep gpg-agent | head -n 1 | cut -d' ' -f1`
  26. if [ -n "${PID}" ]; then
  27. logger "Kill GPG-agent: ${PID}"
  28. kill -9 "${PID}" >> /dev/null
  29. fi
  30. }