sys-process/glances: 3.1.4.1-r1 amd64 stable, bug #720368
[gentoo.git] / www-misc / shellinabox / shellinabox-2.20-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
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 systemd
10
11 DESCRIPTION="Export 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="+pam"
19
20 DEPEND="
21         dev-libs/openssl:0=
22         pam? ( sys-libs/pam )"
23
24 SIAB_CERT_DIR="/etc/shellinabox/cert"
25 SIAB_SSL_BASH="${SIAB_CERT_DIR}/gen_ssl_cert.bash"
26 SIAB_DAEMON="${PN}d"
27
28 shellinbox_gen_ssl_setup() {
29         read -r -d '' SIAB_SSL_SETUP << EOF
30 cd ${SIAB_CERT_DIR}
31 openssl genrsa -des3 -out server.key 1024
32 openssl req -new -key server.key -out server.csr
33 cp server.key server.key.org
34 openssl rsa -in server.key.org -out server.key
35 openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
36 cat server.crt server.key > certificate.pem
37 EOF
38 }
39
40 pkg_setup() {
41         enewgroup "${SIAB_DAEMON}"
42         enewuser "${SIAB_DAEMON}" -1 -1 -1 "${SIAB_DAEMON}"
43 }
44
45 src_configure() {
46         local myeconf=(
47                 --disable-runtime-loading
48                 --enable-ssl
49         )
50
51         econf \
52                 $(use_enable pam) \
53                 "${myeconf[@]}"
54 }
55
56 src_install() {
57         emake DESTDIR="${D}" install
58
59         # make installs the binary in bin...
60         rm -rf "${D}/usr/bin" || die
61
62         # ... whereas it should put it in sbin.
63         dosbin "${SIAB_DAEMON}"
64
65         # Install init+conf files.
66         newinitd "${FILESDIR}/${SIAB_DAEMON}.init" "${SIAB_DAEMON}"
67         newconfd "${FILESDIR}/${SIAB_DAEMON}.conf" "${SIAB_DAEMON}"
68
69         # Install systemd unit file.
70         systemd_dounit "${FILESDIR}"/shellinaboxd.service
71
72         # Install CSS files.
73         insinto "/usr/share/${PN}-resources"
74         doins -r "${PN}"/*.css
75
76         # Create directory where SSL certificates will be generated.
77         dodir "${SIAB_CERT_DIR}"
78         fowners "${SIAB_DAEMON}:${SIAB_DAEMON}" "${SIAB_CERT_DIR}"
79
80         # Generate set up variable.
81         shellinbox_gen_ssl_setup
82
83         # Dump it in a bash script.
84         echo "#!/usr/bin/env bash" > "${D}/${SIAB_SSL_BASH}" || die
85         echo "${SIAB_SSL_SETUP}" >> "${D}/${SIAB_SSL_BASH}" || die
86         chmod +x "${D}/${SIAB_SSL_BASH}" || die
87 }
88
89 pkg_postinst() {
90         ewarn
91         ewarn "The default configuration exposes a login shell"
92         ewarn "with SSL disabled on the localhost interface only."
93         ewarn
94
95         shellinbox_gen_ssl_setup
96
97         einfo
98         einfo "To generate self-signed SSL certificates"
99         einfo "please read the procedure explained here:"
100         einfo "https://code.google.com/p/shellinabox/issues/detail?id=59#c15"
101         einfo
102         einfo "${SIAB_SSL_SETUP}"
103         einfo
104         einfo "This walkthrough has been written in ${SIAB_SSL_BASH} for your convenience."
105         einfo "Make sure to execute this script."
106         einfo
107 }