# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               github 1.0

# Missing compatibility implementation of strndup.
# https://github.com/shellinabox/shellinabox/issues/400
PortGroup               legacysupport 1.0
legacysupport.newest_darwin_requires_legacy 10

# 2.21 was released in 2019 but was not tagged.
# https://github.com/shellinabox/shellinabox/issues/480
github.setup            shellinabox shellinabox 4f0ecc31ac6f985e0dd3f5a52cbfc0e9251f6361
version                 2.21
revision                0
checksums               rmd160  4cc7654ca3ac52d33c855913a41c830d07e4bc0e \
                        sha256  55e7458d7e9c028657d8157170043d6fd5588d740316146c6e70dca9c4a108fa \
                        size    749379

categories              net shells www
maintainers             {ryandesign @ryandesign} openmaintainer
license                 {GPL-2 OpenSSLException}

description             a web-based terminal emulator for ssh or other command line tools

long_description        Shell In A Box implements a web server that can export arbitrary \
                        command line tools (e.g. ssh) to a web-based terminal emulator. \
                        This emulator is accessible to any JavaScript- and CSS-enabled \
                        web browser and does not require any additional browser plugins.

github.tarball_from     archive

depends_lib             path:lib/libssl.dylib:openssl \
                        port:zlib

patchfiles              implicit.patch \
                        version.patch

# No configure script in tarball.
use_autoreconf          yes

# Enable openssl support
# https://code.google.com/p/shellinabox/issues/detail?id=110
configure.args-append   --disable-runtime-loading --disable-pam

if {${os.platform} eq "darwin" && ${os.major} > 8} {
    set user _${name}
} else {
    set user ${name}
}
set group ${user}

add_users               ${user} group=${group} realname=${name}

set certdir             ${prefix}/etc/${name}/certs

startupitem.create      yes
startupitem.executable  ${prefix}/bin/${name}d --user=${user} --group=${group} --cert=${certdir}

destroot.keepdirs       ${destroot}${certdir}

post-destroot {
    xinstall -o ${user} -g ${group} -d ${destroot}${certdir}
}

platform darwin 17 {
    # https://github.com/shellinabox/shellinabox/issues/479
    configure.cppflags-append -Wno-unguarded-availability-new
}

notes {
There is no configuration file; you may wish to use your own launchd plist instead of the\
one included in this port if you want to run the daemon with different options.
}
