1
0

init 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. DOMAIN=`snapctl get domain`
  12. if [ -z "${DOMAIN}" ]; then
  13. DOMAIN="--not-set"
  14. fi
  15. snapctl set domain="${DOMAIN}"
  16. function gpg_start_agent {
  17. gpg-agent 2> /dev/null
  18. if [ $? -ne 0 ]; then
  19. logger "GPG-agent not here"
  20. gpg-agent --daemon 2> /dev/null
  21. if [ $? -eq 0 ]; then
  22. logger "GPG-agent started"
  23. return 0
  24. fi
  25. logger "Failed starting GPG-agent"
  26. return 1
  27. fi
  28. return 0
  29. }
  30. function gpg_close_agent {
  31. PID=`ps -T | grep gpg-agent | head -n 1 | cut -d' ' -f1`
  32. if [ -n "${PID}" ]; then
  33. logger "Kill GPG-agent: ${PID}"
  34. kill -9 "${PID}" >> /dev/null
  35. fi
  36. }