shellinabox-2.19.ebuild 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. AUTOTOOLS_AUTORECONF="yes"
  5. AUTOTOOLS_IN_SOURCE_BUILD="yes"
  6. inherit user autotools-utils
  7. DESCRIPTION="Web server that can export arbitrary command line tools to a web based terminal emulator"
  8. HOMEPAGE="https://github.com/shellinabox/shellinabox"
  9. SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.zip -> ${P}.zip"
  10. LICENSE="GPL-2"
  11. SLOT="0"
  12. KEYWORDS="amd64 ppc ppc64 x86"
  13. IUSE="+ssl +pam"
  14. RDEPEND="${DEPEND}"
  15. DEPEND="${RDEPEND}
  16. ssl? ( dev-libs/openssl:0= )
  17. pam? ( virtual/pam )"
  18. SIAB_CERT_DIR="/etc/shellinabox/cert"
  19. SIAB_SSL_BASH="${SIAB_CERT_DIR}/gen_ssl_cert.bash"
  20. SIAB_DAEMON="${PN}d"
  21. shellinbox_gen_ssl_setup() {
  22. read -r -d '' SIAB_SSL_SETUP << EOF
  23. cd ${SIAB_CERT_DIR}
  24. openssl genrsa -des3 -out server.key 1024
  25. openssl req -new -key server.key -out server.csr
  26. cp server.key server.key.org
  27. openssl rsa -in server.key.org -out server.key
  28. openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  29. cat server.crt server.key > certificate.pem
  30. EOF
  31. }
  32. pkg_setup() {
  33. enewgroup "${SIAB_DAEMON}"
  34. enewuser "${SIAB_DAEMON}" -1 -1 -1 "${SIAB_DAEMON}"
  35. }
  36. src_configure() {
  37. local myeconf="--disable-runtime-loading"
  38. econf \
  39. $(use_enable ssl) \
  40. $(use_enable pam) \
  41. "${myeconf}"
  42. }
  43. src_install() {
  44. emake DESTDIR="${D}" install || die
  45. # make installs the binary in bin.
  46. rm -rf "${D}/usr/bin" || die
  47. # whereas it should put it in sbin.
  48. dosbin "${SIAB_DAEMON}"
  49. # Install init+conf files.
  50. newinitd "${FILESDIR}/${SIAB_DAEMON}.init" "${SIAB_DAEMON}"
  51. newconfd "${FILESDIR}/${SIAB_DAEMON}.conf" "${SIAB_DAEMON}"
  52. # Install CSS files.
  53. insinto "/usr/share/${PN}-resources"
  54. doins -r "${PN}"/*.css
  55. if use ssl; then
  56. # Create directory where SSL certificates will be generated.
  57. dodir "${SIAB_CERT_DIR}"
  58. fowners "${SIAB_DAEMON}:${SIAB_DAEMON}" "${SIAB_CERT_DIR}"
  59. # Generate set up variable.
  60. shellinbox_gen_ssl_setup
  61. # Dump it in a bash script.
  62. echo "#!/usr/bin/env bash" > "${D}/${SIAB_SSL_BASH}" ||die
  63. echo "${SIAB_SSL_SETUP}" >> "${D}/${SIAB_SSL_BASH}" || die
  64. chmod +x "${D}/${SIAB_SSL_BASH}" || die
  65. fi
  66. }
  67. pkg_postinst() {
  68. ewarn
  69. ewarn "The default configuration expose a login shell"
  70. ewarn "with SSL disabled on the localhost interface only."
  71. ewarn
  72. if use ssl; then
  73. shellinbox_gen_ssl_setup
  74. einfo
  75. einfo "To generate self-signed SSL certificates"
  76. einfo "please read the following procedure"
  77. einfo "explained here: https://code.google.com/p/shellinabox/issues/detail?id=59#c15"
  78. einfo
  79. einfo "${SIAB_SSL_SETUP}"
  80. einfo
  81. einfo "This walkthrough has been written in ${SIAB_SSL_BASH} for your convenience."
  82. einfo "Make sure to execute this script."
  83. einfo
  84. fi
  85. }