# Maintainer (Artix): artoo <artoo@cromnix.org>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>

_apver=2.4.18-r1
_aprel=20160303

_dev_url="http://dev.gentoo.org/~polynomial-c/dist/apache"
_url="https://raw.githubusercontent.com/gentoo/gentoo/master"

_sed_args=(-e 's|/var/run|/run|g' -e 's|/usr/sbin|/usr/bin|g')
prefix=true

$_prefix && _sed_args+=(-e 's|#!/sbin/openrc-run|#!/usr/bin/openrc-run|g')

pkgbase=openrc-net
pkgname=('apache-openrc'
         'autofs-openrc'
         'bind-openrc'
         'cyrus-sasl-openrc'
         'dhcp-openrc'
         'dovecot-openrc'
         'exim-openrc'
         'hostapd-openrc'
         'krb5-openrc'
         'lighttpd-openrc'
         'nginx-openrc'
         'opendkim-openrc'
         'opendmarc-openrc'
         'openldap-openrc'
         'openntpd-openrc'
         'opensmtpd-openrc'
         'openssh-openrc'
         'openvpn-openrc'
         'polipo-openrc'
         'postfix-openrc'
         'privoxy-openrc'
         'rsync-openrc'
         'samba-openrc'
         'spamassassin-openrc'
         'squid-openrc'
         'syncthing-openrc'
         'tor-openrc'
         'transmission-openrc'
         'ufw-openrc'
         'unbound-openrc'
         'vnstat-openrc'
         'vsftpd-openrc'
         'wicd-openrc'
         'x2goserver-openrc'
         'xinetd-openrc')
pkgver=20190211
pkgrel=1
pkgdesc="OpenRC init scripts"
arch=('any')
url="https://github.com/artix-linux"
license=('GPL2')
groups=('openrc-net')
conflicts=('systemd-sysvcompat')
source=("${_dev_url}/gentoo-apache-${_apver}-${_aprel}.tar.bz2"
        "autofs.initd::${_url}/net-fs/autofs/files/autofs5.initd"
        "named.confd::${_url}/net-dns/bind/files/named.confd-r7"
        "named.initd::${_url}/net-dns/bind/files/named.init-r13"
        "saslauthd.initd::${_url}/dev-libs/cyrus-sasl/files/saslauthd2.rc7"
        "dhcpd.confd::${_url}/net-misc/dhcp/files/dhcpd.conf2"
        "dhcrelay.confd::${_url}/net-misc/dhcp/files/dhcrelay.conf"
        "dhcrelay6.confd::${_url}/net-misc/dhcp/files/dhcrelay6.conf"
        "dhcpd.initd::${_url}/net-misc/dhcp/files/dhcpd.init5"
        "dhcrelay.initd::${_url}/net-misc/dhcp/files/dhcrelay.init3"
        "dovecot.initd::${_url}/net-mail/dovecot/files/dovecot.init-r4"
        "exim.confd::${_url}/mail-mta/exim/files/exim.confd"
        "exim.initd::${_url}/mail-mta/exim/files/exim.rc10"
        "hostapd.confd::${_url}/net-wireless/hostapd/files/hostapd-conf.d"
        "hostapd.initd::${_url}/net-wireless/hostapd/files/hostapd-init.d"
        "krb5kadmind.initd::${_url}/app-crypt/mit-krb5/files/mit-krb5kadmind.initd-r2"
        "krb5kdc.initd::${_url}/app-crypt/mit-krb5/files/mit-krb5kdc.initd-r2"
        "krb5kpropd.initd::${_url}/app-crypt/mit-krb5/files/mit-krb5kpropd.initd-r2"
        "lighttpd.confd::${_url}/www-servers/lighttpd/files/lighttpd.confd"
        "lighttpd.initd::${_url}/www-servers/lighttpd/files/lighttpd.initd"
        "nginx.confd::${_url}/www-servers/nginx/files/nginx.confd"
        "nginx.initd::${_url}/www-servers/nginx/files/nginx.initd-r4"
        "slapd.confd::${_url}/net-nds/openldap/files/slapd-confd-2.4.28-r1"
        "slapd.initd::${_url}/net-nds/openldap/files/slapd-initd-2.4.40-r2"
        "ntpd.confd::${_url}/net-misc/openntpd/files/openntpd.conf.d-20080406-r6"
        "ntpd.initd::${_url}/net-misc/openntpd/files/openntpd.init.d-20080406-r6"
        "sshd.confd::${_url}/net-misc/openssh/files/sshd.confd"
        "sshd.initd::${_url}/net-misc/openssh/files/sshd.rc6.4"
        "opendkim.initd"
        "opendmarc.confd"
        "opendmarc.initd::${_url}/mail-filter/opendmarc/files/opendmarc.initd"
        "openvpn.confd::${_url}/net-vpn/openvpn/files/openvpn-2.1.conf"
        "openvpn.initd::${_url}/net-vpn/openvpn/files/openvpn-2.1.init"
        "smtpd.initd::${_url}/mail-mta/opensmtpd/files/smtpd.initd"
        "polipo.initd::${_url}/net-proxy/polipo/files/polipo.initd-5"
        "postfix.initd::${_url}/mail-mta/postfix/files/postfix.rc6.2.7"
        "privoxy.initd::${_url}/net-proxy/privoxy/files/privoxy.initd-3"
        "rsyncd.confd::${_url}/net-misc/rsync/files/rsyncd.conf.d"
        "rsyncd.initd::${_url}/net-misc/rsync/files/rsyncd.init.d-r1"
        "smb.confd::${_url}/net-fs/samba/files/4.4/samba4.confd"
        "smb.initd::${_url}/net-fs/samba/files/4.4/samba4.initd-r1"
        "spamassassin.initd::${_url}/mail-filter/spamassassin/files/3.4.1-spamd.init-r3"
        "spamassassin.confd::${_url}/mail-filter/spamassassin/files/3.4.1-spamd.conf-r1"
        "squid.confd::${_url}/net-proxy/squid/files/squid.confd-r1"
        "squid.initd::${_url}/net-proxy/squid/files/squid.initd-r4"
        "syncthing.confd"
        "syncthing.initd"
        "tor.confd::${_url}/net-vpn/tor/files/tor.confd"
        "tor.initd::${_url}/net-vpn/tor/files/tor.initd-r8"
        "transmission-daemon.confd::${_url}/net-p2p/transmission/files/transmission-daemon.confd.4"
        "transmission-daemon.initd::${_url}/net-p2p/transmission/files/transmission-daemon.initd.10"
        "ufw.confd::${_url}/net-firewall/ufw/files/ufw.confd"
        "ufw.initd::${_url}/net-firewall/ufw/files/ufw-2.initd"
        "unbound.confd::${_url}/net-dns/unbound/files/unbound-r1.confd"
        "unbound.initd::${_url}/net-dns/unbound/files/unbound-r1.initd"
        "vnstatd.confd::${_url}/net-analyzer/vnstat/files/vnstatd.confd"
        "vnstatd.initd::${_url}/net-analyzer/vnstat/files/vnstatd.initd-r1"
        "${_url}/net-ftp/vsftpd/files/vsftpd-checkconfig.sh"
        "vsftpd.initd::${_url}/net-ftp/vsftpd/files/vsftpd.init"
        "wicd.initd"
        "x2goserver.initd::${_url}/net-misc/x2goserver/files/x2goserver.init"
        "xinetd.confd::${_url}/sys-apps/xinetd/files/xinetd.confd"
        "xinetd.initd::${_url}/sys-apps/xinetd/files/xinetd.rc6")
sha512sums=('68f0c4de38ae05c45839fe692cbb7de641e331ca133b8aaaf69f3659dec15833cda95e6e074edb3a5b6b6d59b3fc5a4ee3589fff810707fe27417a25cd8a4c4d'
            'f8e1d38917b9c7048a4f6498fb987984306e15458eaf8cb73990a99d355d7f7ce3f1aa5450725283cbbc6f5c0e2f31048f1cd26eca7f136f1fe30a6dd8d31c43'
            '68fa7c8963ac59349de3d05972c07aa0123b7bebbe0ba9604463ccfd1b377c2babe01eed4745cbe0f7d3831d1b47c2fa620f8092c67465fb771cae4932b0861a'
            'c675adec65796989dc8524d533868975d4e2c3b2ed5f09aa3cd92ec21b8dfb161582dd5afdf08ab78174873f3e1458e90c2d50958f0b5a303078540a675ec0c9'
            '1d5942a94ffbc15774443d60a88d4c89c7c3c6ea68b041d304f0110f6ec3aa2a812f59021cddc78de6f51a25bb00955e4e56d769e766a9d856f13774dd37ce83'
            '7b7a77b7826b475a4113ebeee54501ce417cc56e85754301a82a185d88b4713d198f615a366e63e0e2b0aef988c8137dcd1e18c4036d993378257079da17693d'
            'af94d679c5b7652a770d4acb96f5f12fd9dc99f4e8e26b10fab67514693f63392bc8033a6e5e6c1967d7004decc72b810462e1fe92c1d4808606e48086dea00b'
            '40d3a6bdf8521bf5152cf31b961aea88b2fb0339433d0b6a6360a16c796298620b377bd079c0246e97bc9c0533ddb13bbb58cc5169d0ca598e3a51d1a607a9e9'
            '0cf238f3e79ee5d1ba059331664fd092d025ecb8fdb3f1d428713d7cd81ad4efe10ad7ad4ef48146aa6c9763293c1641057a257480e58a639fc6cc20e623f4c1'
            'ab4c38c53bf21dccee252358f0ecece81829048a546f380cb1e3552804e412c38dac09805fb7f9520531d48d3d79b3dd228ffdba7203b89ac30a778a579ddbda'
            '8fbc80bc0efa6b83685da19b6a5c2a2d2ca7e59be7f1f7352984fe30004175330e53f3db1c4c2471f1d7d5e088bef0b4dced97d29d32be8b50d000987b6eeb09'
            'cb5e4aa71d3f0b7945e9806064f6a3ab64cb894381654ead40c73a49ae2d1bbb3dc587919952a09b2c81b9fcf8784f73d59c12081cda96a5b7210442f5088998'
            '5c7cee6139145983c62df8f5ef6c401d34d2eb7eae3146c28045129ba40868ca4d3d10d4b7056887cf4d4d8a83271592f7fa0a527663f727fa8694b621eb5624'
            'f07a6cd209eca351b8545017c5f025282c3fdea838ca3df49e362571ded43973281ce4ff83984b1299db15ea9b5c21a42cbda91432220af9146bf034e2265c30'
            'ab364383da45403d7734be20e7486937ad0a6be25a56eb1ec03d131243270a143189b699becf6e9e14d30b02bb5d93cddde55e51908801f2e6830de53791ccc8'
            '3791af603380277a9d2632a01a86f96f68c9eb38a2c9574cca462fe9a01bef60f24785051d0215a8d71dd5022f1404e281929278e2bfd31603a0415dd9df6a98'
            '42cbc315a4e28a78cd29ee6f9aa9401ac6185cc78d39528f0c498d6b04a8edba7b7efadaaeae52ac2c4f89faa846787da9aee645f9ef0bdb79cd6289454586a3'
            '28b9d9bc9d132d8bd87d5fd9e74103d4772f26cba48d28ad53f40ade037a5ac91e07c01aa3180d50c3624673bf4e534f76689b03feb4888cdd9198755576b6a7'
            'dd722c15230df734d7151bcb9cfc66d6d54aac5dcdca5f50eb33979d3a2443ba3a9ef3d7cb35e6dbd3d39fce09da15ab0029b1399bf1b1e4f4ef20d40f70a416'
            'd5fc03ded923d2aeea19fefdf658ed793114867dd0b50be6836d767108c98fb7de56011f00ea63220c4b198cff45d98fdc8a649efae90673536e03f786219485'
            '9023b33b6e03de4fa4df8459118a34a24a52ec167eb0aa1d220fd5ba8555aa454ca3451cad4eecc87a445b74cae5132fd717286aec3f1fea390eb96547e4ae85'
            'e641829466e54093ad01e9f6c57acd2f0505e489a32e67dfee9279d5da57b216052a92eb05eb0c9c122c12f8b7bf8274b520b6e02fda161cc03187ce7c0660f1'
            '7426c04ee689bcfb29a9a3956367c571eac6bc9620efda938591d09382a05527454458f7a25bdc2fa2ac920f93bae516121e085408ffefbe8ace0c7d8c5da315'
            '3945dc4cff9b20bddd2ac4f38d045f8caabb59368ab0b5e952d4194d06a1bdd9871546b84e9a54b692d2e3ca699aa065e5fa909a29ae80e102ed9635c94bcfd5'
            '016094e0ac80817c8c1eb8a52a527c8a673b3ee904f2c04bef0304b5dfe1c778a34a2d5321cc5540a1dfe2e14dc878c44a1e54fd0263aca3917600827c6d9059'
            'eff7820dea7f79420ddc78fc744a34f6f5cedbf167d7ce98ed35d4ae0b1dab6cae026d5255a6cc428cdbc8f51784ed149c5ec8011ab72c31c65a5bfc6664b94f'
            'b9ae816af54a55e134a9307e376f05367b815f1b3fd545c2a2c312d18aedcf907f413e8bad8db980cdd9aad4011a72a79e1e94594f69500939a9cb46287f2f81'
            'fe58e950514743a72467233ff2f2a63112c50e5db843d61e141a5ca3dd8ef8f42a616cd9de7748ae582054c47c2cc38ce48b638e2d88be39c1387f77e79c83e1'
            '756f48579e2913aa50a547ea7a0a534e0b0cfb4b3246f97a232360331e3dd2fe891effba4c7ac36c3f4b73867b3d75e4d58fd3c428249b73a67e54b54f5e2f0f'
            '6d89d247bfbaee977be8e318ab93234b242780fd0a682f4ad0e825486cfa5e8ee0e41899ec142c921fc220f3f7ed0759e27502bcd373b869564ee438301e699e'
            '00c9901cf5b460e20d8010d4aedfd7c338c76d1053f9ddcd9d4aa2c183345e3b810d0bee1207ff9a7ad988577192c52470ca62c67130a981fa67e393d5c70129'
            '982ade883afbe2e656a9cbbe36c31c0e8b4f7bbbe5b63df9f7b834f02a9153032fb7445c85d3e91f62c68a7ddd13c3afbf420fb71cdd13d9c4b69f867bdd9f37'
            '2d97a41b3998c196c440dcaf43ad8992eae27c5356c94b24f4cc4b20169350f3d6c8d65bb9c2517415ee15637fa60298d9cd8252ad9aa3eec6ae3a847ede0611'
            'e4c8386bd7e8d8171172aa181305a55ca67cba6d4c82d77d8846e1bd3301dd9d118bb39dad6c144677f050194de813e4d83e06ea6dd591d4f07da8c4a1edde37'
            '9a1da0f1a156ce58ed25b20d4e06ac11c0a3040bc032a77c688a518dcb308c6f8ffe6bdeaa608d03fd1feead89ac5f04ce98853de88d32a1af0a79005a0c26bd'
            '2ad1b053bbb51d4f480dbf5a01252e8e99a82ec14a75ff49336b2b190ea55bc02400542b109fa0cc4ebfe6b42eaabbc45f70f2ea581f1eb9c4189c439b825592'
            '0bfd7ab2e42c4905f2542a4dbd93cf30d15a8808d527e6bcb6b14f75de226c94c0e0dea6ff69bbac37d3da605acfa2035e2d0e9fe0a41d7beb33cfea5ed2340b'
            '8ea9a2f1fea508fa132313fa16513eac84a9ed3ce75741c42769b56bbcd3f1bd2eb8bfdfe40a6c7f619e4281e8fc8d95d1bd84096d0b64aaacf606cd614ae5b3'
            'df2ef4d9e65fa72daa9a7d91d69a06027d0e0fbc48f9ebd485e2d51990c8d00985b7ccf41314f984975e8073e2075bbdfe5543754718381497c334dc7d96451a'
            'd6a7ae560621407b7a5f94db6489d6a85c5056f4212a2a9a24210eaeb585caf4f15801282d1b8682962c0cf5642766fe09cc70c48fffafd1560de615154503af'
            '982771fd7e1d260d8d4305eb18a3c15871f535b700d2b9554af24df62286e59ce6c5c76ef4ffee7a751fc01040eefaaabad71b2f67e3749ba1ee97a368b14d5a'
            '2c968750da3252e8dcce4cebf105a26a9dbc471e39bda7d66180e0fbf930b11dd3a98337d7c387026375918b660768c637c2f2031d6624ce3237d9cc8cd88a02'
            'b2233d9330fa06d13dc8d222fa16198a1f81dcb9c87ca93961db54d9f2514cdabd824d0f25c0cca678495f271f48f601ee14363c2a2f833100facae307226beb'
            '018418d0ef66c9ab5d67a8e68ed6f95c7a04ad2a8a073747f39d9db8e83cf72c685d388a727363788042e45d440a69651ec928ccdeed835915ebc8c676b43519'
            'd1edeeafef69730429c19e07b4b39ff388047042880c61907fb2e6d8a907011edb78a29faa265f8e07d2c3bb18d63d62dd384338729e2549995f7f2a0903783d'
            'ce83d729f8fce5fd3da0564f25b352d44d1f62e9a68e9315a04af377ebc36cbf92cf8ea0a55919f0b9f8f19c493c5ad59c976d0ff6b9f3652e587ef7240c0414'
            '322cff79ad490767910fe8697ba86fafcc60f93e7b1739886c6167c9d5cf92467a6223da8c66b9f769419958fc6cd34354ae0eb81ad7d3e7d2fcf512b33d787f'
            '9028ac41e3acdf4405095addb69537e87edecafaec840296ac27a5a8992fe132dc822e4e4abb8826f76460c438da2719dea17859690d03e17198a82086a3d660'
            '4b690a721311a310131041ab962c571f1898f884f55fedf91b842e5190ce58399cccf59d34b4716d5dc15df4183f994d84c7c39f8458cb5f5da870ddc2db1730'
            '47e78c85857eefb9be6c25d1e789cfb2a276d5816ba911ba1511e764469b2d9998edafe44247aff784113ca28926748bc5fb2b879280b780fd69ffb1e4e40736'
            '30d9fe7d06ca3c92ff436e9bbe84729a5b343b52965f8d1d3d43f14f5fa25881dbc9676c5d3d916cff552aad5872ed41c2930e9ce3a5f7c958dbeec0d1ab1ac4'
            'a010532c97b9cf83f1fb5fa707228e0542a8b109c76e5942aaf2d6552c63e033d32e39e5a6ac87cb9e2ed4c3fdbc5d03c75127e6378665e592b143bc1eda52c7'
            'f6cb7f6f7713d6f2c78c0b0254f385701f28b997931007997f0702af0dcd0d1b1bf08617dbb3abd21219c23a63ec3286e019896253ff7e9bdbb218a5bb17dd80'
            'a6baf20b9911734b69784c393c8f38a0bf41c9621ab9332761ecb8b5fdcebf18be7f30a5a77bf3755aa45222b2f27f810a762436c43b03dd74e6806e04d5a90f'
            'ec3520094a679fee962244364d8093b471e7edd5fce434c6d307854952f2ad9d2f041ce5fd5f23ece93a856d59a966daaf5abc114b7d1f3519b930b2e8f14f62'
            'd645817913d5b52e928561b3d6a0e869d8ae5db81b97af91c1ebfc6a8cd2df666c1653e6dc5f91c0a890033a89692f77eaf081c1cae5590446c69a70ea263946'
            '6ad3a29a9a376e7dc19279f7effd643b7f55e66461925689c0a7bc43d3484d001d9c027b53e16b3b5b526f45fb0cc47d31f68b2d3137fbb9203e03e66795304f'
            '541702557231c79413ae77cf26c28398fea3cb332375f8d22e0c0a45706b04db954d268addd76fecbb8b0ab3109f1009c18b0599394ed33c4a6fc8dc647d889e'
            'b367c412f2aebdfa90fae912467ebf227b39be04b45f686c5ea5f66df6addc81a2f130dd616dae932a55108337169e19ef53012f27127eb1970852ed5ea697c0'
            '9c67f021239ce555d6c8fc5ae4e4885c5c74e5778e9dd33d4f079d61c601b603fad10865119dc3b17263330f6159a4f73a37260af88bb47f1b8a30457c4a17ee'
            '4e5add80aedbfb732552158b8c2b97b711e333f45740b8e3dd37089e7a512bd145d64812ec651cd7b022065129cced5730e1b28ab3758fcd81bea5b84b46d93c'
            '03bf05e544c0e52bc2bdeadf494dabd49ace985687b656baae869be99ef65a5f7129492c37e062bf6f196f70561d6239f2d3c4e8171fddc04729d3e266bfe2b2'
            'bfe591f83a03e26ccbe06c489fa8c2e7af0f05203e0239b7cbde521dbe22700ba63d4bc50465e01a3fc101a7c7cfa40d0a6a02e881e950143bef7ac4046a6604')


pkgver() {
    date +%Y%m%d
}

_inst_initd(){
    install -Dm755 ${srcdir}/$1.initd ${pkgdir}/etc/init.d/$1

    sed ${_sed_args[@]} -i ${pkgdir}/etc/init.d/$1
}

_inst_confd(){
    install -Dm755 ${srcdir}/$1.confd ${pkgdir}/etc/conf.d/$1
}

package_apache-openrc() {
    pkgdesc="OpenRC apache init script"
    depends=('openrc' 'apache')
    backup=('etc/conf.d/httpd')

    install -Dm644 "${srcdir}/gentoo-apache-${_apver}/init/apache2.confd" "${pkgdir}/etc/conf.d/httpd"
    install -Dm755 "${srcdir}/gentoo-apache-${_apver}/init/apache2.initd" "${pkgdir}/etc/init.d/httpd"

    sed -e 's|/usr/sbin/apache2|/usr/bin/apachectl|' \
        -e 's|/etc/apache2/httpd.conf|/etc/httpd/conf/httpd.conf|' \
        -e 's/! test -f/test -f/' \
        -e 's|/usr/lib/apache2|/usr/lib/httpd|' \
        -e 's|apache2.pid|httpd/httpd.pid|' \
        -e 's|apache2 >/dev/null|httpd >/dev/null|' \
        -e 's|/run/apache_ssl_mutex|/run/httpd|' \
        -i "${pkgdir}/etc/init.d/httpd"

    sed -e 's|/etc/apache2/httpd.conf|/etc/httpd/conf/httpd.conf|' \
        -e 's|/usr/lib/apache2|/usr/lib/httpd|' \
        -e 's|apache2.pid|httpd/httpd.pid|' \
        -e 's|apache2|httpd|g' \
        -i "${pkgdir}/etc/conf.d/httpd"
}

package_autofs-openrc() {
    pkgdesc="OpenRC autofs init script"
    depends=('openrc' 'autofs')

    _inst_initd 'autofs'
}

package_bind-openrc() {
    pkgdesc="OpenRC bind init script"
    depends=('openrc' 'bind')
    backup=('etc/conf.d/named')

    _inst_confd 'named'
    _inst_initd 'named'

    sed -e 's|/etc/bind/named.conf|/etc/named.conf|g' \
        -i "${pkgdir}/etc/init.d/named"
}

package_cyrus-sasl-openrc() {
    pkgdesc="OpenRC cyrus-sasl init script"
    depends=('openrc' 'cyrus-sasl')

    _inst_initd 'saslauthd'
}

package_dhcp-openrc() {
    pkgdesc="OpenRC dhcp init script"
    depends=('openrc' 'dhcp')
    optdepends=('openldap-openrc: openldap initscript'
                'bind-openrc: bind initscript')
    backup=('etc/conf.d/dhcpd'
            'etc/conf.d/dhcrelay'
            'etc/conf.d/dhcrelay6')
    install=dhcp.install

    for f in dhcpd dhcrelay;do
        _inst_confd $f
        _inst_initd $f
    done
#
    _inst_confd 'dhcrelay6'
#     _inst_initd 'dhcrelay6'

    install -Dm755 "${srcdir}/dhcrelay.initd" "${pkgdir}/etc/init.d/dhcrelay6"

    for f in ${pkgdir}/etc/init.d/*;do
        sed -e 's|#@slapd@|ldap slapd|' \
            -i $f
    done
}

package_dovecot-openrc() {
    pkgdesc="OpenRC dovecot init script"
    depends=('openrc' 'dovecot')
    
    _inst_initd 'dovecot'
}

package_exim-openrc() {
    pkgdesc="OpenRC exim init script"
    depends=('openrc' 'exim')
    backup=('etc/conf.d/exim')
    
    _inst_initd 'exim'
    _inst_confd 'exim'
    
    sed -e 's|/etc/exim|/etc/mail|g' -i "${pkgdir}/etc/init.d/exim"
}

package_hostapd-openrc() {
    pkgdesc="OpenRC hostapd init script"
    depends=('openrc' 'hostapd')
    backup=('etc/conf.d/hostapd')

    _inst_confd 'hostapd'
    _inst_initd 'hostapd'
}

package_krb5-openrc() {
    pkgdesc="OpenRC krb5 init script"
    depends=('openrc' 'krb5')

    for f in krb5kadmind krb5kdc krb5kpropd;do
        _inst_initd $f
    done

    for f in ${pkgdir}/etc/init.d/*;do
        sed -e 's|mit-krb5kdc|krb5kdc|g' \
            -e 's|mit-krb5kadmind|krb5kadmind|g' \
            -i $f
    done
}

package_lighttpd-openrc() {
    pkgdesc="OpenRC lighttpd init script"
    depends=('openrc' 'lighttpd')
    backup=('etc/conf.d/lighttpd')
    install=lighttpd.install

    _inst_confd 'lighttpd'
    _inst_initd 'lighttpd'

    sed -e 's/lighttpd:lighttpd/http:http/' \
        -i "${pkgdir}/etc/init.d/lighttpd"
}

package_nginx-openrc() {
    pkgdesc="OpenRC nginx init script"
    depends=('openrc' 'nginx')
    backup=('etc/conf.d/nginx')

    _inst_confd 'nginx'
    _inst_initd 'nginx'

}

package_opendkim-openrc() {
    pkgdesc="OpenRC opendkim init script"
    depends=('openrc' 'opendkim')

    _inst_initd 'opendkim'

}

package_opendmarc-openrc() {
    pkgdesc="OpenRC opendmarc init script"
    depends=('openrc' 'opendmarc')

    _inst_confd 'opendmarc'
    _inst_initd 'opendmarc'

}

package_openldap-openrc() {
    pkgdesc="OpenRC openldap init script"
    depends=('openrc' 'openldap')
    backup=('etc/conf.d/slapd')

    _inst_confd 'slapd'
    _inst_initd 'slapd'

    sed -e 's|/usr/lib/openldap/slapd|/usr/lib/slapd|g' \
        -i "${pkgdir}/etc/init.d/slapd"
}

package_openntpd-openrc() {
    pkgdesc="OpenRC openntpd init script"
    depends=('openrc' 'openntpd')
    groups=('openrc-net')
    provides=('openrc-timed')
    conflicts=('ntp' 'ntp-openrc' 'systemd-sysvcompat')
    backup=('etc/conf.d/ntpd')

    _inst_confd 'ntpd'
    _inst_initd 'ntpd'
}

package_opensmtpd-openrc() {
    pkgdesc="OpenRC opensmtpd init script"
    depends=('openrc' 'opensmtpd')
    
    _inst_initd 'smtpd'
}

package_openssh-openrc() {
    pkgdesc="OpenRC openssh init script"
    depends=('openrc' 'openssh')
    optdepends=('bind-openrc: bind initscript')
    backup=('etc/conf.d/sshd')

    _inst_confd 'sshd'
    _inst_initd 'sshd'
}

package_openvpn-openrc() {
    pkgdesc="OpenRC openvpn init script"
    depends=('openrc' 'openvpn')
    backup=('etc/conf.d/openvpn')

    _inst_confd 'openvpn'
    _inst_initd 'openvpn'
}

package_polipo-openrc() {
    pkgdesc="OpenRC polipo init script"
    depends=('openrc' 'polipo')

    _inst_initd 'polipo'
}

package_postfix-openrc() {
    pkgdesc="OpenRC postfix init script"
    depends=('openrc' 'postfix')
    optdepends=('bind-openrc: bind initscript'
                'cyrus-sasl-openrc: cyrus-sasl initscript')

    _inst_initd 'postfix'
}

package_privoxy-openrc() {
    pkgdesc="OpenRC privoxy init script"
    depends=('openrc' 'privoxy')

    _inst_initd 'privoxy'

    sed -e "${_shebang}" \
        -e "${_runpath}" \
        -i "${pkgdir}/etc/init.d/privoxy"
}

package_rsync-openrc() {
    pkgdesc="OpenRC rsync init script"
    depends=('openrc' 'rsync')
    backup=('etc/conf.d/rsyncd')

    _inst_confd 'rsyncd'
    _inst_initd 'rsyncd'
}

package_samba-openrc() {
    pkgdesc="OpenRC samba init script"
    depends=('openrc' 'samba')
    backup=('etc/conf.d/smb')

    _inst_confd 'smb'
    _inst_initd 'smb'

    sed -e 's/="samba"/="smb"/' \
        -i "${pkgdir}/etc/conf.d/smb"

    sed -e 's/##samba/##smb/' \
        -e 's|"samba"|"smb"|' \
        -i "${pkgdir}/etc/init.d/smb"
}

package_spamassassin-openrc() {
    pkgdesc="OpenRC spamassassin init script"
    depends=('openrc' 'spamassassin')
    backup=('etc/conf.d/spamassassin')

    _inst_confd 'spamassassin'
    _inst_initd 'spamassassin'
}

package_squid-openrc() {
    pkgdesc="OpenRC squid init script"
    depends=('openrc' 'squid')
    optdepends=('bind-openrc: bind initscript')
    backup=('etc/conf.d/squid')

    _inst_confd 'squid'
    _inst_initd 'squid'

    sed -e 's|chown squid|chown proxy|' \
        -e 's|squid:squid|proxy:proxy|' \
        -i "${pkgdir}/etc/init.d/squid"
}

package_syncthing-openrc() {
    pkgdesc="OpenRC syncthing init script"
    depends=('openrc' 'syncthing')
    backup=('etc/conf.d/syncthing')

    _inst_confd 'syncthing'
    _inst_initd 'syncthing'
}

package_tor-openrc() {
    pkgdesc="OpenRC tor init script"
    depends=('openrc' 'tor')
    backup=('etc/conf.d/tor')
    install=tor.install

    _inst_confd 'tor'
    _inst_initd 'tor'
}

package_transmission-openrc() {
    pkgdesc="OpenRC transmission init script"
    depends=('openrc' 'transmission-cli')
    backup=('etc/conf.d/transmission-daemon')

    _inst_confd 'transmission-daemon'
    _inst_initd 'transmission-daemon'
}

package_ufw-openrc() {
    pkgdesc="OpenRC ufw init script"
    depends=('openrc' 'ufw')
    backup=('etc/conf.d/ufw')

    _inst_confd 'ufw'
    _inst_initd 'ufw'

    sed -e 's|/usr/share/ufw/ufw-init-functions|/usr/lib/ufw/ufw-init-functions|g' \
        -i "${pkgdir}/etc/init.d/ufw"
}

package_unbound-openrc() {
    pkgdesc="OpenRC unbound init script"
    depends=('openrc' 'unbound')
    backup=('etc/conf.d/unbound')

    _inst_confd 'unbound'
    _inst_initd 'unbound'
}

package_vnstat-openrc() {
    pkgdesc="OpenRC vnstat init script"
    depends=('openrc' 'vnstat')
    backup=('etc/conf.d/vnstatd')

    _inst_confd 'vnstatd'
    _inst_initd 'vnstatd'
}

package_vsftpd-openrc() {
    pkgdesc="OpenRC vsftpd init script"
    depends=('openrc' 'vsftpd')
    optdepends=('bind-openrc: bind initscript')

    _inst_initd 'vsftpd'

    install -Dm755 "${srcdir}/vsftpd-checkconfig.sh" "${pkgdir}/usr/lib/vsftpd-checkconfig.sh"

    sed -e 's|/usr/libexec/|/usr/lib/|g' \
        -e 's|/etc/vsftpd/|/etc/|g' \
        -i "${pkgdir}/etc/init.d/vsftpd"

    sed -e 's|/etc/vsftpd/|/etc/|g' \
        -i "${pkgdir}/usr/lib/vsftpd-checkconfig.sh"
}

package_wicd-openrc() {
    pkgdesc="OpenRC wicd script"
    depends=('openrc' 'wicd')
    install=wicd.install

    _inst_initd 'wicd'
}

package_x2goserver-openrc() {
    pkgdesc="OpenRC x2goserver init script"
    depends=('openrc' 'x2goserver')
    
    _inst_initd 'x2goserver'
}

package_xinetd-openrc() {
    pkgdesc="OpenRC xinetd init script"
    depends=('openrc' 'xinetd')
    backup=('etc/conf.d/xinetd')

    _inst_confd 'xinetd'
    _inst_initd 'xinetd'
}
