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