diff --git a/1st b/1st deleted file mode 100644 index e69de29..0000000 diff --git a/profiles/package.mask b/profiles/package.mask new file mode 100644 index 0000000..a6e8a90 --- /dev/null +++ b/profiles/package.mask @@ -0,0 +1,4 @@ +# Froxlor Release Team (30 Jan 2010) +# Live version, only use that when you know what you are doing. +=www-apps/froxlor-9999 + diff --git a/profiles/repo_name b/profiles/repo_name new file mode 100644 index 0000000..1055abf --- /dev/null +++ b/profiles/repo_name @@ -0,0 +1 @@ +froxlor diff --git a/profiles/use.local.desc b/profiles/use.local.desc new file mode 100644 index 0000000..fd8862a --- /dev/null +++ b/profiles/use.local.desc @@ -0,0 +1,23 @@ +# Copyright 1999-2011 Gentoo Foundation. +# Distributed under the terms of the GNU General Public License v2 +# $Header$ +# This file contains descriptions of local USE flags, and the ebuilds which +# contain them. +# Keep it sorted (use "LC_ALL=C sort -t: -k1,1 -k2 | LC_ALL=C sort -s -t/ -k1,1") +# Declaring the locale for the sort is critical to avoid flapping. + +www-apps/froxlor:aps - Support for the Application Packaging Standard +www-apps/froxlor:autoresponder - E-Mail Autoresponder Support for Customers +www-apps/froxlor:awstats - use AWStats instead of Webalizer +www-apps/froxlor:bind - Adds support for writing BIND configuration files +www-apps/froxlor:domainkey - Adds support for writing DKIM DNS-Records and Filters for them +www-apps/froxlor:dovecot - use Dovecot instead of Courier +www-apps/froxlor:fcgid - Adds support for FCGId +www-apps/froxlor:ftpquota - Adds support for FTP Quotas for use with ProFTPd +www-apps/froxlor:fpm - Adds support for PHP-FPM +www-apps/froxlor:lighttpd - use ligHTTPd instead of Apache +www-apps/froxlor:log - Adds support for logging actions in the Panel +www-apps/froxlor:mailquota - Adds support for Quotas for the maildirs of Customers +www-apps/froxlor:nginx - use nginx instead of Apache +www-apps/froxlor:pureftpd - use pure-FTPd instead of ProFTPd +www-apps/froxlor:tickets - Adds support for the Ticket System diff --git a/www-apps/froxlor/ChangeLog b/www-apps/froxlor/ChangeLog new file mode 100644 index 0000000..e4eef6b --- /dev/null +++ b/www-apps/froxlor/ChangeLog @@ -0,0 +1,247 @@ +# ChangeLog for www-apps/froxlor +# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2 +# $Header: $ + +*froxlor-0.9.18 (28 Feb 2011) + + 28 Feb 2011; Froxlor Release Team + -froxlor-0.9.17.ebuild, +froxlor-0.9.18.ebuild, froxlor-9999.ebuild, + metadata.xml: + version bump, switch to git and add nginx and FPM support + +*froxlor-0.9.17 (27 Jan 2011) + + 27 Jan 2011; Froxlor Release Team + -froxlor-0.9.16.ebuild, +froxlor-0.9.17.ebuild: + version bump + +*froxlor-0.9.16 (28 Dec 2010) + + 28 Dec 2010; Froxlor Release Team + -froxlor-0.9.15.1.ebuild, +froxlor-0.9.16.ebuild: + version bump + + 10 Dec 2010; Froxlor Release Team + froxlor-0.9.15.1.ebuild, froxlor-9999.ebuild: + fix #517, replace deprecated useq with use + + 07 Dec 2010; Froxlor Release Team + froxlor-0.9.15.1.ebuild, froxlor-9999.ebuild: + fix #510,#511,#512 + +*froxlor-0.9.15.1 (01 Dec 2010) + + 01 Dec 2010; Froxlor Release Team + -froxlor-0.9.15.ebuild, +froxlor-0.9.15.1.ebuild: + version bump + +*froxlor-0.9.15 (29 Nov 2010) + + 29 Nov 2010; Froxlor Release Team + -froxlor-0.9.14.ebuild, +froxlor-0.9.15.ebuild: + version bump + + 29 Nov 2010; Froxlor Release Team froxlor-9999.ebuild, + +files/aliases: + fix #412 + + 07 Nov 2010; Froxlor Release Team + froxlor-0.9.14.ebuild, froxlor-9999.ebuild: + fix typo for #463 + + 02 Nov 2010; Froxlor Release Team + froxlor-0.9.14.ebuild, froxlor-9999.ebuild: + depend on correct SAPI for lighttpd + +*froxlor-0.9.14 (25 Oct 2010) + + 25 Oct 2010; Froxlor Release Team + -froxlor-0.9.13.1.ebuild, +froxlor-0.9.14.ebuild: + version bump, remove old + + 23 Oct 2010; Froxlor Release Team + froxlor-9999.ebuild, metadata.xml: + remove realtime useflag + +*froxlor-0.9.13.1 (01 Oct 2010) + + 01 Oct 2010; Froxlor Release Team + -froxlor-0.9.13.ebuild, +froxlor-0.9.13.1.ebuild, froxlor-9999.ebuild: + version bump, remove old + +*froxlor-0.9.13 (27 Sep 2010) + + 27 Sep 2010; Froxlor Release Team + -froxlor-0.9.12.ebuild, +froxlor-0.9.13.ebuild: + version bump, remove old + + 24 Sep 2010; Froxlor Release Team + froxlor-9999.ebuild: + added php.ini for Froxlors own vhost + + 03 Sep 2010; Froxlor Release Team + froxlor-0.9.12.ebuild, froxlor-9999.ebuild: + fix typo, thanks to Emilien + +*froxlor-0.9.12 (23 Aug 2010) + + 23 Aug 2010; Froxlor Release Team + -froxlor-0.9.11.ebuild, +froxlor-0.9.12.ebuild: + version bump, remove old + + 09 Aug 2010; Froxlor Release Team + froxlor-9999.ebuild, metadata.xml: + add pureftpd support, fix disabling inserttask statement when bind useflag + is not set + +*froxlor-0.9.11 (26 Jul 2010) + + 26 Jul 2010; Froxlor Release Team + -froxlor-0.9.10.ebuild, +froxlor-0.9.11.ebuild: + version bump + + 15 Jul 2010; Froxlor Release Team + froxlor-9999.ebuild: + remove conditional dependency on dovecot 1.1 as per gentoo security bug + #314533 + + 29 Jun 2010; Froxlor Release Team + froxlor-0.9.10.ebuild, froxlor-9999.ebuild: + depend on virtual/cron instead of vixie-cron, thanks to marienz + +*froxlor-0.9.10 (28 Jun 2010) + + 28 Jun 2010; Froxlor Release Team + -froxlor-0.9.9.ebuild, +froxlor-0.9.10.ebuild: + version bump + +*froxlor-0.9.9 (14 Jun 2010) + + 14 Jun 2010; Froxlor Release Team + -froxlor-0.9.8.ebuild, +froxlor-0.9.9.ebuild: + version bump + + 10 Jun 2010; Froxlor Release Team + froxlor-0.9.8.ebuild, froxlor-9999.ebuild: + added USE-flag ftpquota to enable/disable quota in proftpd + + 09 Jun 2010; Froxlor Release Team + froxlor-0.9.8.ebuild, froxlor-9999.ebuild: + some fixes in pkg_config phase + +*froxlor-0.9.8 (31 May 2010) + + 31 May 2010; Froxlor Release Team + -froxlor-0.9.7.ebuild, +froxlor-0.9.8.ebuild: + version bump, remove old + + 28 May 2010; Froxlor Release Team + froxlor-9999.ebuild: + tweak php 5.3 depends, depend on virtual/mysql instead of dev-db/mysql + +*froxlor-0.9.7 (17 May 2010) + + 17 May 2010; Froxlor Release Team + -froxlor-0.9.6.ebuild, +froxlor-0.9.7.ebuild: + version bump, remove old + +*froxlor-0.9.6 (03 May 2010) + + 03 May 2010; Froxlor Release Team + -froxlor-0.9.5.ebuild, +froxlor-0.9.6.ebuild: + version bump, remove old + +*froxlor-0.9.5 (19 Apr 2010) + + 19 Apr 2010; Froxlor Release Team + -froxlor-0.9.4.ebuild, +froxlor-0.9.5.ebuild: + version bump, remove old + + 16 Apr 2010; Froxlor Release Team + froxlor-9999.ebuild: + support PHP 5.3, this is considered WIP until it hits the portage tree + + 11 Apr 2010; Froxlor Release Team + froxlor-0.9.4.ebuild, froxlor-9999.ebuild: + fixup bind permissions, bug 135 + + 10 Apr 2010; Froxlor Release Team + froxlor-0.9.4.ebuild, froxlor-9999.ebuild: + add pl to linguas, drop app-arch/unzip depend, we just expect people to + have a non-broken php version around + +*froxlor-0.9.4 (05 Apr 2010) + + 10 Apr 2010; Froxlor Release Team + froxlor-0.9.4.ebuild, froxlor-9999.ebuild: + add AWStats useflag + + 05 Apr 2010; Froxlor Release Team + -froxlor-0.9.3.ebuild, +froxlor-0.9.4.ebuild: + version bump, remove old + + 25 Mar 2010; Froxlor Release Team + froxlor-0.9.3.ebuild, froxlor-9999.ebuild: + adding ability to define the docroot in /etc/make.conf with + FROXLOR_DOCROOT + + 18 Mar 2010; Froxlor Release Team + froxlor-0.9.3.ebuild, froxlor-9999.ebuild: + add note for cron changes and fix messed up quoting + + 16 Mar 2010; Froxlor Release Team + froxlor-0.9.3.ebuild, froxlor-9999.ebuild: + call epatch_user, fixes #65 + +*froxlor-0.9.3 (14 Mar 2010) + + 14 Mar 2010; Froxlor Release Team + -froxlor-0.9.2.1.ebuild, +froxlor-0.9.3.ebuild: + version bump, remove old + + 02 Mar 2010; Froxlor Release Team + froxlor-0.9.2.1.ebuild, froxlor-9999.ebuild: + fixup installation from $FILESDIR just copy its contents to /usr/share to + make pkg_config(); install its files + +*froxlor-0.9.2.1 (02 Mar 2010) + + 02 Mar 2010; Froxlor Release Team + -froxlor-0.9.2.ebuild, +froxlor-0.9.2.1.ebuild: + version bump, remove old + +*froxlor-0.9.2 (01 Mar 2010) + + 01 Mar 2010; Froxlor Release Team + -froxlor-0.9.1.ebuild, +froxlor-0.9.2.ebuild: + version bump, remove old + + 23 Feb 2010; Froxlor Release Team + froxlor-0.9.1.ebuild, froxlor-9999.ebuild: + block the syscp package and tell people what to do when they upgrade + + 22 Feb 2010; Froxlor Release Team + froxlor-0.9.1.ebuild, froxlor-9999.ebuild: + do not block a dovecot 1.2 upgrade due to usedeps + + 21 Feb 2010; Froxlor Release Team + froxlor-0.9.1.ebuild, froxlor-9999.ebuild, metadata.xml: + add realtime useflag (no configuration yet, just ensure we have the right + php useflag to even make it work) + +*froxlor-0.9.1 (15 Feb 2010) + + 15 Feb 2010; Froxlor Release Team + -froxlor-0.9.ebuild, +froxlor-0.9.1.ebuild: + version bump, remove old + +*froxlor-0.9 (01 Feb 2010) + + 01 Feb 2010; Froxlor Release Team + +froxlor-0.9.ebuild, froxlor-9999.ebuild: + version bump, small cleanup + + 30 Jan 2010; Froxlor Release Team + froxlor-9999.ebuild: + pkg_preinst -> pkg_setup + diff --git a/www-apps/froxlor/Manifest b/www-apps/froxlor/Manifest new file mode 100644 index 0000000..612d468 --- /dev/null +++ b/www-apps/froxlor/Manifest @@ -0,0 +1,20 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA256 + +AUX aliases 820 RMD160 c4c86731b7b8337890677093267c52ea4805af84 SHA1 ce782e4207d50d71446cbe483e5d2b7e99968487 SHA256 809990aeef45ae1c1e46f484b397d6e4b683166fcd55608a0b0efdfb7e6e12ef +AUX domainkey.conf 102 RMD160 7cf298411682321f4f9b97fee313668767a1301e SHA1 ad9a8bb7be54b6fc15c6db6140b11ffd9b4894ae SHA256 30c86dd638888eb92456fd053e25a86b6df7a025f3972e6dc5976d10347a6524 +AUX froxlor.cron 255 RMD160 a506d5165dff33b1a9c3b466441139af73921709 SHA1 bb0d4d5fb6128598883b97babaa4b2a83bd1fdbb SHA256 5a4ff57d65b563d32f1da76726f3fafc3e45cba956e357d7bc7dfe48693edb3d +AUX php-fcgi-starter 226 RMD160 feeb05480f03b357030a73c1192ecfc08598b2b5 SHA1 8dad00ef853d0a0fb1800d231f2f0309e8c3d44f SHA256 1ce8e33e7c89172d24bc95eba804f871c6a72ea7739e3084198d835544ca0535 +AUX php.ini 1765 RMD160 678be9f350668bca899c6dac5fce5c9fe074b28b SHA1 564634c696e38b2b51352e85f9954b66844c46f9 SHA256 b8efce5d40dec9ae0361f7cf0314169c32b68f7cc130f5e1a11093b7d54affa5 +DIST froxlor-0.9.18.tar.gz 1179024 RMD160 611f5b13b262e78735a843a9472272a35b275cec SHA1 9084257268565becf76efcdc82e0e8d6b323eec3 SHA256 74324e070b6885209be2e160e532ac74fd014d8a50e4d03777815cfc2441d67e +EBUILD froxlor-0.9.18.ebuild 56714 RMD160 d00ceed61468e52f1183c5c281d59b95c11f4011 SHA1 280125ee57d9b5ae9779c9e93cbaff2a743982f3 SHA256 da304a765f1d5707668d2e51ca85dd8437a9ffab7535c01d8ff6ddf4d2430b5f +EBUILD froxlor-9999.ebuild 56714 RMD160 d00ceed61468e52f1183c5c281d59b95c11f4011 SHA1 280125ee57d9b5ae9779c9e93cbaff2a743982f3 SHA256 da304a765f1d5707668d2e51ca85dd8437a9ffab7535c01d8ff6ddf4d2430b5f +MISC ChangeLog 7795 RMD160 c5e44acebc7627ee794aff45cbb0d34759a8e165 SHA1 125f7ba76bc439a35829421e981dfa518239e131 SHA256 a46449fb1d3307399290a37fe178a11c862b2a61a6ff9e684de830c7df49f76f +MISC metadata.xml 1423 RMD160 d984046adac16b95ecb18ec6e6cf342c93edda8b SHA1 3c0bf9cbc15aee33d206fb446c434b36d551a44d SHA256 846275c47bdfbf06e3d4e199c2ecd046848807153e477e03e53bf60ca58e7506 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2.0.17 (GNU/Linux) + +iF4EAREIAAYFAk1rlucACgkQ9rSocE+em7wDLgD+M/GRZwfGk98S/4BzUc1r6sw0 +6Ermda9pjJXDiw1nNqsBAK7CTCk7+HaZaqrLnifMd5PMgKBh4EFaNjcvtBrU+1LU +=RgAS +-----END PGP SIGNATURE----- diff --git a/www-apps/froxlor/files/aliases b/www-apps/froxlor/files/aliases new file mode 100644 index 0000000..8ce8eb0 --- /dev/null +++ b/www-apps/froxlor/files/aliases @@ -0,0 +1,33 @@ +# Basic system aliases -- these MUST be present. +MAILER-DAEMON: postmaster +postmaster: root + +# General redirections for pseudo accounts. +adm: root +bin: root +daemon: root +exim: root +lp: root +mail: root +named: root +nobody: root +postfix: root + +# Well-known aliases -- these should be filled in! +root: +# operator: + +# Standard RFC2142 aliases +abuse: postmaster +ftp: root +hostmaster: root +news: usenet +noc: root +security: root +usenet: root +uucp: root +webmaster: root +www: webmaster + +# trap decode to catch security attacks +# decode: /dev/null diff --git a/www-apps/froxlor/files/domainkey.conf b/www-apps/froxlor/files/domainkey.conf new file mode 100644 index 0000000..b95216c --- /dev/null +++ b/www-apps/froxlor/files/domainkey.conf @@ -0,0 +1,3 @@ +smtpd_milters = inet:localhost:8891 +milter_macro_daemon_name = SIGNING +milter_default_action = accept diff --git a/www-apps/froxlor/files/froxlor.cron b/www-apps/froxlor/files/froxlor.cron new file mode 100644 index 0000000..3f211cf --- /dev/null +++ b/www-apps/froxlor/files/froxlor.cron @@ -0,0 +1,8 @@ +# +# Set PATH, otherwise restart-scripts won't find start-stop-daemon +# +PATH=/sbin:/bin:/usr/sbin:/usr/bin +# +# Regular cron jobs for the froxlor package +# +*/5 * * * * root /usr/lib/php5/bin/php -q /var/www/froxlor/scripts/froxlor_master_cronjob.php diff --git a/www-apps/froxlor/files/php-fcgi-starter b/www-apps/froxlor/files/php-fcgi-starter new file mode 100644 index 0000000..2389761 --- /dev/null +++ b/www-apps/froxlor/files/php-fcgi-starter @@ -0,0 +1,8 @@ +#!/bin/sh +PHPRC='/var/www/froxlor/php-fcgi-script/' +export PHPRC +PHP_FCGI_CHILDREN=0 +export PHP_FCGI_CHILDREN +PHP_FCGI_MAX_REQUESTS=250 +export PHP_FCGI_MAX_REQUESTS +exec /usr/bin/php-cgi -c '/var/www/froxlor/php-fcgi-script/' diff --git a/www-apps/froxlor/files/php.ini b/www-apps/froxlor/files/php.ini new file mode 100644 index 0000000..8d9704a --- /dev/null +++ b/www-apps/froxlor/files/php.ini @@ -0,0 +1,64 @@ +short_open_tag = On +asp_tags = Off +precision = 14 +output_buffering = 4096 +allow_call_time_pass_reference = Off +safe_mode = {SAFE_MODE} +safe_mode_gid = Off +safe_mode_include_dir = "{PEAR_DIR}" +safe_mode_allowed_env_vars = PHP_ +safe_mode_protected_env_vars = LD_LIBRARY_PATH +{OPEN_BASEDIR_C}open_basedir = "{OPEN_BASEDIR}" +disable_functions = exec,passthru,shell_exec,system,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate +disable_classes = +expose_php = Off +max_execution_time = 30 +max_input_time = 60 +memory_limit = 16M +post_max_size = 16M +error_reporting = E_ALL & ~E_NOTICE +display_errors = On +display_startup_errors = Off +log_errors = On +log_errors_max_len = 1024 +ignore_repeated_errors = Off +ignore_repeated_source = Off +report_memleaks = On +track_errors = Off +html_errors = Off +variables_order = "GPCS" +register_globals = Off +register_argc_argv = Off +gpc_order = "GPC" +magic_quotes_gpc = Off +magic_quotes_runtime = Off +magic_quotes_sybase = Off +include_path = ".:{PEAR_DIR}" +enable_dl = Off +file_uploads = On +upload_tmp_dir = "{TMP_DIR}" +upload_max_filesize = 32M +allow_url_fopen = Off +sendmail_path = "/usr/sbin/sendmail -t -f {CUSTOMER_EMAIL}" +session.save_handler = files +session.save_path = "{TMP_DIR}" +session.use_cookies = 1 +session.name = PHPSESSID +session.auto_start = 0 +session.cookie_lifetime = 0 +session.cookie_path = / +session.cookie_domain = +session.serialize_handler = php +session.gc_probability = 1 +session.gc_divisor = 1000 +session.gc_maxlifetime = 1440 +session.bug_compat_42 = 0 +session.bug_compat_warn = 1 +session.referer_check = +session.entropy_length = 16 +session.entropy_file = /dev/urandom +session.cache_limiter = nocache +session.cache_expire = 180 +session.use_trans_sid = 0 +suhosin.simulation = Off +suhosin.mail.protect = 1 diff --git a/www-apps/froxlor/froxlor-0.9.18.ebuild b/www-apps/froxlor/froxlor-0.9.18.ebuild new file mode 100644 index 0000000..fce4e26 --- /dev/null +++ b/www-apps/froxlor/froxlor-0.9.18.ebuild @@ -0,0 +1,1350 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="2" + +inherit eutils depend.php + +if [[ ${PV} == "9999" ]] ; then + EGIT_REPO_URI="git://git.froxlor.org/froxlor.git" + EGIT_PROJECT="froxlor" + inherit git + #KEYWORDS="" +else + RESTRICT="mirror" + SRC_URI="http://files.froxlor.org/releases/${P}.tar.gz" + KEYWORDS="~amd64 ~x86" +fi + +DESCRIPTION="A PHP-based webhosting-oriented control panel for servers." +HOMEPAGE="http://www.froxlor.org/" +LICENSE="GPL-2" +SLOT="0" +IUSE="aps autoresponder awstats bind domainkey dovecot fcgid ftpquota fpm lighttpd +log mailquota nginx pureftpd ssl +tickets" + +DEPEND=" + !www-apps/syscp + >=mail-mta/postfix-2.4[mysql,ssl=] + virtual/cron + virtual/mysql + >=dev-lang/php-5.2[bcmath,cli,ctype,filter,ftp,gd,mysql,nls,posix,session,simplexml,ssl=,tokenizer,xml,xsl,zlib] + || ( =dev-lang/php-5.3 ) + pureftpd? ( + net-ftp/pure-ftpd[mysql,ssl=] + ) + !pureftpd? ( + net-ftp/proftpd[mysql,ssl=] + ftpquota? ( net-ftp/proftpd[softquota] ) + ) + awstats? ( + www-misc/awstats + ( !lighttpd? ( + !nginx? ( + www-misc/awstats[apache2] + ) + ) + ) + ) + !awstats? ( + app-admin/webalizer + ) + bind? ( net-dns/bind + domainkey? ( mail-filter/dkim-milter ) + ) + ssl? ( dev-libs/openssl ) + lighttpd? ( www-servers/lighttpd[fastcgi,ssl=] + >=dev-lang/php-5.2[cgi] + ) + nginx? ( + www-servers/nginx[ssl=] + ) + !lighttpd? ( + ( !nginx? ( + www-servers/apache[ssl=] + dev-lang/php[apache2] + ) + ) + ) + fcgid? ( >=dev-lang/php-5.2[cgi] + || ( =dev-lang/php-5.3 ) + sys-auth/libnss-mysql + ( !lighttpd? ( + !nginx? ( + www-servers/apache[suexec] + www-apache/mod_fcgid + ) + ) + ) + ) + dovecot? ( >=net-mail/dovecot-1.2.0[mysql,ssl=] + >=mail-mta/postfix-2.4[dovecot-sasl] + ) + !dovecot? ( dev-libs/cyrus-sasl[crypt,mysql,ssl=] + net-libs/courier-authlib[crypt,mysql] + net-mail/courier-imap + >=mail-mta/postfix-2.4[sasl] + ) + aps? ( dev-lang/php[zip] ) + mailquota? ( >=mail-mta/postfix-2.4[vda] )" + +RDEPEND="${DEPEND}" + +# we need that to set the standardlanguage later +LANGS="bg ca cs de da en es fr hu it nl pl pt ru se sl zh_CN" +for X in ${LANGS} ; do + IUSE="${IUSE} linguas_${X}" +done + +# lets check user defined variables +FROXLOR_DOCROOT="${FROXLOR_DOCROOT:-/var/www}" + +need_php5_httpd +need_php5_cli + +S="${WORKDIR}/${PN}" + +src_unpack() { + if [[ ${PV} == "9999" ]] ; then + git_src_unpack + else + unpack ${A} + fi + cd "${S}" +} +pkg_setup() { + # Create the user and group that will own the Froxlor files + einfo "Creating froxlor user ..." + enewgroup froxlor 9995 + enewuser froxlor 9995 -1 ${FROXLOR_DOCROOT}/froxlor froxlor + + # Create the user and group that will run the FTPd + einfo "Creating froxlorftpd user ..." + enewgroup froxlorftpd 9996 + enewuser froxlorftpd 9996 -1 /var/customers/webs froxlorftpd + + # Create the user and group that will run the virtual MTA + einfo "Creating vmail user ..." + enewgroup vmail 9997 + enewuser vmail 9997 -1 /var/customers/mail vmail +} + +src_prepare() { + epatch_user + # Delete any mention of inserttask('4') if no Bind is used + if ! use bind ; then + find "${S}/" -type f -exec sed -e "s|inserttask('4');||g" -i {} \; + fi +} + +src_install() { + # set default language + local MYLANG="" + if use linguas_bg ; then + MYLANG="Bulgarian" + elif use linguas_ca ; then + MYLANG="Catalan" + elif use linguas_cs ; then + MYLANG="Czech" + elif use linguas_de ; then + MYLANG="Deutsch" + elif use linguas_da ; then + MYLANG="Danish" + elif use linguas_es ; then + MYLANG="Español" + elif use linguas_fr ; then + MYLANG="Français" + elif use linguas_hu ; then + MYLANG="Hungarian" + elif use linguas_it ; then + MYLANG="Italian" + elif use linguas_nl ; then + MYLANG="Dutch" + elif use linguas_pl ; then + MYLANG="Polski" + elif use linguas_pt ; then + MYLANG="Português" + elif use linguas_ru ; then + MYLANG="Russian" + elif use linguas_se ; then + MYLANG="Swedish" + elif use linguas_sl ; then + MYLANG="Slovak" + elif use linguas_zh_CN ; then + MYLANG="Chinese" + fi + + if [[ ${MYLANG} != '' ]] ; then + einfo "Setting standardlanguage to '${MYLANG}'" + sed -e "s|'standardlanguage', 'English'|'standardlanguage', '${MYLANG}'|g" -i "${S}/install/froxlor.sql" || die "Unable to change default language" + fi + + einfo "Setting 'lastguid' to '10000'" + sed -e "s|'lastguid', '9999'|'lastguid', '10000'|g" -i "${S}/install/froxlor.sql" || die "Unable to change lastguid" + + einfo "Setting 'vmail_uid' and 'vmail_gid' to '9997'" + sed -e "s|'vmail_uid', '2000'|'vmail_uid', '9997'|g" -i "${S}/install/froxlor.sql" || die "Unable to change uid for user vmail" + sed -e "s|'vmail_gid', '2000'|'vmail_gid', '9997'|g" -i "${S}/install/froxlor.sql" || die "Unable to change gid for user vmail" + + # set correct webserver reload + if use lighttpd; then + einfo "Switching settings to fit 'lighttpd'" + sed -e "s|/etc/init.d/apache reload|/etc/init.d/lighttpd restart|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver restart-command" + sed -e "s|'webserver', 'apache2'|'webserver', 'lighttpd'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver version" + sed -e "s|'apacheconf_vhost', '/etc/apache/vhosts.conf'|'apacheconf_vhost', '/etc/lighttpd/froxlor-vhosts.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver vhost directory" + sed -e "s|'apacheconf_diroptions', '/etc/apache/diroptions.conf'|'apacheconf_diroptions', '/etc/lighttpd/diroptions.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver diroptions file" + sed -e "s|'apacheconf_htpasswddir', '/etc/apache/htpasswd/'|'apacheconf_htpasswddir', '/etc/lighttpd/htpasswd/'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver htpasswd directory" + sed -e "s|'httpuser', 'www-data'|'httpuser', 'lighttpd'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver user" + sed -e "s|'httpgroup', 'www-data'|'httpgroup', 'lighttpd'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver group" + elif use nginx; then + einfo "Switching settings to fit 'nginx'" + sed -e "s|/etc/init.d/apache reload|/etc/init.d/nginx restart|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver restart-command" + sed -e "s|'webserver', 'apache2'|'webserver', 'nginx'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver version" + sed -e "s|'apacheconf_vhost', '/etc/apache/vhosts.conf'|'apacheconf_vhost', '/etc/nginx/froxlor-vhosts.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver vhost directory" + sed -e "s|'apacheconf_diroptions', '/etc/apache/diroptions.conf'|'apacheconf_diroptions', '/etc/nginx/diroptions.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver diroptions file" + sed -e "s|'apacheconf_htpasswddir', '/etc/apache/htpasswd/'|'apacheconf_htpasswddir', '/etc/nginx/htpasswd/'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver htpasswd directory" + sed -e "s|'httpuser', 'www-data'|'httpuser', 'nginx'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver user" + sed -e "s|'httpgroup', 'www-data'|'httpgroup', 'nginx'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver group" + else + einfo "Switching settings to fit 'apache2'" + sed -e "s|/etc/init.d/apache reload|/etc/init.d/apache2 reload|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver restart-command" + sed -e "s|'apacheconf_vhost', '/etc/apache/vhosts.conf'|'apacheconf_vhost', '/etc/apache2/vhosts.d/99_froxlor-vhosts.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver vhost directory" + sed -e "s|'apacheconf_diroptions', '/etc/apache/diroptions.conf'|'apacheconf_diroptions', '/etc/apache2/diroptions.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver diroptions file" + sed -e "s|'apacheconf_htpasswddir', '/etc/apache/htpasswd/'|'apacheconf_htpasswddir', '/etc/apache2/htpasswd/'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver htpasswd directory" + sed -e "s|'httpuser', 'www-data'|'httpuser', 'apache'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver user" + sed -e "s|'httpgroup', 'www-data'|'httpgroup', 'apache'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver group" + fi + + if use fcgid && ! use lighttpd && ! use nginx ; then + einfo "Switching 'fcgid' to 'On'" + sed -e "s|'mod_fcgid', '0'|'mod_fcgid', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set fcgid to 'On'" + + einfo "Setting wrapper to FCGIWrapper" + sed -e "s|'mod_fcgid_wrapper', '0'|'mod_fcgid_wrapper', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set fcgi-wrapper to 'FCGIWrapper'" + + einfo "Creating tmp-directory" + dodir "/var/customers/tmp" + + ewarn "You have to remove the '-D PHP5' entry from /etc/conf.d/apache2 if it exists!" + fi + + if use fpm ; then + einfo "Switching 'fpm' to 'On'" + sed -e "s|'phpfpm', 'enabled', '0'|'phpfpm', 'enabled', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set fpm to 'On'" + + einfo "Setting configdir for fpm" + sed -e "s|'phpfpm', 'configdir', '/etc/php-fpm.d/'|'phpfpm', 'configdir', '/etc/php/fpm-php5.3/fpm.d/'|g" -i "${S}/install/froxlor.sql" || die "Unable to set configdir for 'fpm'" + + einfo "Enable custom configdir for fpm" + sed -e "s|;include=/etc/php/fpm-php5.3/fpm.d/*.conf|include=/etc/php/fpm-php5.3/fpm.d/*.conf|g" -i "/etc/php/fpm-php5.3/php-fpm.conf" || die "Unable to set custom configdir for 'fpm'" + + einfo "Checking for directory /etc/php/fpm-php5.3/fpm.d/" + if [ ! -d /etc/php/fpm-php5.3/fpm.d/ ]; then + didir "/etc/php/fpm-php5.3/fpm.d/" + fi + + einfo "Creating tmp-directory" + dodir "/var/customers/tmp" + fi + + # If Bind will not used, change the reload path for it + if ! use bind ; then + einfo "Switching 'bind' to 'Off'" + sed -e 's|/etc/init.d/named reload|/bin/true|g' -i "${S}/install/froxlor.sql" || die "Unable to change reload path for Bind" + fi + + # default value is logging_enabled='1' + if ! use log ; then + einfo "Switching 'log' to 'Off'" + sed -e "s|'logger', 'enabled', '1'|'logger', 'enabled', '0'|g" -i "${S}/install/froxlor.sql" || die "Unable to set logging to 'Off'" + # fix menu + sed -e "s|'10', 'change_serversettings'|'10', 'logger.enabled'|g" -i "${S}/install/froxlor.sql" || die "Unable to fix logging menu-entry" + fi + + # default value is tickets_enabled='1' + if ! use tickets ; then + einfo "Switching 'tickets' to 'Off'" + sed -e "s|'ticket', 'enabled', '1'|'ticket', 'enabled', '0'|g" -i "${S}/install/froxlor.sql" || die "Unable to set ticketsystem to 'Off'" + fi + + # default value is mailquota='0' + if use mailquota ; then + einfo "Switching 'mailquota' to 'On'" + sed -e "s|'mail_quota_enabled', '0'|'mail_quota_enabled', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set mailquota to 'On'" + fi + + # default value is autoresponder='0' + if use autoresponder ; then + einfo "Switching 'autoresponder' to 'On'" + sed -e "s|'autoresponder_active', '0'|'autoresponder_active', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set autoresponder to 'On'" + # fix menu + sed -e "s|40, 'autoresponder.autoresponder_active'|40, 'mails'|g" -i "${S}/install/froxlor.sql" || die "Unable to fix autoresponder menu-entry" + fi + + # default value is dkim_enabled='0' + if use domainkey && use bind ; then + einfo "Switching 'domainkey' to 'On'" + sed -e "s|'use_dkim', '0'|'use_dkim', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set domainkey to 'On'" + + einfo "Setting dkim-path to gentoo value" + sed -e "s|'dkim_prefix', '/etc/postfix/dkim/'|'dkim_prefix', '/etc/mail/dkim-filter/'|g" -i "${S}/install/froxlor.sql" || die "Unable to set domainkey prefix" + fi + + # default value is aps_enabled='0' + if use aps ; then + einfo "Switching 'APS' to 'On'" + sed -e "s|'aps_active', '0'|'aps_active', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set aps to 'On'" + # fix menu + sed -e "s|'admin_aps.nourl', 45, 'aps.aps_active'|'admin_aps.nourl', 45, 'can_manage_aps_packages'|g" -i "${S}/install/froxlor.sql" || die "Unable to fix aps admin-menu-entry" + sed -e "s|'customer_aps.nourl', 50, 'aps.aps_active'|'customer_aps.nourl', 50, 'phpenabled'|g" -i "${S}/install/froxlor.sql" || die "Unable to fix aps customer-menu-entry" + + # if aps is used we enable required features in the php-cli php.ini + ewarn + ewarn "Please run the following command in your shell to change the php-cli php.ini file for APS" + ewarn + ewarn "sed -ie \"s|allow_url_fopen = Off|allow_url_fopen = On|g\" -i \"/etc/php/cli-php5/php.ini\"" + ewarn + fi + + # default value is ssl_enabled='1' + if ! use ssl ; then + einfo "Switching 'SSL' to 'Off'" + sed -e "s|'use_ssl','1'|'use_ssl','0'|g" -i "${S}/install/froxlor.sql" || die "Unable to set ssl to 'Off'" + fi + + if use awstats ; then + einfo "Switching from 'Webalizer' to 'AWStats'" + sed -e "s|'webalizer_quiet', '2'|'webalizer_quiet', '0'|g" -i "${S}/install/froxlor.sql" + sed -e "s|'awstats_enabled', '0'|'awstats_enabled', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to enable AWStats" + fi + + if use pureftpd ; then + einfo "Switching from 'ProFTPd' to 'Pure-FTPd'" + sed -e "s|'ftpserver', 'proftpd'|'ftpserver', 'pureftpd'|g" -i "${S}/install/froxlor.sql" + fi + + # Install the Froxlor files + einfo "Installing Froxlor files" + dodir ${FROXLOR_DOCROOT} + cp -Rf "${S}/" "${D}${FROXLOR_DOCROOT}/" || die "Installation of the Froxlor files failed" + + # Fix the permissions for the Froxlor files + einfo "Fixing permission of Froxlor files" + if use lighttpd ; then + fowners -R froxlor:lighttpd ${FROXLOR_DOCROOT}/froxlor + elif use nginx ; then + fowners -R froxlor:nginx ${FROXLOR_DOCROOT}/froxlor + else + fowners -R froxlor:apache ${FROXLOR_DOCROOT}/froxlor + fi + if use fcgid ; then + if ! use lighttpd ; then + fowners -R froxlor:froxlor ${FROXLOR_DOCROOT}/froxlor + else + einfo "lighttpd overwrites fcgid USE-flag!" + #fowners froxlor:lighttpd ${FROXLOR_DOCROOT}/froxlor + fi + fperms 0750 ${FROXLOR_DOCROOT}/froxlor + elif use fpm ; then + fowners -R froxlor:froxlor ${FROXLOR_DOCROOT}/froxlor + fperms 0750 ${FROXLOR_DOCROOT}/froxlor + else + if use lighttpd ; then + fowners -R froxlor:lighttpd ${FROXLOR_DOCROOT}/froxlor/{temp,packages} + elif use nginx ; then + fowners -R froxlor:nginx ${FROXLOR_DOCROOT}/froxlor/{temp,packages} + else + fowners -R froxlor:apache ${FROXLOR_DOCROOT}/froxlor/{temp,packages} + fi + fi + fperms 0775 ${FROXLOR_DOCROOT}/froxlor/{temp,packages} + + # Create the main directories for customer data + dodir /var/customers/webs + dodir /var/customers/mail + fowners vmail:vmail /var/customers/mail + fperms 0750 /var/customers/mail + dodir /var/customers/logs + + dodir /usr/share/${PN} + cp "${FILESDIR}/domainkey.conf" "${D}/usr/share/${PN}" + cp "${FILESDIR}/froxlor.cron" "${D}/usr/share/${PN}" + cp "${FILESDIR}/php-fcgi-starter" "${D}/usr/share/${PN}" + cp "${FILESDIR}/php.ini" "${D}/usr/share/${PN}" + cp "${FILESDIR}/aliases" "${D}/usr/share/${PN}" +} + +pkg_postinst() { + # we need to check if this is going to be an update or a fresh install! + if [[ -f "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" ]] ; then + elog "Froxlor is already installed on this system!" + elog + elog "In this case 'emerge --config' mustn't be executed!" + elog "Any configurationfiles will stay untouched!" + elog + elog "Froxlor will update the database when you open" + elog "it in your browser the first time after the update-process" + sleep 2 + elif [[ -f "${ROOT}${FROXLOR_DOCROOT}/syscp/lib/userdata.inc.php" ]] ; then + elog "This seems to be an upgrade from syscp" + elog "please move ${FROXLOR_DOCROOT}/syscp/lib/userdata.inc.php to" + elog "${FROXLOR_DOCROOT}/froxlor/lib/" + elog "and don't forget to copy "${ROOT}/usr/share/${PN}/froxlor.cron"" + elog "to /etc/cron.d/froxlor and remove /etc/cron.d/syscp" + else + elog "Please run 'emerge --config =${PF}' to continue with" + elog "the basic setup of Gentoo-Froxlor, *after* you have" + elog "setup your MySQL databases root user and password" + elog "like the MySQL ebuild tells you to do." + fi +} + +pkg_config() { + local proceedyesno1 + local servername + local serverip + local mysqlhost + local mysqlaccesshost + local mysqlrootuser + local mysqlrootpw1 + local mysqlrootpw2 + local mysqlrootpw + local mysqldbname + local mysqlunprivuser + local mysqlunprivpw1 + local mysqlunprivpw2 + local mysqlunprivpw + local adminuser + local adminpw1 + local adminpw2 + local adminpw + local proceedyesno2 + + ewarn "Gentoo-Froxlor Basic Configuration" + echo + einfo "This will setup Gentoo-Froxlor on your system, it will create and" + einfo "populate the MySQL database, create and chmod the needed files" + einfo "correctly and configure all services to work out-of-the-box" + einfo "with Gentoo-Froxlor, using a sane default configuration, and" + einfo "start them, along with creating the correct Gentoo-Froxlor Apache" + einfo "VirtualHost for you." + einfo "CAUTION: this will backup and then replace your services" + einfo "configuration and restart them!" + echo + einfo "Do you want to proceed? [Y/N]" + echo + read -rp " > " proceedyesno1 ; echo + if [[ ${proceedyesno1} == "Y" ]] || [[ ${proceedyesno1} == "y" ]] || [[ ${proceedyesno1} == "Yes" ]] || [[ ${proceedyesno1} == "yes" ]] ; then + echo + else + echo + die "User abort: not proceeding!" + fi + einfo "Enter the domain under wich Froxlor shall be reached, this normally" + einfo "is the FQDN (Fully Qualified Domain Name) of your system." + einfo "If you don't know the FQDN of your system, execute 'hostname -f'." + einfo "This installscript will try to guess your FQDN automatically if" + einfo "you leave this field blank, setting it to the output of 'hostname -f'." + echo + read -rp " > " servername ; echo + echo + if [[ ${servername} == "" ]] ; then + servername=`hostname -f` + fi + einfo "Enter the IP address of your system, under wich all" + einfo "websites shall then be reached. This must be the same" + einfo "IP address the domain you inserted above points to." + einfo "You *must* set this to your correct IP address." + echo + read -rp " > " serverip ; echo + echo + if [[ ${serverip} == "" ]] ; then + die "Abort: need correct IP address!" + fi + einfo "Enter the IP address of the MySQL server, if the MySQL" + einfo "server is on the same machine, enter 'localhost' or" + einfo "simply leave the field blank." + echo + read -rp " > " mysqlhost ; echo + echo + if [[ ${mysqlhost} == "" ]] ; then + mysqlhost="localhost" + fi + if [[ ${mysqlhost} == "localhost" ]] ; then + mysqlaccesshost="localhost" + else + mysqlaccesshost="${serverip}" + fi + einfo "Enter the username of the MySQL root user." + einfo "The default is 'root'." + echo + read -rp " > " mysqlrootuser ; echo + echo + if [[ ${mysqlrootuser} == "" ]] ; then + mysqlrootuser="root" + fi + einfo "Enter the password of the MySQL root user." + echo + read -rsp " > " mysqlrootpw1 ; echo + echo + if [[ ${mysqlrootpw1} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + einfo "Confirm the password of the MySQL root user." + echo + read -rsp " > " mysqlrootpw2 ; echo + echo + if [[ ${mysqlrootpw2} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + if [[ ${mysqlrootpw1} != ${mysqlrootpw2} ]] ; then + die "Abort: the two passwords don't match!" + else + mysqlrootpw="${mysqlrootpw1}" + fi + einfo "Enter the name of the database you want to" + einfo "use for Froxlor. The default is 'froxlor'." + einfo "CAUTION: any database with that name will" + einfo "be dropped!" + echo + read -rp " > " mysqldbname ; echo + echo + if [[ ${mysqldbname} == "" ]] ; then + mysqldbname="froxlor" + fi + einfo "Enter the username of the unprivileged" + einfo "MySQL user you want Froxlor to use." + einfo "The default is 'froxlor'." + einfo "CAUTION: any user with that name will" + einfo "be deleted!" + echo + read -rp " > " mysqlunprivuser ; echo + echo + if [[ ${mysqlunprivuser} == "" ]] ; then + mysqlunprivuser="froxlor" + fi + einfo "Enter the password of the unprivileged" + einfo "MySQL user." + echo + read -rsp " > " mysqlunprivpw1 ; echo + echo + if [[ ${mysqlunprivpw1} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + einfo "Confirm the password of the unprivileged" + einfo "MySQL user." + echo + read -rsp " > " mysqlunprivpw2 ; echo + echo + if [[ ${mysqlunprivpw2} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + if [[ ${mysqlunprivpw1} != ${mysqlunprivpw2} ]] ; then + die "Abort: the two passwords don't match!" + else + mysqlunprivpw="${mysqlunprivpw1}" + fi + einfo "Enter the username of the admin user you" + einfo "want in your Froxlor panel." + einfo "Default is 'admin'." + echo + read -rp " > " adminuser ; echo + echo + if [[ ${adminuser} == "" ]] ; then + adminuser="admin" + fi + einfo "Enter the password of the Froxlor admin user." + echo + read -rsp " > " adminpw1 ; echo + echo + if [[ ${adminpw1} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + einfo "Confirm the password of the Froxlor admin user." + echo + read -rsp " > " adminpw2 ; echo + echo + if [[ ${adminpw2} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + if [[ ${adminpw1} != ${adminpw2} ]] ; then + die "Abort: the two passwords don't match!" + else + adminpw="${adminpw1}" + fi + + einfo "Adding MySQL server to 'default' runlevel ..." + rc-update add mysql default + + einfo "(Re)Starting MySQL server ..." + "${ROOT}/etc/init.d/mysql" restart + + einfo "Creating temporary work directory ..." + rm -Rf "${ROOT}/tmp/froxlor-install-by-emerge" + mkdir -p "${ROOT}/tmp/froxlor-install-by-emerge" + chown root:0 "${ROOT}/tmp/froxlor-install-by-emerge" + chmod 0700 "${ROOT}/tmp/froxlor-install-by-emerge" + + einfo "Preparing SQL database files ..." + cp -f "${ROOT}${FROXLOR_DOCROOT}/froxlor/install/froxlor.sql" "${ROOT}/tmp/froxlor-install-by-emerge/" + chown root:0 "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + chmod 0600 "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + sed -e "s|SERVERNAME|${servername}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + sed -e "s|SERVERIP|${serverip}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + sed -e "s|'mysql_access_host', 'localhost'|'mysql_access_host', '${mysqlaccesshost}'|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + + touch "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + echo "DROP DATABASE IF EXISTS MYSQL_DATABASE_NAME; +CREATE DATABASE MYSQL_DATABASE_NAME; +GRANT ALL PRIVILEGES ON MYSQL_DATABASE_NAME.* TO MYSQL_UNPRIV_USER@MYSQL_ACCESS_HOST IDENTIFIED BY 'password'; +SET PASSWORD FOR MYSQL_UNPRIV_USER@MYSQL_ACCESS_HOST = PASSWORD('MYSQL_UNPRIV_PASSWORD'); +FLUSH PRIVILEGES;" > "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + + sed -e "s|MYSQL_ACCESS_HOST|${mysqlaccesshost}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + sed -e "s|MYSQL_UNPRIV_USER|${mysqlunprivuser}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + sed -e "s|MYSQL_UNPRIV_PASSWORD|${mysqlunprivpw}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + sed -e "s|MYSQL_DATABASE_NAME|${mysqldbname}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + + einfo "Creating Froxlor database ..." + mysql -u ${mysqlrootuser} -p${mysqlrootpw} < "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + + einfo "Installing SQL database files ..." + mysql -u ${mysqlrootuser} -p${mysqlrootpw} ${mysqldbname} < "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + + einfo "Adding system ip/port to database" + touch "${ROOT}/tmp/froxlor-install-by-emerge/ipandport.sql" + cat > "${ROOT}/tmp/froxlor-install-by-emerge/ipandport.sql" < "${ROOT}/tmp/froxlor-install-by-emerge/admin.sql" <" > "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + + if ! use fcgid ; then + if ! use lighttpd ; then + chown froxlor:apache "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + else + chown froxlor:lighttpd "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + fi + else + if ! use lighttpd ; then + chown froxlor:froxlor "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + else + # this stays as lighty doesn't use fcgid + chown froxlor:lighttpd "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + fi + fi + + if use ssl ; then + einfo "Creating needed SSL certificates ..." + einfo "Please enter the correct input when it's requested." + ewarn + ewarn "ATTENTION: when you're requested to enter a" + ewarn "'Common Name' enter ${servername} ." + ewarn + + # Create the directories where we'll store our SSL + # certificates and set secure permissions on them + mkdir -p "${ROOT}/etc/ssl/server" + chown root:0 "${ROOT}/etc/ssl/server" + chmod 0700 "${ROOT}/etc/ssl/server" + + # We first generate our Private Key + openssl genrsa -des3 -out "${ROOT}/etc/ssl/server/${servername}.key" 2048 + + # Now we generate our CSR (Certificate Signing Request) + openssl req -new -key "${ROOT}/etc/ssl/server/${servername}.key" -out "${ROOT}/etc/ssl/server/${servername}.csr" + + # Create an unencrypted key, to avoid having to always enter + # the passphrase when a service using it is restarted (eg. Apache) + cp -f "${ROOT}/etc/ssl/server/${servername}.key" "${ROOT}/etc/ssl/server/${servername}.key.orig" + openssl rsa -in "${ROOT}/etc/ssl/server/${servername}.key.orig" -out "${ROOT}/etc/ssl/server/${servername}.key" + + einfo "You can now submit ${ROOT}/etc/ssl/server/${servername}.csr" + einfo "to an official CA (Certification Authority) to be" + einfo "signed (with costs) or you can sign it yourself (free)." + einfo "For more informations regarding SSL please visit:" + einfo "http://httpd.apache.org/docs/2.0/ssl/ssl_intro.html" + + echo + einfo "Do you want to self-sign your certificate? [Y/N]" + echo + read -rp " > " proceedyesno2 ; echo + if [[ ${proceedyesno2} == "Y" ]] || [[ ${proceedyesno2} == "y" ]] || [[ ${proceedyesno2} == "Yes" ]] || [[ ${proceedyesno2} == "yes" ]] ; then + echo + # We now generate a self-signed certificate that will + # be valid for 365 days + openssl x509 -req -days 365 -in "${ROOT}/etc/ssl/server/${servername}.csr" -signkey "${ROOT}/etc/ssl/server/${servername}.key" -out "${ROOT}/etc/ssl/server/${servername}.crt" + + # We now create a file that contains both the Private Key + # and the signed certificate, this is needed for Courier + cat "${ROOT}/etc/ssl/server/${servername}.crt" "${ROOT}/etc/ssl/server/${servername}.key" > "${ROOT}/etc/ssl/server/${servername}.pem" + else + einfo "Note: if you let your certificate be signed by an official" + einfo "CA please be sure to copy the certificate they gave you to" + einfo "${ROOT}/etc/ssl/server/${servername}.crt before starting" + einfo "and using any of the SSL enabled services." + echo + einfo "You'll also need to create a file that contains both the" + einfo "Private Key and the signed certificate, this is needed for" + einfo "Courier to work correctly." + einfo "You can do this with the following command:" + einfo "cat \"${ROOT}/etc/ssl/server/${servername}.crt\" \"${ROOT}/etc/ssl/server/${servername}.key\" > \"${ROOT}/etc/ssl/server/${servername}.pem\"" + echo + einfo "Additionally, don't forget to set the correct file permissions" + einfo "on your SSL files, you can do this with the following commands:" + einfo "chown root:0 \"${ROOT}/etc/ssl/server/${servername}.\"*" + einfo "chmod 0400 \"${ROOT}/etc/ssl/server/${servername}.\"*" + fi + + # Set secure permissions for our SSL files + chown root:0 "${ROOT}/etc/ssl/server/${servername}."* + chmod 0400 "${ROOT}/etc/ssl/server/${servername}."* + fi + + einfo "Writing Gentoo-Froxlor vhost configuration ..." + if use lighttpd ; then + VHOST_CONFIG="${ROOT}/etc/lighttpd/froxlor-vhosts.conf" + elif use nginx ; then + VHOST_CONFIG="${ROOT}/etc/nginx/froxlor-vhosts.conf" + else + VHOST_CONFIG="${ROOT}/etc/apache2/vhosts.d/99_froxlor-vhosts.conf" + fi + + # do stuff with the config file + rm -f "${VHOST_CONFIG}" + touch "${VHOST_CONFIG}" + chown root:0 "${VHOST_CONFIG}" + chmod 0600 "${VHOST_CONFIG}" + + if use lighttpd ; then + einfo "Configuring lighttpd" + rm -f "${ROOT}/etc/lighttpd/lighttpd.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/lighttpd/etc_lighttpd.conf" "${ROOT}/etc/lighttpd/lighttpd.conf" + sed -e "s||${servername}|g" -i "${ROOT}/etc/lighttpd/lighttpd.conf" + sed -e "s||${serverip}|g" -i "${ROOT}/etc/lighttpd/lighttpd.conf" + + touch "${VHOST_CONFIG}" + echo -e "\ninclude \"froxlor-vhosts.conf\"" >> "${ROOT}/etc/lighttpd/lighttpd.conf" + + echo -e "# Froxlor default vhost +\$HTTP[\"host\"] == \"${servername}\" { + server.document-root = var.basedir + \"/froxlor\" + server.name = \"${servername}\"" > "${VHOST_CONFIG}" + + if use ssl ; then + echo -e " + \$HTTP[\"scheme\"] == \"http\" { + url.redirect = ( \"^/(.*)\" => \"https://${servername}/$1\" ) + }" >> "${VHOST_CONFIG}" + fi + + if use fpm ; then + + echo -e ";PHP-FPM configuration for \"${servername}\" +[${servername}] +listen = /var/run/lighttpd/${servername}-php-fpm.socket +listen.owner = froxlor +listen.group = froxlor +listen.mode = 0666 + +user = froxlor +group = froxlor + +pm = static +pm.max_children = 1 +pm.max_requests = 0 + +env[TMP] = /tmp/ +env[TMPDIR] = /tmp/ +env[TEMP] = /tmp/ + +php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f admin@${servername}" > "${ROOT}/etc/php/fpm-php5.3/fpm.d/${servername}.conf" + + echo -e "\n fastcgi.server = ( +\".php\" => ( + \"localhost\" => ( + \"socket\" => \"/var/run/lighttpd/${servername}-php-fpm.socket\", + \"check-local\" => \"enable\", + \"disable-time\" => 1 + ) +) +)" >> "${VHOST_CONFIG}" + + dodir "/var/run/lighttpd" + fi + + echo -e " +}" >> "${VHOST_CONFIG}" + + if use ssl ; then + echo -e "\n\$SERVER[\"socket\"] == \"${serverip}:443\" { +ssl.engine = \"enable\" +ssl.pemfile = \"${ROOT}etc/ssl/server/${servername}.pem\" +ssl.ca-file = \"${ROOT}etc/ssl/server/${servername}.pem\" +}" >> "${ROOT}/etc/lighttpd/lighttpd.conf" + + fi + + elif use nginx ; then + einfo "Configuring nginx" + rm -f "${ROOT}/etc/nginx/nginx.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/nginx/etc_nginx_nginx.conf" "${ROOT}/etc/nginx/nginx.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/nginx/etc_init.d_php-fcgi" "${ROOT}/etc/init.d/php-fcgi" + chmod u+x "${ROOT}/etc/init.d/php-fcgi" + + touch "${VHOST_CONFIG}" + + echo -e "# Froxlor default vhost +server_name ${servername}; +access_log /var/log/nginx/access.log; +root "${ROOT}${FROXLOR_DOCROOT}"; +location / { + index index.php index.html index.htm; +}" > "${VHOST_CONFIG}" + + if use ssl ; then + echo -e "\n ssl on; +ssl_certificate "${ROOT}etc/ssl/server/${servername}.pem;" +ssl_certificate_key "${ROOT}etc/ssl/server/${servername}.pem;"" >> "${VHOST_CONFIG}" + fi + + echo -e "\nlocation ~ \.php$ { +fastcgi_index index.php; +include /etc/nginx/fastcgi_params;" >> "${VHOST_CONFIG}" + + if use ssl ; then + echo -e "fastcgi_param HTTPS on;" >> "${VHOST_CONFIG}" + fi + + echo -e "fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;" >> "${VHOST_CONFIG}" + + if use fpm ; then + + echo -e ";PHP-FPM configuration for \"${servername}\" +[${servername}] +listen = /var/run/nginx/${servername}-php-fpm.socket +listen.owner = froxlor +listen.group = froxlor +listen.mode = 0666 + +user = froxlor +group = froxlor + +pm = static +pm.max_children = 1 +pm.max_requests = 0 + +env[TMP] = /tmp/ +env[TMPDIR] = /tmp/ +env[TEMP] = /tmp/ + +php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f admin@${servername}" > "${ROOT}/etc/php/fpm-php5.3/fpm.d/${servername}.conf" + + echo -e "\n fastcgi_pass unix: /var/run/nginx/${servername}-php-fpm.socket;" >> "${VHOST_CONFIG}" + + dodir "/var/run/nginx" + fi + + echo -e "\n} +}" >> "${VHOST_CONFIG}" + + else + einfo "Configuring apache2" + if use fcgid ; then + # create php-starter file + FCGIDPATH="${ROOT}${FROXLOR_DOCROOT}/php-fcgi-scripts/froxlor.panel/${servername}" + mkdir -p "${FCGIDPATH}/php-fcgi-script" + mkdir -p "${FCGIDPATH}/tmp" + chmod 0750 "${FCGIDPATH}/tmp" + touch "${FCGIDPATH}/php-fcgi-starter" + cp "${ROOT}/usr/share/${PN}/php-fcgi-starter" "${FCGIDPATH}/php-fcgi-starter" + chmod 0750 "${FCGIDPATH}/php-fcgi-starter" + touch "${FCGIDPATH}/php.ini" + cp "${ROOT}/usr/share/${PN}/php.ini" "${FCGIDPATH}/php.ini" + chown froxlor:froxlor -R "${FCGIDPATH}/php-fcgi-script" || die "Unable to fix owner for php-fcgi-script folder" + chattr +i "${FCGIDPATH}/php-fcgi-starter" + fi + + if use ssl ; then + echo "# Gentoo-Froxlor SSL-enabled VirtualHost + + + + DocumentRoot \"${FROXLOR_DOCROOT}/froxlor\" + ServerName ${servername}" >> "${VHOST_CONFIG}" + + echo " ErrorLog /var/log/apache2/froxlor_ssl_error_log + + TransferLog /var/log/apache2/froxlor_ssl_access_log + + SSLEngine on + SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL + SSLCertificateFile /etc/ssl/server/${servername}.crt + SSLCertificateKeyFile /etc/ssl/server/${servername}.key + + SSLOptions +StdEnvVars + + + SetEnvIf User-Agent \".*MSIE.*\" nokeepalive ssl-unclean-shutdown \\ + downgrade-1.0 force-response-1.0 + + + CustomLog /var/log/apache2/froxlor_ssl_request_log \\ + \"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \\\"%r\\\" %b\" + " >> "${VHOST_CONFIG}" + + if use fcgid ; then + echo "SuexecUserGroup \"froxlor\" \"froxlor\" + + AddHandler fcgid-script .php + FCGIWrapper ${FROXLOR_DOCROOT}/php-fcgi-scripts/froxlor.panel/${servername}/php-fcgi-starter .php + Options +ExecCGI +" >> "${VHOST_CONFIG}" + + else + echo " + Order allow,deny + allow from all + " >> "${VHOST_CONFIG}" + fi + + echo " + + + + +# Redirect to the SSL-enabled Gentoo-Froxlor vhost + + RedirectPermanent / https://${servername}/index.php +" >> "${VHOST_CONFIG}" + + else + + echo "# Gentoo-Froxlor VirtualHost + + DocumentRoot \"${FROXLOR_DOCROOT}/froxlor\" + ServerName ${servername}" >> "${VHOST_CONFIG}" + + if use fcgid ; then + echo "SuexecUserGroup \"froxlor\" \"froxlor\" + + AddHandler fcgid-script .php + FCGIWrapper ${FROXLOR_DOCROOT}/php-fcgi-scripts/froxlor.panel/${servername}/php-fcgi-starter .php + Options +ExecCGI +" >> "${VHOST_CONFIG}" + + else + echo " + Order allow,deny + allow from all + " >> "${VHOST_CONFIG}" + fi + + echo "" >> "${VHOST_CONFIG}" + fi + fi + + if ! use lighttpd && ! use nginx ; then + einfo "Fix general Apache configuration to work with Gentoo-Froxlor ..." + sed -e "s|^\#ServerName localhost.*|ServerName ${servername}|g" -i "${ROOT}/etc/apache2/httpd.conf" || ewarn "Please make sure that the ServerName directive in ${ROOT}/etc/apache${USE_APACHE2}/httpd.conf is set to a valid value!" + sed -e "s|^ServerAdmin root\@localhost.*|ServerAdmin root\@${servername}|g" -i "${ROOT}/etc/apache2/httpd.conf" || ewarn "Please make sure that the ServerAdmin directive in ${ROOT}/etc/apache${USE_APACHE2}/httpd.conf is set to a valid value!" + sed -e "s|\*:80|${serverip}:80|g" -i "${ROOT}/etc/apache2/vhosts.d/00_default_vhost.conf" || ewarn "Please make sure the NameVirtualHost and VirtualHost directives in ${ROOT}/etc/apache${USE_APACHE2}/vhosts.d/00_default_vhost.conf are set to the Gentoo-Froxlor IP and Port 80!" + fi + + if ! use lighttpd && ! use nginx ; then + local DFCGID="" + + if use fcgid ; then + DFCGID="-D FCGID " + else + DFCGID="" + fi + + # this is maybe automatically added to APACHE2_OPTS + if [[ ${DFCGID} != "" ]] ; then + einfo "Attempting to add FCGID to ${ROOT}/etc/conf.d/apache2 ..." + sed -e "s|^APACHE2_OPTS=\"|APACHE2_OPTS=\"${DFCGID}|g" -i "${ROOT}/etc/conf.d/apache2" || ewarn "Unable to change APACHE2_OPTS in ${ROOT}/etc/conf.d/apache2, please change it manually to add '${DFCGID}'" + fi + fi + + # NSS-MySQL preparations + if use fcgid ; then + einfo "Modifying nsswitch.conf to use MySQL ..." + sed -e "s|compat|compat mysql|g" -i "${ROOT}/etc/nsswitch.conf" + rm -f "${ROOT}/etc/libnss-mysql.cfg" + rm -f "${ROOT}/etc/libnss-mysql-root.cfg" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/libnss/etc_libnss-mysql.cfg" "${ROOT}/etc/libnss-mysql.cfg" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/libnss/etc_libnss-mysql-root.cfg" "${ROOT}/etc/libnss-mysql-root.cfg" + + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/libnss-mysql.cfg" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/libnss-mysql.cfg" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/libnss-mysql.cfg" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/libnss-mysql.cfg" + + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/libnss-mysql-root.cfg" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/libnss-mysql-root.cfg" + fi + + if ! use pureftpd ; then + einfo "Configuring ProFTPd ..." + rm -f "${ROOT}/etc/proftpd/proftpd.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/proftpd/etc_proftpd_proftpd.conf" "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${servername}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + if use ssl ; then + sed -e "s|#||g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSEngine|TLSEngine|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSLog|TLSLog|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSProtocol|TLSProtocol|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSTimeoutHandshake|TLSTimeoutHandshake|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSOptions|TLSOptions|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSRSACertificateFile|TLSRSACertificateFile|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSRSACertificateKeyFile|TLSRSACertificateKeyFile|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSVerifyClient|TLSVerifyClient|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSRequired|TLSRequired|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#||g" -i "${ROOT}/etc/proftpd/proftpd.conf" + fi + if ! use ftpquota ; then + sed -e "s|QuotaEngine|#QuotaEngine|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaShowQuotas|#QuotaShowQuotas|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaDisplayUnits|#QuotaDisplayUnits|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaLock|#QuotaLock|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaLimitTable|#QuotaLimitTable|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaTallyTable|#QuotaTallyTable|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|SQLNamedQuery|#SQLNamedQuery|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + fi + if ! has_version "net-ftp/proftpd[ipv6]"; then + sed -e "s|UseIPv6|#UseIPv6|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + fi + chown root:0 "${ROOT}/etc/proftpd/proftpd.conf" + chmod 0600 "${ROOT}/etc/proftpd/proftpd.conf" + else + einfo "Configuring Pure-FTPd ..." + rm -f "${ROOT}/etc/conf.d/pure-ftpd" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/pureftpd/etc_conf.d_pure-ftpd" "${ROOT}/etc/conf.d/pure-ftpd" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/pureftpd/etc_pureftpd-mysql.conf" "${ROOT}/etc/pureftpd-mysql.conf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/pureftpd-mysql.conf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/pureftpd-mysql.conf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/pureftpd-mysql.conf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/pureftpd-mysql.conf" + chown root:0 "${ROOT}/etc/conf.d/pure-ftpd" + chmod 0644 "${ROOT}/etc/conf.d/pure-ftpd" + chown root:0 "${ROOT}/etc/pureftpd-mysql.conf" + chmod 0600 "${ROOT}/etc/pureftpd-mysql.conf" + fi + + einfo "Configuring Gentoo-Froxlor cronjob ..." + insinto "/etc/cron.d" + newins "${ROOT}/usr/share/${PN}/froxlor.cron" froxlor + + if ! use dovecot ; then + einfo "Configuring Courier-IMAP ..." + rm -f "${ROOT}/etc/courier/authlib/authdaemonrc" + rm -f "${ROOT}/etc/courier/authlib/authmysqlrc" + rm -f "${ROOT}/etc/courier-imap/pop3d" + rm -f "${ROOT}/etc/courier-imap/imapd" + rm -f "${ROOT}/etc/courier-imap/pop3d-ssl" + rm -f "${ROOT}/etc/courier-imap/imapd-ssl" + + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier_authlib_authdaemonrc" "${ROOT}/etc/courier/authlib/authdaemonrc" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier_authlib_authmysqlrc" "${ROOT}/etc/courier/authlib/authmysqlrc" + + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||/var/customers/mail|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||9997|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||9997|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier-imap_pop3d" "${ROOT}/etc/courier-imap/pop3d" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier-imap_imapd" "${ROOT}/etc/courier-imap/imapd" + + if use ssl ; then + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier-imap_pop3d-ssl" "${ROOT}/etc/courier-imap/pop3d-ssl" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier-imap_imapd-ssl" "${ROOT}/etc/courier-imap/imapd-ssl" + + sed -e "s||${servername}|g" -i "${ROOT}/etc/courier-imap/pop3d-ssl" + sed -e "s||${servername}|g" -i "${ROOT}/etc/courier-imap/imapd-ssl" + fi + + chown root:0 "${ROOT}/etc/courier/authlib/authdaemonrc" + chown root:0 "${ROOT}/etc/courier/authlib/authmysqlrc" + chown root:0 "${ROOT}/etc/courier-imap/pop3d" + chown root:0 "${ROOT}/etc/courier-imap/imapd" + if use ssl ; then + chown root:0 "${ROOT}/etc/courier-imap/pop3d-ssl" + chown root:0 "${ROOT}/etc/courier-imap/imapd-ssl" + fi + chmod 0600 "${ROOT}/etc/courier/authlib/authdaemonrc" + chmod 0600 "${ROOT}/etc/courier/authlib/authmysqlrc" + chmod 0600 "${ROOT}/etc/courier-imap/pop3d" + chmod 0600 "${ROOT}/etc/courier-imap/imapd" + if use ssl ; then + chmod 0600 "${ROOT}/etc/courier-imap/pop3d-ssl" + chmod 0600 "${ROOT}/etc/courier-imap/imapd-ssl" + fi + else + einfo "Configuring Dovecot-IMAP ..." + rm -f "${ROOT}/etc/dovecot/dovecot.conf" + rm -f "${ROOT}/etc/dovecot/dovecot-sql.conf" + + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/dovecot/etc_dovecot_dovecot.conf" "${ROOT}/etc/dovecot/dovecot.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/dovecot/etc_dovecot_dovecot-sql.conf" "${ROOT}/etc/dovecot/dovecot-sql.conf" + + if use ssl ; then + sed -e "s||imaps pop3s|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + sed -e "s|#ssl_cert_file|ssl_cert_file|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + sed -e "s|#ssl_key_file|ssl_key_file|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + else + sed -e "s|||g" -i "${ROOT}/etc/dovecot/dovecot.conf" + fi + + sed -e "s||root@${servername}|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + sed -e "s||${servername}|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/dovecot/dovecot-sql.conf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/dovecot/dovecot-sql.conf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/dovecot/dovecot-sql.conf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/dovecot/dovecot-sql.conf" + + chown root:0 "${ROOT}/etc/dovecot/dovecot-sql.conf" + chown root:0 "${ROOT}/etc/dovecot/dovecot-sql.conf" + chmod 0600 "${ROOT}/etc/dovecot/dovecot-sql.conf" + chmod 0600 "${ROOT}/etc/dovecot/dovecot-sql.conf" + fi + + einfo "Configuring Postfix ..." + local POSTFIX_PATH="" + if use dovecot ; then + POSTFIX_PATH="postfix_dovecot" + else + POSTFIX_PATH="postfix_courier" + fi + + rm -f "${ROOT}/etc/postfix/main.cf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_main.cf" "${ROOT}/etc/postfix/main.cf" + sed -e "s||${servername}|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s||/var/customers/mail|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s||9997|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s||9997|g" -i "${ROOT}/etc/postfix/main.cf" + if use dovecot ; then + sed -e "s|#mailbox_command = /usr/libexec/dovecot/deliver|mailbox_command = /usr/libexec/dovecot/deliver|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_sasl_type = dovecot|smtpd_sasl_type = dovecot|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_sasl_path = private/auth|smtpd_sasl_path = private/auth|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_transport = dovecot|virtual_transport = dovecot|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#dovecot_destination_recipient_limit = 1|dovecot_destination_recipient_limit = 1|g" -i "${ROOT}/etc/postfix/main.cf" + + # add line to master.cf + local MASTER_DOVECOT="" + MASTER_DOVECOT=`cat ${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_master.cf` + echo -e "\n${MASTER_DOVECOT}" >> "${ROOT}/etc/postfix/master.cf" + fi + if use mailquota ; then + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_mailbox_limit_maps.cf" "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + + sed -e "s|#virtual_transport = virtual|virtual_transport = virtual|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_create_maildirsize|virtual_create_maildirsize|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_mailbox_extended|virtual_mailbox_extended|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_mailbox_limit_inbox|virtual_mailbox_limit_inbox|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_mailbox_limit_maps|virtual_mailbox_limit_maps|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_maildir_limit_message|virtual_maildir_limit_message|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_overquota_bounce|virtual_overquota_bounce|g" -i "${ROOT}/etc/postfix/main.cf" + + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + fi + if use ssl ; then + sed -e "s||${servername}|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtp_use_tls|smtp_use_tls|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_tls_cert_file|smtpd_tls_cert_file|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_tls_key_file|smtpd_tls_key_file|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_tls_auth_only|smtpd_tls_auth_only|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_tls_session_cache_timeout|smtpd_tls_session_cache_timeout|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#tls_random_source|tls_random_source|g" -i "${ROOT}/etc/postfix/main.cf" + fi + + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_alias_maps.cf" "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_mailbox_domains.cf" "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_mailbox_maps.cf" "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_sender_permissions.cf" "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + + if ! use dovecot ; then + rm -f "${ROOT}/etc/sasl2/smtpd.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_sasl2_smtpd.conf" "${ROOT}/etc/sasl2/smtpd.conf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/sasl2/smtpd.conf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/sasl2/smtpd.conf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/sasl2/smtpd.conf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/sasl2/smtpd.conf" + chown root:0 "${ROOT}/etc/sasl2/smtpd.conf" + chmod 0600 "${ROOT}/etc/sasl2/smtpd.conf" + fi + + if use domainkey && use bind ; then + cat "${ROOT}/usr/share/${PN}/domainkey.conf" >> "${ROOT}/etc/postfix/main.cf" + fi + + # create postfix aliases.db, #412 + einfo "Creating aliases.db for postfix ..." + rm -f "${ROOT}/etc/mail/aliases" + # do not use insinto/newins. mailbase does contain that file so it will nether work nor fail in pkg_config :( #512 + cp "${ROOT}/usr/share/${PN}/aliases" "${ROOT}/etc/mail" + sed -e "s||root@${servername}|g" -i "${ROOT}/etc/mail/aliases" + /usr/bin/newaliases + + # Automatical Bind configuration, if Bind is installed + if use bind ; then + einfo "Configuring Bind .." + rm -f "${ROOT}/etc/bind/default.zone" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/bind/etc_bind_default.zone" "${ROOT}/etc/bind/default.zone" + sed -e "s||${serverip}|g" -i "${ROOT}/etc/bind/default.zone" + + einfo "Add Gentoo-Froxlor include to Bind configuration ..." + echo "include \"/etc/bind/froxlor_bind.conf\";" >> "${ROOT}/etc/bind/named.conf" + touch "${ROOT}/etc/bind/froxlor_bind.conf" + chown named:0 "${ROOT}/etc/bind/froxlor_bind.conf" + chmod 0600 "${ROOT}/etc/bind/froxlor_bind.conf" + fi + + srv_add_restart() { + einfo "Adding ${1} to 'default' runlevel ..." + rc-update add ${1} default + einfo "(Re)Starting ${1} ..." + "${ROOT}/etc/init.d/${1}" restart + } + + # Automatical service starting + + sleep 2 + if use lighttpd ; then + srv_add_restart lighttpd + else + srv_add_restart apache2 + fi + # NB: this may fail if the user does not have vixie-cron installed + srv_add_restart vixie-cron + if use bind ; then + srv_add_restart named + fi + srv_add_restart proftpd + if ! use dovecot ; then + srv_add_restart courier-authlib + srv_add_restart courier-pop3d + srv_add_restart courier-imapd + if use ssl ; then + srv_add_restart courier-pop3d-ssl + srv_add_restart courier-imapd-ssl + fi + else + srv_add_restart dovecot + fi + if use domainkey && use bind ; then + srv_add_restart dkim-filter + fi + if use fcgid ; then + srv_add_restart nscd + fi + srv_add_restart postfix + + einfo "Configuration completed successfully!" + einfo + local URL="" + if use ssl ; then + URL="https://${servername}/index.php" + else + URL="http://${servername}/index.php" + fi + einfo "You can now open your Froxlor under ${URL}" +} diff --git a/www-apps/froxlor/froxlor-9999.ebuild b/www-apps/froxlor/froxlor-9999.ebuild new file mode 100644 index 0000000..fce4e26 --- /dev/null +++ b/www-apps/froxlor/froxlor-9999.ebuild @@ -0,0 +1,1350 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="2" + +inherit eutils depend.php + +if [[ ${PV} == "9999" ]] ; then + EGIT_REPO_URI="git://git.froxlor.org/froxlor.git" + EGIT_PROJECT="froxlor" + inherit git + #KEYWORDS="" +else + RESTRICT="mirror" + SRC_URI="http://files.froxlor.org/releases/${P}.tar.gz" + KEYWORDS="~amd64 ~x86" +fi + +DESCRIPTION="A PHP-based webhosting-oriented control panel for servers." +HOMEPAGE="http://www.froxlor.org/" +LICENSE="GPL-2" +SLOT="0" +IUSE="aps autoresponder awstats bind domainkey dovecot fcgid ftpquota fpm lighttpd +log mailquota nginx pureftpd ssl +tickets" + +DEPEND=" + !www-apps/syscp + >=mail-mta/postfix-2.4[mysql,ssl=] + virtual/cron + virtual/mysql + >=dev-lang/php-5.2[bcmath,cli,ctype,filter,ftp,gd,mysql,nls,posix,session,simplexml,ssl=,tokenizer,xml,xsl,zlib] + || ( =dev-lang/php-5.3 ) + pureftpd? ( + net-ftp/pure-ftpd[mysql,ssl=] + ) + !pureftpd? ( + net-ftp/proftpd[mysql,ssl=] + ftpquota? ( net-ftp/proftpd[softquota] ) + ) + awstats? ( + www-misc/awstats + ( !lighttpd? ( + !nginx? ( + www-misc/awstats[apache2] + ) + ) + ) + ) + !awstats? ( + app-admin/webalizer + ) + bind? ( net-dns/bind + domainkey? ( mail-filter/dkim-milter ) + ) + ssl? ( dev-libs/openssl ) + lighttpd? ( www-servers/lighttpd[fastcgi,ssl=] + >=dev-lang/php-5.2[cgi] + ) + nginx? ( + www-servers/nginx[ssl=] + ) + !lighttpd? ( + ( !nginx? ( + www-servers/apache[ssl=] + dev-lang/php[apache2] + ) + ) + ) + fcgid? ( >=dev-lang/php-5.2[cgi] + || ( =dev-lang/php-5.3 ) + sys-auth/libnss-mysql + ( !lighttpd? ( + !nginx? ( + www-servers/apache[suexec] + www-apache/mod_fcgid + ) + ) + ) + ) + dovecot? ( >=net-mail/dovecot-1.2.0[mysql,ssl=] + >=mail-mta/postfix-2.4[dovecot-sasl] + ) + !dovecot? ( dev-libs/cyrus-sasl[crypt,mysql,ssl=] + net-libs/courier-authlib[crypt,mysql] + net-mail/courier-imap + >=mail-mta/postfix-2.4[sasl] + ) + aps? ( dev-lang/php[zip] ) + mailquota? ( >=mail-mta/postfix-2.4[vda] )" + +RDEPEND="${DEPEND}" + +# we need that to set the standardlanguage later +LANGS="bg ca cs de da en es fr hu it nl pl pt ru se sl zh_CN" +for X in ${LANGS} ; do + IUSE="${IUSE} linguas_${X}" +done + +# lets check user defined variables +FROXLOR_DOCROOT="${FROXLOR_DOCROOT:-/var/www}" + +need_php5_httpd +need_php5_cli + +S="${WORKDIR}/${PN}" + +src_unpack() { + if [[ ${PV} == "9999" ]] ; then + git_src_unpack + else + unpack ${A} + fi + cd "${S}" +} +pkg_setup() { + # Create the user and group that will own the Froxlor files + einfo "Creating froxlor user ..." + enewgroup froxlor 9995 + enewuser froxlor 9995 -1 ${FROXLOR_DOCROOT}/froxlor froxlor + + # Create the user and group that will run the FTPd + einfo "Creating froxlorftpd user ..." + enewgroup froxlorftpd 9996 + enewuser froxlorftpd 9996 -1 /var/customers/webs froxlorftpd + + # Create the user and group that will run the virtual MTA + einfo "Creating vmail user ..." + enewgroup vmail 9997 + enewuser vmail 9997 -1 /var/customers/mail vmail +} + +src_prepare() { + epatch_user + # Delete any mention of inserttask('4') if no Bind is used + if ! use bind ; then + find "${S}/" -type f -exec sed -e "s|inserttask('4');||g" -i {} \; + fi +} + +src_install() { + # set default language + local MYLANG="" + if use linguas_bg ; then + MYLANG="Bulgarian" + elif use linguas_ca ; then + MYLANG="Catalan" + elif use linguas_cs ; then + MYLANG="Czech" + elif use linguas_de ; then + MYLANG="Deutsch" + elif use linguas_da ; then + MYLANG="Danish" + elif use linguas_es ; then + MYLANG="Español" + elif use linguas_fr ; then + MYLANG="Français" + elif use linguas_hu ; then + MYLANG="Hungarian" + elif use linguas_it ; then + MYLANG="Italian" + elif use linguas_nl ; then + MYLANG="Dutch" + elif use linguas_pl ; then + MYLANG="Polski" + elif use linguas_pt ; then + MYLANG="Português" + elif use linguas_ru ; then + MYLANG="Russian" + elif use linguas_se ; then + MYLANG="Swedish" + elif use linguas_sl ; then + MYLANG="Slovak" + elif use linguas_zh_CN ; then + MYLANG="Chinese" + fi + + if [[ ${MYLANG} != '' ]] ; then + einfo "Setting standardlanguage to '${MYLANG}'" + sed -e "s|'standardlanguage', 'English'|'standardlanguage', '${MYLANG}'|g" -i "${S}/install/froxlor.sql" || die "Unable to change default language" + fi + + einfo "Setting 'lastguid' to '10000'" + sed -e "s|'lastguid', '9999'|'lastguid', '10000'|g" -i "${S}/install/froxlor.sql" || die "Unable to change lastguid" + + einfo "Setting 'vmail_uid' and 'vmail_gid' to '9997'" + sed -e "s|'vmail_uid', '2000'|'vmail_uid', '9997'|g" -i "${S}/install/froxlor.sql" || die "Unable to change uid for user vmail" + sed -e "s|'vmail_gid', '2000'|'vmail_gid', '9997'|g" -i "${S}/install/froxlor.sql" || die "Unable to change gid for user vmail" + + # set correct webserver reload + if use lighttpd; then + einfo "Switching settings to fit 'lighttpd'" + sed -e "s|/etc/init.d/apache reload|/etc/init.d/lighttpd restart|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver restart-command" + sed -e "s|'webserver', 'apache2'|'webserver', 'lighttpd'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver version" + sed -e "s|'apacheconf_vhost', '/etc/apache/vhosts.conf'|'apacheconf_vhost', '/etc/lighttpd/froxlor-vhosts.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver vhost directory" + sed -e "s|'apacheconf_diroptions', '/etc/apache/diroptions.conf'|'apacheconf_diroptions', '/etc/lighttpd/diroptions.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver diroptions file" + sed -e "s|'apacheconf_htpasswddir', '/etc/apache/htpasswd/'|'apacheconf_htpasswddir', '/etc/lighttpd/htpasswd/'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver htpasswd directory" + sed -e "s|'httpuser', 'www-data'|'httpuser', 'lighttpd'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver user" + sed -e "s|'httpgroup', 'www-data'|'httpgroup', 'lighttpd'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver group" + elif use nginx; then + einfo "Switching settings to fit 'nginx'" + sed -e "s|/etc/init.d/apache reload|/etc/init.d/nginx restart|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver restart-command" + sed -e "s|'webserver', 'apache2'|'webserver', 'nginx'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver version" + sed -e "s|'apacheconf_vhost', '/etc/apache/vhosts.conf'|'apacheconf_vhost', '/etc/nginx/froxlor-vhosts.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver vhost directory" + sed -e "s|'apacheconf_diroptions', '/etc/apache/diroptions.conf'|'apacheconf_diroptions', '/etc/nginx/diroptions.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver diroptions file" + sed -e "s|'apacheconf_htpasswddir', '/etc/apache/htpasswd/'|'apacheconf_htpasswddir', '/etc/nginx/htpasswd/'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver htpasswd directory" + sed -e "s|'httpuser', 'www-data'|'httpuser', 'nginx'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver user" + sed -e "s|'httpgroup', 'www-data'|'httpgroup', 'nginx'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver group" + else + einfo "Switching settings to fit 'apache2'" + sed -e "s|/etc/init.d/apache reload|/etc/init.d/apache2 reload|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver restart-command" + sed -e "s|'apacheconf_vhost', '/etc/apache/vhosts.conf'|'apacheconf_vhost', '/etc/apache2/vhosts.d/99_froxlor-vhosts.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver vhost directory" + sed -e "s|'apacheconf_diroptions', '/etc/apache/diroptions.conf'|'apacheconf_diroptions', '/etc/apache2/diroptions.conf'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver diroptions file" + sed -e "s|'apacheconf_htpasswddir', '/etc/apache/htpasswd/'|'apacheconf_htpasswddir', '/etc/apache2/htpasswd/'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver htpasswd directory" + sed -e "s|'httpuser', 'www-data'|'httpuser', 'apache'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver user" + sed -e "s|'httpgroup', 'www-data'|'httpgroup', 'apache'|g" -i "${S}/install/froxlor.sql" || die "Unable to change webserver group" + fi + + if use fcgid && ! use lighttpd && ! use nginx ; then + einfo "Switching 'fcgid' to 'On'" + sed -e "s|'mod_fcgid', '0'|'mod_fcgid', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set fcgid to 'On'" + + einfo "Setting wrapper to FCGIWrapper" + sed -e "s|'mod_fcgid_wrapper', '0'|'mod_fcgid_wrapper', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set fcgi-wrapper to 'FCGIWrapper'" + + einfo "Creating tmp-directory" + dodir "/var/customers/tmp" + + ewarn "You have to remove the '-D PHP5' entry from /etc/conf.d/apache2 if it exists!" + fi + + if use fpm ; then + einfo "Switching 'fpm' to 'On'" + sed -e "s|'phpfpm', 'enabled', '0'|'phpfpm', 'enabled', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set fpm to 'On'" + + einfo "Setting configdir for fpm" + sed -e "s|'phpfpm', 'configdir', '/etc/php-fpm.d/'|'phpfpm', 'configdir', '/etc/php/fpm-php5.3/fpm.d/'|g" -i "${S}/install/froxlor.sql" || die "Unable to set configdir for 'fpm'" + + einfo "Enable custom configdir for fpm" + sed -e "s|;include=/etc/php/fpm-php5.3/fpm.d/*.conf|include=/etc/php/fpm-php5.3/fpm.d/*.conf|g" -i "/etc/php/fpm-php5.3/php-fpm.conf" || die "Unable to set custom configdir for 'fpm'" + + einfo "Checking for directory /etc/php/fpm-php5.3/fpm.d/" + if [ ! -d /etc/php/fpm-php5.3/fpm.d/ ]; then + didir "/etc/php/fpm-php5.3/fpm.d/" + fi + + einfo "Creating tmp-directory" + dodir "/var/customers/tmp" + fi + + # If Bind will not used, change the reload path for it + if ! use bind ; then + einfo "Switching 'bind' to 'Off'" + sed -e 's|/etc/init.d/named reload|/bin/true|g' -i "${S}/install/froxlor.sql" || die "Unable to change reload path for Bind" + fi + + # default value is logging_enabled='1' + if ! use log ; then + einfo "Switching 'log' to 'Off'" + sed -e "s|'logger', 'enabled', '1'|'logger', 'enabled', '0'|g" -i "${S}/install/froxlor.sql" || die "Unable to set logging to 'Off'" + # fix menu + sed -e "s|'10', 'change_serversettings'|'10', 'logger.enabled'|g" -i "${S}/install/froxlor.sql" || die "Unable to fix logging menu-entry" + fi + + # default value is tickets_enabled='1' + if ! use tickets ; then + einfo "Switching 'tickets' to 'Off'" + sed -e "s|'ticket', 'enabled', '1'|'ticket', 'enabled', '0'|g" -i "${S}/install/froxlor.sql" || die "Unable to set ticketsystem to 'Off'" + fi + + # default value is mailquota='0' + if use mailquota ; then + einfo "Switching 'mailquota' to 'On'" + sed -e "s|'mail_quota_enabled', '0'|'mail_quota_enabled', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set mailquota to 'On'" + fi + + # default value is autoresponder='0' + if use autoresponder ; then + einfo "Switching 'autoresponder' to 'On'" + sed -e "s|'autoresponder_active', '0'|'autoresponder_active', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set autoresponder to 'On'" + # fix menu + sed -e "s|40, 'autoresponder.autoresponder_active'|40, 'mails'|g" -i "${S}/install/froxlor.sql" || die "Unable to fix autoresponder menu-entry" + fi + + # default value is dkim_enabled='0' + if use domainkey && use bind ; then + einfo "Switching 'domainkey' to 'On'" + sed -e "s|'use_dkim', '0'|'use_dkim', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set domainkey to 'On'" + + einfo "Setting dkim-path to gentoo value" + sed -e "s|'dkim_prefix', '/etc/postfix/dkim/'|'dkim_prefix', '/etc/mail/dkim-filter/'|g" -i "${S}/install/froxlor.sql" || die "Unable to set domainkey prefix" + fi + + # default value is aps_enabled='0' + if use aps ; then + einfo "Switching 'APS' to 'On'" + sed -e "s|'aps_active', '0'|'aps_active', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to set aps to 'On'" + # fix menu + sed -e "s|'admin_aps.nourl', 45, 'aps.aps_active'|'admin_aps.nourl', 45, 'can_manage_aps_packages'|g" -i "${S}/install/froxlor.sql" || die "Unable to fix aps admin-menu-entry" + sed -e "s|'customer_aps.nourl', 50, 'aps.aps_active'|'customer_aps.nourl', 50, 'phpenabled'|g" -i "${S}/install/froxlor.sql" || die "Unable to fix aps customer-menu-entry" + + # if aps is used we enable required features in the php-cli php.ini + ewarn + ewarn "Please run the following command in your shell to change the php-cli php.ini file for APS" + ewarn + ewarn "sed -ie \"s|allow_url_fopen = Off|allow_url_fopen = On|g\" -i \"/etc/php/cli-php5/php.ini\"" + ewarn + fi + + # default value is ssl_enabled='1' + if ! use ssl ; then + einfo "Switching 'SSL' to 'Off'" + sed -e "s|'use_ssl','1'|'use_ssl','0'|g" -i "${S}/install/froxlor.sql" || die "Unable to set ssl to 'Off'" + fi + + if use awstats ; then + einfo "Switching from 'Webalizer' to 'AWStats'" + sed -e "s|'webalizer_quiet', '2'|'webalizer_quiet', '0'|g" -i "${S}/install/froxlor.sql" + sed -e "s|'awstats_enabled', '0'|'awstats_enabled', '1'|g" -i "${S}/install/froxlor.sql" || die "Unable to enable AWStats" + fi + + if use pureftpd ; then + einfo "Switching from 'ProFTPd' to 'Pure-FTPd'" + sed -e "s|'ftpserver', 'proftpd'|'ftpserver', 'pureftpd'|g" -i "${S}/install/froxlor.sql" + fi + + # Install the Froxlor files + einfo "Installing Froxlor files" + dodir ${FROXLOR_DOCROOT} + cp -Rf "${S}/" "${D}${FROXLOR_DOCROOT}/" || die "Installation of the Froxlor files failed" + + # Fix the permissions for the Froxlor files + einfo "Fixing permission of Froxlor files" + if use lighttpd ; then + fowners -R froxlor:lighttpd ${FROXLOR_DOCROOT}/froxlor + elif use nginx ; then + fowners -R froxlor:nginx ${FROXLOR_DOCROOT}/froxlor + else + fowners -R froxlor:apache ${FROXLOR_DOCROOT}/froxlor + fi + if use fcgid ; then + if ! use lighttpd ; then + fowners -R froxlor:froxlor ${FROXLOR_DOCROOT}/froxlor + else + einfo "lighttpd overwrites fcgid USE-flag!" + #fowners froxlor:lighttpd ${FROXLOR_DOCROOT}/froxlor + fi + fperms 0750 ${FROXLOR_DOCROOT}/froxlor + elif use fpm ; then + fowners -R froxlor:froxlor ${FROXLOR_DOCROOT}/froxlor + fperms 0750 ${FROXLOR_DOCROOT}/froxlor + else + if use lighttpd ; then + fowners -R froxlor:lighttpd ${FROXLOR_DOCROOT}/froxlor/{temp,packages} + elif use nginx ; then + fowners -R froxlor:nginx ${FROXLOR_DOCROOT}/froxlor/{temp,packages} + else + fowners -R froxlor:apache ${FROXLOR_DOCROOT}/froxlor/{temp,packages} + fi + fi + fperms 0775 ${FROXLOR_DOCROOT}/froxlor/{temp,packages} + + # Create the main directories for customer data + dodir /var/customers/webs + dodir /var/customers/mail + fowners vmail:vmail /var/customers/mail + fperms 0750 /var/customers/mail + dodir /var/customers/logs + + dodir /usr/share/${PN} + cp "${FILESDIR}/domainkey.conf" "${D}/usr/share/${PN}" + cp "${FILESDIR}/froxlor.cron" "${D}/usr/share/${PN}" + cp "${FILESDIR}/php-fcgi-starter" "${D}/usr/share/${PN}" + cp "${FILESDIR}/php.ini" "${D}/usr/share/${PN}" + cp "${FILESDIR}/aliases" "${D}/usr/share/${PN}" +} + +pkg_postinst() { + # we need to check if this is going to be an update or a fresh install! + if [[ -f "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" ]] ; then + elog "Froxlor is already installed on this system!" + elog + elog "In this case 'emerge --config' mustn't be executed!" + elog "Any configurationfiles will stay untouched!" + elog + elog "Froxlor will update the database when you open" + elog "it in your browser the first time after the update-process" + sleep 2 + elif [[ -f "${ROOT}${FROXLOR_DOCROOT}/syscp/lib/userdata.inc.php" ]] ; then + elog "This seems to be an upgrade from syscp" + elog "please move ${FROXLOR_DOCROOT}/syscp/lib/userdata.inc.php to" + elog "${FROXLOR_DOCROOT}/froxlor/lib/" + elog "and don't forget to copy "${ROOT}/usr/share/${PN}/froxlor.cron"" + elog "to /etc/cron.d/froxlor and remove /etc/cron.d/syscp" + else + elog "Please run 'emerge --config =${PF}' to continue with" + elog "the basic setup of Gentoo-Froxlor, *after* you have" + elog "setup your MySQL databases root user and password" + elog "like the MySQL ebuild tells you to do." + fi +} + +pkg_config() { + local proceedyesno1 + local servername + local serverip + local mysqlhost + local mysqlaccesshost + local mysqlrootuser + local mysqlrootpw1 + local mysqlrootpw2 + local mysqlrootpw + local mysqldbname + local mysqlunprivuser + local mysqlunprivpw1 + local mysqlunprivpw2 + local mysqlunprivpw + local adminuser + local adminpw1 + local adminpw2 + local adminpw + local proceedyesno2 + + ewarn "Gentoo-Froxlor Basic Configuration" + echo + einfo "This will setup Gentoo-Froxlor on your system, it will create and" + einfo "populate the MySQL database, create and chmod the needed files" + einfo "correctly and configure all services to work out-of-the-box" + einfo "with Gentoo-Froxlor, using a sane default configuration, and" + einfo "start them, along with creating the correct Gentoo-Froxlor Apache" + einfo "VirtualHost for you." + einfo "CAUTION: this will backup and then replace your services" + einfo "configuration and restart them!" + echo + einfo "Do you want to proceed? [Y/N]" + echo + read -rp " > " proceedyesno1 ; echo + if [[ ${proceedyesno1} == "Y" ]] || [[ ${proceedyesno1} == "y" ]] || [[ ${proceedyesno1} == "Yes" ]] || [[ ${proceedyesno1} == "yes" ]] ; then + echo + else + echo + die "User abort: not proceeding!" + fi + einfo "Enter the domain under wich Froxlor shall be reached, this normally" + einfo "is the FQDN (Fully Qualified Domain Name) of your system." + einfo "If you don't know the FQDN of your system, execute 'hostname -f'." + einfo "This installscript will try to guess your FQDN automatically if" + einfo "you leave this field blank, setting it to the output of 'hostname -f'." + echo + read -rp " > " servername ; echo + echo + if [[ ${servername} == "" ]] ; then + servername=`hostname -f` + fi + einfo "Enter the IP address of your system, under wich all" + einfo "websites shall then be reached. This must be the same" + einfo "IP address the domain you inserted above points to." + einfo "You *must* set this to your correct IP address." + echo + read -rp " > " serverip ; echo + echo + if [[ ${serverip} == "" ]] ; then + die "Abort: need correct IP address!" + fi + einfo "Enter the IP address of the MySQL server, if the MySQL" + einfo "server is on the same machine, enter 'localhost' or" + einfo "simply leave the field blank." + echo + read -rp " > " mysqlhost ; echo + echo + if [[ ${mysqlhost} == "" ]] ; then + mysqlhost="localhost" + fi + if [[ ${mysqlhost} == "localhost" ]] ; then + mysqlaccesshost="localhost" + else + mysqlaccesshost="${serverip}" + fi + einfo "Enter the username of the MySQL root user." + einfo "The default is 'root'." + echo + read -rp " > " mysqlrootuser ; echo + echo + if [[ ${mysqlrootuser} == "" ]] ; then + mysqlrootuser="root" + fi + einfo "Enter the password of the MySQL root user." + echo + read -rsp " > " mysqlrootpw1 ; echo + echo + if [[ ${mysqlrootpw1} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + einfo "Confirm the password of the MySQL root user." + echo + read -rsp " > " mysqlrootpw2 ; echo + echo + if [[ ${mysqlrootpw2} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + if [[ ${mysqlrootpw1} != ${mysqlrootpw2} ]] ; then + die "Abort: the two passwords don't match!" + else + mysqlrootpw="${mysqlrootpw1}" + fi + einfo "Enter the name of the database you want to" + einfo "use for Froxlor. The default is 'froxlor'." + einfo "CAUTION: any database with that name will" + einfo "be dropped!" + echo + read -rp " > " mysqldbname ; echo + echo + if [[ ${mysqldbname} == "" ]] ; then + mysqldbname="froxlor" + fi + einfo "Enter the username of the unprivileged" + einfo "MySQL user you want Froxlor to use." + einfo "The default is 'froxlor'." + einfo "CAUTION: any user with that name will" + einfo "be deleted!" + echo + read -rp " > " mysqlunprivuser ; echo + echo + if [[ ${mysqlunprivuser} == "" ]] ; then + mysqlunprivuser="froxlor" + fi + einfo "Enter the password of the unprivileged" + einfo "MySQL user." + echo + read -rsp " > " mysqlunprivpw1 ; echo + echo + if [[ ${mysqlunprivpw1} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + einfo "Confirm the password of the unprivileged" + einfo "MySQL user." + echo + read -rsp " > " mysqlunprivpw2 ; echo + echo + if [[ ${mysqlunprivpw2} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + if [[ ${mysqlunprivpw1} != ${mysqlunprivpw2} ]] ; then + die "Abort: the two passwords don't match!" + else + mysqlunprivpw="${mysqlunprivpw1}" + fi + einfo "Enter the username of the admin user you" + einfo "want in your Froxlor panel." + einfo "Default is 'admin'." + echo + read -rp " > " adminuser ; echo + echo + if [[ ${adminuser} == "" ]] ; then + adminuser="admin" + fi + einfo "Enter the password of the Froxlor admin user." + echo + read -rsp " > " adminpw1 ; echo + echo + if [[ ${adminpw1} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + einfo "Confirm the password of the Froxlor admin user." + echo + read -rsp " > " adminpw2 ; echo + echo + if [[ ${adminpw2} == "" ]] ; then + die "Abort: please insert a valid password!" + fi + if [[ ${adminpw1} != ${adminpw2} ]] ; then + die "Abort: the two passwords don't match!" + else + adminpw="${adminpw1}" + fi + + einfo "Adding MySQL server to 'default' runlevel ..." + rc-update add mysql default + + einfo "(Re)Starting MySQL server ..." + "${ROOT}/etc/init.d/mysql" restart + + einfo "Creating temporary work directory ..." + rm -Rf "${ROOT}/tmp/froxlor-install-by-emerge" + mkdir -p "${ROOT}/tmp/froxlor-install-by-emerge" + chown root:0 "${ROOT}/tmp/froxlor-install-by-emerge" + chmod 0700 "${ROOT}/tmp/froxlor-install-by-emerge" + + einfo "Preparing SQL database files ..." + cp -f "${ROOT}${FROXLOR_DOCROOT}/froxlor/install/froxlor.sql" "${ROOT}/tmp/froxlor-install-by-emerge/" + chown root:0 "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + chmod 0600 "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + sed -e "s|SERVERNAME|${servername}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + sed -e "s|SERVERIP|${serverip}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + sed -e "s|'mysql_access_host', 'localhost'|'mysql_access_host', '${mysqlaccesshost}'|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + + touch "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + echo "DROP DATABASE IF EXISTS MYSQL_DATABASE_NAME; +CREATE DATABASE MYSQL_DATABASE_NAME; +GRANT ALL PRIVILEGES ON MYSQL_DATABASE_NAME.* TO MYSQL_UNPRIV_USER@MYSQL_ACCESS_HOST IDENTIFIED BY 'password'; +SET PASSWORD FOR MYSQL_UNPRIV_USER@MYSQL_ACCESS_HOST = PASSWORD('MYSQL_UNPRIV_PASSWORD'); +FLUSH PRIVILEGES;" > "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + + sed -e "s|MYSQL_ACCESS_HOST|${mysqlaccesshost}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + sed -e "s|MYSQL_UNPRIV_USER|${mysqlunprivuser}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + sed -e "s|MYSQL_UNPRIV_PASSWORD|${mysqlunprivpw}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + sed -e "s|MYSQL_DATABASE_NAME|${mysqldbname}|g" -i "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + + einfo "Creating Froxlor database ..." + mysql -u ${mysqlrootuser} -p${mysqlrootpw} < "${ROOT}/tmp/froxlor-install-by-emerge/createdb.sql" + + einfo "Installing SQL database files ..." + mysql -u ${mysqlrootuser} -p${mysqlrootpw} ${mysqldbname} < "${ROOT}/tmp/froxlor-install-by-emerge/froxlor.sql" + + einfo "Adding system ip/port to database" + touch "${ROOT}/tmp/froxlor-install-by-emerge/ipandport.sql" + cat > "${ROOT}/tmp/froxlor-install-by-emerge/ipandport.sql" < "${ROOT}/tmp/froxlor-install-by-emerge/admin.sql" <" > "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + + if ! use fcgid ; then + if ! use lighttpd ; then + chown froxlor:apache "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + else + chown froxlor:lighttpd "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + fi + else + if ! use lighttpd ; then + chown froxlor:froxlor "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + else + # this stays as lighty doesn't use fcgid + chown froxlor:lighttpd "${ROOT}${FROXLOR_DOCROOT}/froxlor/lib/userdata.inc.php" + fi + fi + + if use ssl ; then + einfo "Creating needed SSL certificates ..." + einfo "Please enter the correct input when it's requested." + ewarn + ewarn "ATTENTION: when you're requested to enter a" + ewarn "'Common Name' enter ${servername} ." + ewarn + + # Create the directories where we'll store our SSL + # certificates and set secure permissions on them + mkdir -p "${ROOT}/etc/ssl/server" + chown root:0 "${ROOT}/etc/ssl/server" + chmod 0700 "${ROOT}/etc/ssl/server" + + # We first generate our Private Key + openssl genrsa -des3 -out "${ROOT}/etc/ssl/server/${servername}.key" 2048 + + # Now we generate our CSR (Certificate Signing Request) + openssl req -new -key "${ROOT}/etc/ssl/server/${servername}.key" -out "${ROOT}/etc/ssl/server/${servername}.csr" + + # Create an unencrypted key, to avoid having to always enter + # the passphrase when a service using it is restarted (eg. Apache) + cp -f "${ROOT}/etc/ssl/server/${servername}.key" "${ROOT}/etc/ssl/server/${servername}.key.orig" + openssl rsa -in "${ROOT}/etc/ssl/server/${servername}.key.orig" -out "${ROOT}/etc/ssl/server/${servername}.key" + + einfo "You can now submit ${ROOT}/etc/ssl/server/${servername}.csr" + einfo "to an official CA (Certification Authority) to be" + einfo "signed (with costs) or you can sign it yourself (free)." + einfo "For more informations regarding SSL please visit:" + einfo "http://httpd.apache.org/docs/2.0/ssl/ssl_intro.html" + + echo + einfo "Do you want to self-sign your certificate? [Y/N]" + echo + read -rp " > " proceedyesno2 ; echo + if [[ ${proceedyesno2} == "Y" ]] || [[ ${proceedyesno2} == "y" ]] || [[ ${proceedyesno2} == "Yes" ]] || [[ ${proceedyesno2} == "yes" ]] ; then + echo + # We now generate a self-signed certificate that will + # be valid for 365 days + openssl x509 -req -days 365 -in "${ROOT}/etc/ssl/server/${servername}.csr" -signkey "${ROOT}/etc/ssl/server/${servername}.key" -out "${ROOT}/etc/ssl/server/${servername}.crt" + + # We now create a file that contains both the Private Key + # and the signed certificate, this is needed for Courier + cat "${ROOT}/etc/ssl/server/${servername}.crt" "${ROOT}/etc/ssl/server/${servername}.key" > "${ROOT}/etc/ssl/server/${servername}.pem" + else + einfo "Note: if you let your certificate be signed by an official" + einfo "CA please be sure to copy the certificate they gave you to" + einfo "${ROOT}/etc/ssl/server/${servername}.crt before starting" + einfo "and using any of the SSL enabled services." + echo + einfo "You'll also need to create a file that contains both the" + einfo "Private Key and the signed certificate, this is needed for" + einfo "Courier to work correctly." + einfo "You can do this with the following command:" + einfo "cat \"${ROOT}/etc/ssl/server/${servername}.crt\" \"${ROOT}/etc/ssl/server/${servername}.key\" > \"${ROOT}/etc/ssl/server/${servername}.pem\"" + echo + einfo "Additionally, don't forget to set the correct file permissions" + einfo "on your SSL files, you can do this with the following commands:" + einfo "chown root:0 \"${ROOT}/etc/ssl/server/${servername}.\"*" + einfo "chmod 0400 \"${ROOT}/etc/ssl/server/${servername}.\"*" + fi + + # Set secure permissions for our SSL files + chown root:0 "${ROOT}/etc/ssl/server/${servername}."* + chmod 0400 "${ROOT}/etc/ssl/server/${servername}."* + fi + + einfo "Writing Gentoo-Froxlor vhost configuration ..." + if use lighttpd ; then + VHOST_CONFIG="${ROOT}/etc/lighttpd/froxlor-vhosts.conf" + elif use nginx ; then + VHOST_CONFIG="${ROOT}/etc/nginx/froxlor-vhosts.conf" + else + VHOST_CONFIG="${ROOT}/etc/apache2/vhosts.d/99_froxlor-vhosts.conf" + fi + + # do stuff with the config file + rm -f "${VHOST_CONFIG}" + touch "${VHOST_CONFIG}" + chown root:0 "${VHOST_CONFIG}" + chmod 0600 "${VHOST_CONFIG}" + + if use lighttpd ; then + einfo "Configuring lighttpd" + rm -f "${ROOT}/etc/lighttpd/lighttpd.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/lighttpd/etc_lighttpd.conf" "${ROOT}/etc/lighttpd/lighttpd.conf" + sed -e "s||${servername}|g" -i "${ROOT}/etc/lighttpd/lighttpd.conf" + sed -e "s||${serverip}|g" -i "${ROOT}/etc/lighttpd/lighttpd.conf" + + touch "${VHOST_CONFIG}" + echo -e "\ninclude \"froxlor-vhosts.conf\"" >> "${ROOT}/etc/lighttpd/lighttpd.conf" + + echo -e "# Froxlor default vhost +\$HTTP[\"host\"] == \"${servername}\" { + server.document-root = var.basedir + \"/froxlor\" + server.name = \"${servername}\"" > "${VHOST_CONFIG}" + + if use ssl ; then + echo -e " + \$HTTP[\"scheme\"] == \"http\" { + url.redirect = ( \"^/(.*)\" => \"https://${servername}/$1\" ) + }" >> "${VHOST_CONFIG}" + fi + + if use fpm ; then + + echo -e ";PHP-FPM configuration for \"${servername}\" +[${servername}] +listen = /var/run/lighttpd/${servername}-php-fpm.socket +listen.owner = froxlor +listen.group = froxlor +listen.mode = 0666 + +user = froxlor +group = froxlor + +pm = static +pm.max_children = 1 +pm.max_requests = 0 + +env[TMP] = /tmp/ +env[TMPDIR] = /tmp/ +env[TEMP] = /tmp/ + +php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f admin@${servername}" > "${ROOT}/etc/php/fpm-php5.3/fpm.d/${servername}.conf" + + echo -e "\n fastcgi.server = ( +\".php\" => ( + \"localhost\" => ( + \"socket\" => \"/var/run/lighttpd/${servername}-php-fpm.socket\", + \"check-local\" => \"enable\", + \"disable-time\" => 1 + ) +) +)" >> "${VHOST_CONFIG}" + + dodir "/var/run/lighttpd" + fi + + echo -e " +}" >> "${VHOST_CONFIG}" + + if use ssl ; then + echo -e "\n\$SERVER[\"socket\"] == \"${serverip}:443\" { +ssl.engine = \"enable\" +ssl.pemfile = \"${ROOT}etc/ssl/server/${servername}.pem\" +ssl.ca-file = \"${ROOT}etc/ssl/server/${servername}.pem\" +}" >> "${ROOT}/etc/lighttpd/lighttpd.conf" + + fi + + elif use nginx ; then + einfo "Configuring nginx" + rm -f "${ROOT}/etc/nginx/nginx.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/nginx/etc_nginx_nginx.conf" "${ROOT}/etc/nginx/nginx.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/nginx/etc_init.d_php-fcgi" "${ROOT}/etc/init.d/php-fcgi" + chmod u+x "${ROOT}/etc/init.d/php-fcgi" + + touch "${VHOST_CONFIG}" + + echo -e "# Froxlor default vhost +server_name ${servername}; +access_log /var/log/nginx/access.log; +root "${ROOT}${FROXLOR_DOCROOT}"; +location / { + index index.php index.html index.htm; +}" > "${VHOST_CONFIG}" + + if use ssl ; then + echo -e "\n ssl on; +ssl_certificate "${ROOT}etc/ssl/server/${servername}.pem;" +ssl_certificate_key "${ROOT}etc/ssl/server/${servername}.pem;"" >> "${VHOST_CONFIG}" + fi + + echo -e "\nlocation ~ \.php$ { +fastcgi_index index.php; +include /etc/nginx/fastcgi_params;" >> "${VHOST_CONFIG}" + + if use ssl ; then + echo -e "fastcgi_param HTTPS on;" >> "${VHOST_CONFIG}" + fi + + echo -e "fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;" >> "${VHOST_CONFIG}" + + if use fpm ; then + + echo -e ";PHP-FPM configuration for \"${servername}\" +[${servername}] +listen = /var/run/nginx/${servername}-php-fpm.socket +listen.owner = froxlor +listen.group = froxlor +listen.mode = 0666 + +user = froxlor +group = froxlor + +pm = static +pm.max_children = 1 +pm.max_requests = 0 + +env[TMP] = /tmp/ +env[TMPDIR] = /tmp/ +env[TEMP] = /tmp/ + +php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f admin@${servername}" > "${ROOT}/etc/php/fpm-php5.3/fpm.d/${servername}.conf" + + echo -e "\n fastcgi_pass unix: /var/run/nginx/${servername}-php-fpm.socket;" >> "${VHOST_CONFIG}" + + dodir "/var/run/nginx" + fi + + echo -e "\n} +}" >> "${VHOST_CONFIG}" + + else + einfo "Configuring apache2" + if use fcgid ; then + # create php-starter file + FCGIDPATH="${ROOT}${FROXLOR_DOCROOT}/php-fcgi-scripts/froxlor.panel/${servername}" + mkdir -p "${FCGIDPATH}/php-fcgi-script" + mkdir -p "${FCGIDPATH}/tmp" + chmod 0750 "${FCGIDPATH}/tmp" + touch "${FCGIDPATH}/php-fcgi-starter" + cp "${ROOT}/usr/share/${PN}/php-fcgi-starter" "${FCGIDPATH}/php-fcgi-starter" + chmod 0750 "${FCGIDPATH}/php-fcgi-starter" + touch "${FCGIDPATH}/php.ini" + cp "${ROOT}/usr/share/${PN}/php.ini" "${FCGIDPATH}/php.ini" + chown froxlor:froxlor -R "${FCGIDPATH}/php-fcgi-script" || die "Unable to fix owner for php-fcgi-script folder" + chattr +i "${FCGIDPATH}/php-fcgi-starter" + fi + + if use ssl ; then + echo "# Gentoo-Froxlor SSL-enabled VirtualHost + + + + DocumentRoot \"${FROXLOR_DOCROOT}/froxlor\" + ServerName ${servername}" >> "${VHOST_CONFIG}" + + echo " ErrorLog /var/log/apache2/froxlor_ssl_error_log + + TransferLog /var/log/apache2/froxlor_ssl_access_log + + SSLEngine on + SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL + SSLCertificateFile /etc/ssl/server/${servername}.crt + SSLCertificateKeyFile /etc/ssl/server/${servername}.key + + SSLOptions +StdEnvVars + + + SetEnvIf User-Agent \".*MSIE.*\" nokeepalive ssl-unclean-shutdown \\ + downgrade-1.0 force-response-1.0 + + + CustomLog /var/log/apache2/froxlor_ssl_request_log \\ + \"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \\\"%r\\\" %b\" + " >> "${VHOST_CONFIG}" + + if use fcgid ; then + echo "SuexecUserGroup \"froxlor\" \"froxlor\" + + AddHandler fcgid-script .php + FCGIWrapper ${FROXLOR_DOCROOT}/php-fcgi-scripts/froxlor.panel/${servername}/php-fcgi-starter .php + Options +ExecCGI +" >> "${VHOST_CONFIG}" + + else + echo " + Order allow,deny + allow from all + " >> "${VHOST_CONFIG}" + fi + + echo " + + + + +# Redirect to the SSL-enabled Gentoo-Froxlor vhost + + RedirectPermanent / https://${servername}/index.php +" >> "${VHOST_CONFIG}" + + else + + echo "# Gentoo-Froxlor VirtualHost + + DocumentRoot \"${FROXLOR_DOCROOT}/froxlor\" + ServerName ${servername}" >> "${VHOST_CONFIG}" + + if use fcgid ; then + echo "SuexecUserGroup \"froxlor\" \"froxlor\" + + AddHandler fcgid-script .php + FCGIWrapper ${FROXLOR_DOCROOT}/php-fcgi-scripts/froxlor.panel/${servername}/php-fcgi-starter .php + Options +ExecCGI +" >> "${VHOST_CONFIG}" + + else + echo " + Order allow,deny + allow from all + " >> "${VHOST_CONFIG}" + fi + + echo "" >> "${VHOST_CONFIG}" + fi + fi + + if ! use lighttpd && ! use nginx ; then + einfo "Fix general Apache configuration to work with Gentoo-Froxlor ..." + sed -e "s|^\#ServerName localhost.*|ServerName ${servername}|g" -i "${ROOT}/etc/apache2/httpd.conf" || ewarn "Please make sure that the ServerName directive in ${ROOT}/etc/apache${USE_APACHE2}/httpd.conf is set to a valid value!" + sed -e "s|^ServerAdmin root\@localhost.*|ServerAdmin root\@${servername}|g" -i "${ROOT}/etc/apache2/httpd.conf" || ewarn "Please make sure that the ServerAdmin directive in ${ROOT}/etc/apache${USE_APACHE2}/httpd.conf is set to a valid value!" + sed -e "s|\*:80|${serverip}:80|g" -i "${ROOT}/etc/apache2/vhosts.d/00_default_vhost.conf" || ewarn "Please make sure the NameVirtualHost and VirtualHost directives in ${ROOT}/etc/apache${USE_APACHE2}/vhosts.d/00_default_vhost.conf are set to the Gentoo-Froxlor IP and Port 80!" + fi + + if ! use lighttpd && ! use nginx ; then + local DFCGID="" + + if use fcgid ; then + DFCGID="-D FCGID " + else + DFCGID="" + fi + + # this is maybe automatically added to APACHE2_OPTS + if [[ ${DFCGID} != "" ]] ; then + einfo "Attempting to add FCGID to ${ROOT}/etc/conf.d/apache2 ..." + sed -e "s|^APACHE2_OPTS=\"|APACHE2_OPTS=\"${DFCGID}|g" -i "${ROOT}/etc/conf.d/apache2" || ewarn "Unable to change APACHE2_OPTS in ${ROOT}/etc/conf.d/apache2, please change it manually to add '${DFCGID}'" + fi + fi + + # NSS-MySQL preparations + if use fcgid ; then + einfo "Modifying nsswitch.conf to use MySQL ..." + sed -e "s|compat|compat mysql|g" -i "${ROOT}/etc/nsswitch.conf" + rm -f "${ROOT}/etc/libnss-mysql.cfg" + rm -f "${ROOT}/etc/libnss-mysql-root.cfg" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/libnss/etc_libnss-mysql.cfg" "${ROOT}/etc/libnss-mysql.cfg" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/libnss/etc_libnss-mysql-root.cfg" "${ROOT}/etc/libnss-mysql-root.cfg" + + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/libnss-mysql.cfg" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/libnss-mysql.cfg" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/libnss-mysql.cfg" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/libnss-mysql.cfg" + + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/libnss-mysql-root.cfg" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/libnss-mysql-root.cfg" + fi + + if ! use pureftpd ; then + einfo "Configuring ProFTPd ..." + rm -f "${ROOT}/etc/proftpd/proftpd.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/proftpd/etc_proftpd_proftpd.conf" "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${servername}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + if use ssl ; then + sed -e "s|#||g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSEngine|TLSEngine|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSLog|TLSLog|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSProtocol|TLSProtocol|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSTimeoutHandshake|TLSTimeoutHandshake|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSOptions|TLSOptions|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSRSACertificateFile|TLSRSACertificateFile|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSRSACertificateKeyFile|TLSRSACertificateKeyFile|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSVerifyClient|TLSVerifyClient|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#TLSRequired|TLSRequired|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|#||g" -i "${ROOT}/etc/proftpd/proftpd.conf" + fi + if ! use ftpquota ; then + sed -e "s|QuotaEngine|#QuotaEngine|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaShowQuotas|#QuotaShowQuotas|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaDisplayUnits|#QuotaDisplayUnits|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaLock|#QuotaLock|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaLimitTable|#QuotaLimitTable|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|QuotaTallyTable|#QuotaTallyTable|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + sed -e "s|SQLNamedQuery|#SQLNamedQuery|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + fi + if ! has_version "net-ftp/proftpd[ipv6]"; then + sed -e "s|UseIPv6|#UseIPv6|g" -i "${ROOT}/etc/proftpd/proftpd.conf" + fi + chown root:0 "${ROOT}/etc/proftpd/proftpd.conf" + chmod 0600 "${ROOT}/etc/proftpd/proftpd.conf" + else + einfo "Configuring Pure-FTPd ..." + rm -f "${ROOT}/etc/conf.d/pure-ftpd" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/pureftpd/etc_conf.d_pure-ftpd" "${ROOT}/etc/conf.d/pure-ftpd" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/pureftpd/etc_pureftpd-mysql.conf" "${ROOT}/etc/pureftpd-mysql.conf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/pureftpd-mysql.conf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/pureftpd-mysql.conf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/pureftpd-mysql.conf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/pureftpd-mysql.conf" + chown root:0 "${ROOT}/etc/conf.d/pure-ftpd" + chmod 0644 "${ROOT}/etc/conf.d/pure-ftpd" + chown root:0 "${ROOT}/etc/pureftpd-mysql.conf" + chmod 0600 "${ROOT}/etc/pureftpd-mysql.conf" + fi + + einfo "Configuring Gentoo-Froxlor cronjob ..." + insinto "/etc/cron.d" + newins "${ROOT}/usr/share/${PN}/froxlor.cron" froxlor + + if ! use dovecot ; then + einfo "Configuring Courier-IMAP ..." + rm -f "${ROOT}/etc/courier/authlib/authdaemonrc" + rm -f "${ROOT}/etc/courier/authlib/authmysqlrc" + rm -f "${ROOT}/etc/courier-imap/pop3d" + rm -f "${ROOT}/etc/courier-imap/imapd" + rm -f "${ROOT}/etc/courier-imap/pop3d-ssl" + rm -f "${ROOT}/etc/courier-imap/imapd-ssl" + + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier_authlib_authdaemonrc" "${ROOT}/etc/courier/authlib/authdaemonrc" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier_authlib_authmysqlrc" "${ROOT}/etc/courier/authlib/authmysqlrc" + + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||/var/customers/mail|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||9997|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + sed -e "s||9997|g" -i "${ROOT}/etc/courier/authlib/authmysqlrc" + + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier-imap_pop3d" "${ROOT}/etc/courier-imap/pop3d" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier-imap_imapd" "${ROOT}/etc/courier-imap/imapd" + + if use ssl ; then + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier-imap_pop3d-ssl" "${ROOT}/etc/courier-imap/pop3d-ssl" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/courier/etc_courier-imap_imapd-ssl" "${ROOT}/etc/courier-imap/imapd-ssl" + + sed -e "s||${servername}|g" -i "${ROOT}/etc/courier-imap/pop3d-ssl" + sed -e "s||${servername}|g" -i "${ROOT}/etc/courier-imap/imapd-ssl" + fi + + chown root:0 "${ROOT}/etc/courier/authlib/authdaemonrc" + chown root:0 "${ROOT}/etc/courier/authlib/authmysqlrc" + chown root:0 "${ROOT}/etc/courier-imap/pop3d" + chown root:0 "${ROOT}/etc/courier-imap/imapd" + if use ssl ; then + chown root:0 "${ROOT}/etc/courier-imap/pop3d-ssl" + chown root:0 "${ROOT}/etc/courier-imap/imapd-ssl" + fi + chmod 0600 "${ROOT}/etc/courier/authlib/authdaemonrc" + chmod 0600 "${ROOT}/etc/courier/authlib/authmysqlrc" + chmod 0600 "${ROOT}/etc/courier-imap/pop3d" + chmod 0600 "${ROOT}/etc/courier-imap/imapd" + if use ssl ; then + chmod 0600 "${ROOT}/etc/courier-imap/pop3d-ssl" + chmod 0600 "${ROOT}/etc/courier-imap/imapd-ssl" + fi + else + einfo "Configuring Dovecot-IMAP ..." + rm -f "${ROOT}/etc/dovecot/dovecot.conf" + rm -f "${ROOT}/etc/dovecot/dovecot-sql.conf" + + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/dovecot/etc_dovecot_dovecot.conf" "${ROOT}/etc/dovecot/dovecot.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/dovecot/etc_dovecot_dovecot-sql.conf" "${ROOT}/etc/dovecot/dovecot-sql.conf" + + if use ssl ; then + sed -e "s||imaps pop3s|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + sed -e "s|#ssl_cert_file|ssl_cert_file|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + sed -e "s|#ssl_key_file|ssl_key_file|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + else + sed -e "s|||g" -i "${ROOT}/etc/dovecot/dovecot.conf" + fi + + sed -e "s||root@${servername}|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + sed -e "s||${servername}|g" -i "${ROOT}/etc/dovecot/dovecot.conf" + + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/dovecot/dovecot-sql.conf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/dovecot/dovecot-sql.conf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/dovecot/dovecot-sql.conf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/dovecot/dovecot-sql.conf" + + chown root:0 "${ROOT}/etc/dovecot/dovecot-sql.conf" + chown root:0 "${ROOT}/etc/dovecot/dovecot-sql.conf" + chmod 0600 "${ROOT}/etc/dovecot/dovecot-sql.conf" + chmod 0600 "${ROOT}/etc/dovecot/dovecot-sql.conf" + fi + + einfo "Configuring Postfix ..." + local POSTFIX_PATH="" + if use dovecot ; then + POSTFIX_PATH="postfix_dovecot" + else + POSTFIX_PATH="postfix_courier" + fi + + rm -f "${ROOT}/etc/postfix/main.cf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_main.cf" "${ROOT}/etc/postfix/main.cf" + sed -e "s||${servername}|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s||/var/customers/mail|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s||9997|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s||9997|g" -i "${ROOT}/etc/postfix/main.cf" + if use dovecot ; then + sed -e "s|#mailbox_command = /usr/libexec/dovecot/deliver|mailbox_command = /usr/libexec/dovecot/deliver|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_sasl_type = dovecot|smtpd_sasl_type = dovecot|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_sasl_path = private/auth|smtpd_sasl_path = private/auth|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_transport = dovecot|virtual_transport = dovecot|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#dovecot_destination_recipient_limit = 1|dovecot_destination_recipient_limit = 1|g" -i "${ROOT}/etc/postfix/main.cf" + + # add line to master.cf + local MASTER_DOVECOT="" + MASTER_DOVECOT=`cat ${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_master.cf` + echo -e "\n${MASTER_DOVECOT}" >> "${ROOT}/etc/postfix/master.cf" + fi + if use mailquota ; then + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_mailbox_limit_maps.cf" "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + + sed -e "s|#virtual_transport = virtual|virtual_transport = virtual|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_create_maildirsize|virtual_create_maildirsize|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_mailbox_extended|virtual_mailbox_extended|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_mailbox_limit_inbox|virtual_mailbox_limit_inbox|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_mailbox_limit_maps|virtual_mailbox_limit_maps|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_maildir_limit_message|virtual_maildir_limit_message|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#virtual_overquota_bounce|virtual_overquota_bounce|g" -i "${ROOT}/etc/postfix/main.cf" + + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_mailbox_limit_maps.cf" + fi + if use ssl ; then + sed -e "s||${servername}|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtp_use_tls|smtp_use_tls|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_tls_cert_file|smtpd_tls_cert_file|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_tls_key_file|smtpd_tls_key_file|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_tls_auth_only|smtpd_tls_auth_only|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#smtpd_tls_session_cache_timeout|smtpd_tls_session_cache_timeout|g" -i "${ROOT}/etc/postfix/main.cf" + sed -e "s|#tls_random_source|tls_random_source|g" -i "${ROOT}/etc/postfix/main.cf" + fi + + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_alias_maps.cf" "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_mailbox_domains.cf" "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_mailbox_maps.cf" "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_postfix_mysql-virtual_sender_permissions.cf" "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + chown root:postfix "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_alias_maps.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_mailbox_domains.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_mailbox_maps.cf" + chmod 0640 "${ROOT}/etc/postfix/mysql-virtual_sender_permissions.cf" + + if ! use dovecot ; then + rm -f "${ROOT}/etc/sasl2/smtpd.conf" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/${POSTFIX_PATH}/etc_sasl2_smtpd.conf" "${ROOT}/etc/sasl2/smtpd.conf" + sed -e "s||${mysqldbname}|g" -i "${ROOT}/etc/sasl2/smtpd.conf" + sed -e "s||${mysqlaccesshost}|g" -i "${ROOT}/etc/sasl2/smtpd.conf" + sed -e "s||${mysqlunprivuser}|g" -i "${ROOT}/etc/sasl2/smtpd.conf" + sed -e "s||${mysqlunprivpw}|g" -i "${ROOT}/etc/sasl2/smtpd.conf" + chown root:0 "${ROOT}/etc/sasl2/smtpd.conf" + chmod 0600 "${ROOT}/etc/sasl2/smtpd.conf" + fi + + if use domainkey && use bind ; then + cat "${ROOT}/usr/share/${PN}/domainkey.conf" >> "${ROOT}/etc/postfix/main.cf" + fi + + # create postfix aliases.db, #412 + einfo "Creating aliases.db for postfix ..." + rm -f "${ROOT}/etc/mail/aliases" + # do not use insinto/newins. mailbase does contain that file so it will nether work nor fail in pkg_config :( #512 + cp "${ROOT}/usr/share/${PN}/aliases" "${ROOT}/etc/mail" + sed -e "s||root@${servername}|g" -i "${ROOT}/etc/mail/aliases" + /usr/bin/newaliases + + # Automatical Bind configuration, if Bind is installed + if use bind ; then + einfo "Configuring Bind .." + rm -f "${ROOT}/etc/bind/default.zone" + cp -L "${ROOT}${FROXLOR_DOCROOT}/froxlor/templates/misc/configfiles/gentoo/bind/etc_bind_default.zone" "${ROOT}/etc/bind/default.zone" + sed -e "s||${serverip}|g" -i "${ROOT}/etc/bind/default.zone" + + einfo "Add Gentoo-Froxlor include to Bind configuration ..." + echo "include \"/etc/bind/froxlor_bind.conf\";" >> "${ROOT}/etc/bind/named.conf" + touch "${ROOT}/etc/bind/froxlor_bind.conf" + chown named:0 "${ROOT}/etc/bind/froxlor_bind.conf" + chmod 0600 "${ROOT}/etc/bind/froxlor_bind.conf" + fi + + srv_add_restart() { + einfo "Adding ${1} to 'default' runlevel ..." + rc-update add ${1} default + einfo "(Re)Starting ${1} ..." + "${ROOT}/etc/init.d/${1}" restart + } + + # Automatical service starting + + sleep 2 + if use lighttpd ; then + srv_add_restart lighttpd + else + srv_add_restart apache2 + fi + # NB: this may fail if the user does not have vixie-cron installed + srv_add_restart vixie-cron + if use bind ; then + srv_add_restart named + fi + srv_add_restart proftpd + if ! use dovecot ; then + srv_add_restart courier-authlib + srv_add_restart courier-pop3d + srv_add_restart courier-imapd + if use ssl ; then + srv_add_restart courier-pop3d-ssl + srv_add_restart courier-imapd-ssl + fi + else + srv_add_restart dovecot + fi + if use domainkey && use bind ; then + srv_add_restart dkim-filter + fi + if use fcgid ; then + srv_add_restart nscd + fi + srv_add_restart postfix + + einfo "Configuration completed successfully!" + einfo + local URL="" + if use ssl ; then + URL="https://${servername}/index.php" + else + URL="http://${servername}/index.php" + fi + einfo "You can now open your Froxlor under ${URL}" +} diff --git a/www-apps/froxlor/metadata.xml b/www-apps/froxlor/metadata.xml new file mode 100644 index 0000000..e4a6b92 --- /dev/null +++ b/www-apps/froxlor/metadata.xml @@ -0,0 +1,29 @@ + + + +no-herd + + release@froxlor.org + Upstream Maintainer + +A PHP-based webhosting-oriented control panel for servers. + + Support for the Application Packaging Standard + E-Mail Autoresponder Support for Customers + use AWStats instead of Webalizer + Adds support for writing BIND configuration files + Adds support for writing DKIM DNS-Records and + Filters for them + use Dovecot instead of Courier + Adds support for FCGId + Adds support for FTP Quotas for use with ProFTPd + Adds support for PHP-FPM + use ligHTTPd instead of Apache + Adds support for logging actions in the Panel + Adds support for Quotas for the maildirs of + Customers + use nginx instead of Apache + use pure-FTPd instead of ProFTPd + Adds support for the Ticket System + + diff --git a/www-apps/metadata.xml b/www-apps/metadata.xml new file mode 100644 index 0000000..b776a8d --- /dev/null +++ b/www-apps/metadata.xml @@ -0,0 +1,41 @@ + + + + + The www-apps category contains various world wide web applications. + + + La categoría www-apps contiene paquetes relacionados con la world wide + web (WWW). + + + Die Kategorie www-apps enthält verschiedene WWW-Applikationen wie + beispielsweise Wikis, CMS- oder Blogging-Software. + + + www-appsカテゴリーには様々なワールド・ワイド・ウェブの + アプリケーションが含まれています。 + + + De www-apps categorie bevat verschillende WWW-applicaties zoals bijvoorbeeld + wiki's, CMS- en blogging-software. + + + Nhóm www-apps chứa các ứng dụng web. + + + Táto kategória obsahuje rôzne WWW aplikácie. + + + La categoria www-apps contiene applicazioni per il world wide + web (WWW) come software per wiki, CMS e blog. + + + A categoria www-apps contém várias aplicações relacionadas a + world wide web (WWW). + + + Kategoria www-apps zawiera programy związane z przeglądaniem WWW. + + +