~alpine/aports

testing/otrs: new aport v2 PROPOSED

Valery Kartel
Valery Kartel: 1
 testing/otrs: new aport

 9 files changed, 310 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.alpinelinux.org/~alpine/aports/patches/2474/mbox | git am -3
Learn more about email & git

[alpine-aports] [PATCH v2] testing/otrs: new aport Export this patch

Valery Kartel
Flexible Open Source Service Management Software
http://www.otrs.org/

---
v1 -> v2:

make save Config.pm between reinstalls
move configuration examples from -doc to -setup
add nginx config + fcgi support

---
 testing/otrs/APKBUILD                  | 175 +++++++++++++++++++++++++++++++++
 testing/otrs/otrs-setup.post-deinstall |   5 +
 testing/otrs/otrs-setup.post-install   |  31 ++++++
 testing/otrs/otrs.initd                |  42 ++++++++
 testing/otrs/otrs.nginx.conf           |  25 +++++
 testing/otrs/otrs.post-install         |  17 ++++
 testing/otrs/otrs.post-upgrade         |   1 +
 testing/otrs/otrs.pre-install          |   8 ++
 testing/otrs/otrs.spawn-fcgi           |   6 ++
 9 files changed, 310 insertions(+)
 create mode 100644 testing/otrs/APKBUILD
 create mode 100644 testing/otrs/otrs-setup.post-deinstall
 create mode 100644 testing/otrs/otrs-setup.post-install
 create mode 100644 testing/otrs/otrs.initd
 create mode 100644 testing/otrs/otrs.nginx.conf
 create mode 100644 testing/otrs/otrs.post-install
 create mode 120000 testing/otrs/otrs.post-upgrade
 create mode 100644 testing/otrs/otrs.pre-install
 create mode 100644 testing/otrs/otrs.spawn-fcgi

diff --git a/testing/otrs/APKBUILD b/testing/otrs/APKBUILD
new file mode 100644
index 0000000000..bc88492f84
--- /dev/null
+++ b/testing/otrs/APKBUILD
@@ -0,0 +1,175 @@
# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Maintainer: Valery Kartel <valery.kartel@gmail.com>
pkgname=otrs
pkgver=5.0.16
pkgrel=0
pkgdesc="Flexible Open Source Service Management Software"
url="http://www.otrs.org/"
arch="noarch"
license="AGPL3"
pkgusers="otrs"
pkggroups="www-data"
depends="perl perl-archive-zip perl-crypt-eksblowfish perl-crypt-ssleay
	perl-date-format perl-dbi perl-encode-hanextra perl-io-socket-ssl perl-json-xs
	perl-ldap perl-libwww perl-mail-imapclient perl-net-dns perl-template-toolkit
	perl-text-csv perl-text-csv_xs perl-uri perl-xml-libxml perl-xml-libxslt
	perl-xml-parser perl-yaml-xs ttf-dejavu"
makedepends=""
subpackages="$pkgname-doc $pkgname-dev $pkgname-setup $pkgname-apache2
	$pkgname-nginx $pkgname-bash-completion:bashcomp"
install="$pkgname.pre-install $pkgname.post-install $pkgname.post-upgrade
	$pkgname-setup.post-install $pkgname-setup.post-deinstall"
source="http://ftp.otrs.org/pub/$pkgname/$pkgname-$pkgver.tar.bz2
	$pkgname.initd
	$pkgname.spawn-fcgi
	$pkgname.nginx.conf
	"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare || return 1

	find "$builddir" -type f -exec \
		sed -i 's:/opt/otrs:/var/lib/otrs:g' {} + \
		|| return 1
}

package() {
	local file

	mkdir -p "$pkgdir"/var/lib/$pkgname

	cd "$pkgdir"

	cp -r "$builddir"/* var/lib/$pkgname || return 1
	install -Dm755 "$srcdir"/$pkgname.initd etc/init.d/$pkgname || return 1

	# switch to system fonts
	rm -fr var/lib/$pkgname/var/fonts
	ln -s /usr/share/fonts/ttf-dejavu \
		var/lib/$pkgname/var/fonts

	# fix *.dist files
	for file in var/lib/$pkgname/var/cron/*.dist \
		var/lib/$pkgname/Kernel/Config.pod.dist
	do
		mv $file ${file%.dist} || return 1
	done
}

doc() {
	local file;
	default_doc || return 1

	mkdir -p "$subpkgdir"/var/lib/$pkgname/scripts

	mv "$pkgdir"/var/lib/$pkgname/doc \
		"$subpkgdir"/var/lib/$pkgname || return 1

	for file in $(find "$pkgdir" -name "*.md" -o -name "*.pod" -o -name "*.txt" \
		-o -name "ARCHIVE" -o -name "README"  \
		-o -name "UPGRADING" -o -name "COPYING*")
	do
		file=${file#$pkgdir}
		mkdir -p "$subpkgdir"/${file%/*} || return 1
		mv "$pkgdir"/$file "$subpkgdir"/$file || return 1
	done
}

dev() {
	local file
	default_dev || return 1

	mkdir -p "$subpkgdir"/var/lib/$pkgname/scripts \
		"$subpkgdir"/var/lib/$pkgname/var/httpd/htdocs/js

	mv "$pkgdir"/var/lib/$pkgname/scripts/auto_build \
		"$pkgdir"/var/lib/$pkgname/scripts/tools \
		"$pkgdir"/var/lib/$pkgname/scripts/test \
		"$pkgdir"/var/lib/$pkgname/scripts/contrib \
		"$pkgdir"/var/lib/$pkgname/scripts/rpc-example.pl \
		"$subpkgdir"/var/lib/$pkgname/scripts || return 1

	for file in processes webservices; do
		mkdir -p "$subpkgdir"/var/lib/$pkgname/var/$file
		mv "$pkgdir"/var/lib/$pkgname/var/$file/examples \
			"$subpkgdir"/var/lib/$pkgname/var/$file || return 1
	done

	mv "$pkgdir"/var/lib/$pkgname/var/httpd/htdocs/js/test \
		"$subpkgdir"/var/lib/$pkgname/var/httpd/htdocs/js
}

setup() {
	local file
	pkgdesc="$pkgdesc (initial setup)"
	depends="$pkgname"

	mkdir -p "$subpkgdir"/var/lib/$pkgname/scripts \
		"$subpkgdir"/var/lib/$pkgname/bin/cgi-bin \
		"$subpkgdir"/var/lib/$pkgname/bin/fcgi-bin

	mv "$pkgdir"/var/lib/$pkgname/scripts/DBUpdate-* \
		"$pkgdir"/var/lib/$pkgname/scripts/database \
		"$subpkgdir"/var/lib/$pkgname/scripts || return 1

	mv "$pkgdir"/var/lib/$pkgname/bin/cgi-bin/installer.pl \
		"$subpkgdir"/var/lib/$pkgname/bin/cgi-bin/installer.pl || return 1

	mv "$pkgdir"/var/lib/$pkgname/bin/fcgi-bin/installer.pl \
		"$subpkgdir"/var/lib/$pkgname/bin/fcgi-bin/installer.pl || return 1

	for file in CheckModules CheckSum; do
		mv "$pkgdir"/var/lib/$pkgname/bin/$pkgname.$file.pl \
			"$subpkgdir"/var/lib/$pkgname/bin/$pkgname.$file.pl || return 1
	done

	for file in fetchmailrc mailfilter procmailrc; do
		install -Dm644 "$builddir"/.$file.dist \
			"$subpkgdir"/var/lib/$pkgname/.$file.dist || return 1
	done

	mv "$pkgdir"/var/lib/$pkgname/scripts/apache2-httpd-plack-proxy.conf \
		"$subpkgdir"/var/lib/$pkgname/scripts
}

apache2() {
	pkgdesc="$pkgdesc (apache2 configuration)"
	depends="$pkgname apache2 apache2-mod-perl"

	mkdir -p "$subpkgdir"/etc/apache2/conf.d \
		"$subpkgdir"/var/lib/$pkgname/scripts

	mv "$pkgdir"/var/lib/$pkgname/scripts/apache2-httpd.include.conf \
		"$subpkgdir"/etc/apache2/conf.d/$pkgname.conf || return 1

	mv "$pkgdir"/var/lib/$pkgname/scripts/apache2-perl-startup.pl \
		"$subpkgdir"/var/lib/$pkgname/scripts
}

nginx() {
	pkgdesc="$pkgdesc (nginx configuration)"
	depends="$pkgname fcgiwrap nginx perl-cgi-fast spawn-fcgi"

	install -Dm644 "$srcdir"/$pkgname.spawn-fcgi \
		"$subpkgdir"/etc/conf.d/spawn-fcgi.$pkgname || return 1
	install -Dm644 "$srcdir"/$pkgname.nginx.conf \
		"$subpkgdir"/etc/nginx/$pkgname.conf || return 1

	mkdir -p "$subpkgdir"/etc/init.d
	ln -s spawn-fcgi "$subpkgdir"/etc/init.d/spawn-fcgi.$pkgname
}

bashcomp() {
	pkgdesc="$pkgdesc (bash completion)"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	install -Dm644 "$builddir"/.bash_completion \
		"$subpkgdir"/var/lib/$pkgname/.bash_completion
}

sha512sums="326ebc97b689ce05c33a4f8e5587b891029c168544ab6bea4e5b112b2c75527a605689fd957d7acdebf18e331176db727cca4c87244f22cfdb9b9e4e0735b6c4  otrs-5.0.16.tar.bz2
90d43b350a00fa1648c8add5e2af9b88f78cb583f71438306a9b80ee45a939eda903472b84db1327e0579a5d8c5fd88e3c1e7d55a15106aeef426b16e932363d  otrs.initd
6e6e3577bc45bcabdb23da49aef5cddf7beb926a02ea29a09b2eb0c509667e7064b340bc6f1243d1589e6f68a08eedaadd382a7983036e0334f6d9e10818f5d2  otrs.spawn-fcgi
73e201e3ff934b0b04f397440ba39cd8d2dccc14e25cd00396b741574a9b16f0357c5e80dbdfacc52030e3ea601d1efdd31df60dab367df5d0ce7d54c9db6614  otrs.nginx.conf"
diff --git a/testing/otrs/otrs-setup.post-deinstall b/testing/otrs/otrs-setup.post-deinstall
new file mode 100644
index 0000000000..027f87c441
--- /dev/null
+++ b/testing/otrs/otrs-setup.post-deinstall
@@ -0,0 +1,5 @@
#!/bin/sh

/var/lib/otrs/bin/otrs.SetPermissions.pl --web-group=www-data >/dev/null

exit 0
diff --git a/testing/otrs/otrs-setup.post-install b/testing/otrs/otrs-setup.post-install
new file mode 100644
index 0000000000..eed1d9cbc2
--- /dev/null
+++ b/testing/otrs/otrs-setup.post-install
@@ -0,0 +1,31 @@
#!/bin/sh

/var/lib/otrs/bin/otrs.SetPermissions.pl --web-group=www-data >/dev/null

su -s /bin/sh otrs -c "/var/lib/otrs/bin/otrs.CheckModules.pl"

cat <<EOF
----------------------------------------------------------
*
* Inital setup:
* 1. configure and restart web server
*    - apache: otrs-apache2
*    - nginx: otrs-nginx (uses spawn-fcgi service)
*        - include /etc/nginx/otrs.conf somewhere in 'server' section
*        - rc-update add spawn-fcgi.otrs
*        - service spawn-fcgi.otrs start
* 2. add needed database driver:
*    - mysql: perl-dbd-mysql
*    - postgress: perl-dbd-pg
* 3. go online and continue setup
*    - http://$(hostname -f)/otrs/installer.pl
* 4. enable and start otrs service
*    - rc-update add otrs
*    - service otrs start
* 5. enjoy :)
*
* After setup complete, you can safely remove otrs-setup aport
*
EOF

exit 0
diff --git a/testing/otrs/otrs.initd b/testing/otrs/otrs.initd
new file mode 100644
index 0000000000..5e82854abf
--- /dev/null
+++ b/testing/otrs/otrs.initd
@@ -0,0 +1,42 @@
#!/sbin/openrc-run

description="Open Ticket Management System"
extra_started_commands="reload status"

otrs_cron=/var/lib/otrs/bin/Cron.sh
otrs_daemon=/var/lib/otrs/bin/otrs.Daemon.pl

depend() {
	need net
	after firewall
}

otrs() {
	[ -n "$2" ] && su -s /bin/sh otrs -c "$(eval echo \$otrs_$1) $2" >/dev/null
}

start() {
	ebegin "Starting $RC_SVCNAME"
	/var/lib/otrs/bin/otrs.SetPermissions.pl --web-group=www-data >/dev/null
	otrs daemon start
	otrs cron start
	eend
}

stop() {
	ebegin "Stopping $RC_SVCNAME"
	otrs daemon stop
	otrs cron stop
	eend
}

reload() {
	ebegin "Reloading $RC_SVCNAME"
	otrs daemon restart
	otrs cron restart
	eend
}

status() {
	otrs daemon status
}
diff --git a/testing/otrs/otrs.nginx.conf b/testing/otrs/otrs.nginx.conf
new file mode 100644
index 0000000000..61cf6a0a89
--- /dev/null
+++ b/testing/otrs/otrs.nginx.conf
@@ -0,0 +1,25 @@
#
# include this file somewhere to 'server' section
#
# server {
#       ...
#       include otrs.conf;
#       ...
# }
#

root /var/lib/otrs/var/httpd/htdocs;
index index.html;

location /otrs-web {
	gzip on;
	alias /var/lib/otrs/var/httpd/htdocs;
}

location ~ ^/otrs/(.*\.pl)(/.*)?$ {
	gzip off;
	fastcgi_pass localhost:6877;
	fastcgi_index index.pl;
	include fastcgi_params;
	fastcgi_param SCRIPT_FILENAME /var/lib/otrs/bin/fcgi-bin/$1;
}
diff --git a/testing/otrs/otrs.post-install b/testing/otrs/otrs.post-install
new file mode 100644
index 0000000000..757affecab
--- /dev/null
+++ b/testing/otrs/otrs.post-install
@@ -0,0 +1,17 @@
#!/bin/sh

if [ ! -e /var/lib/otrs/Kernel/Config.pm ]; then
	echo "Initializing /var/lib/otrs/Kernel/Config.pm"
	cp /var/lib/otrs/Kernel/Config.pm.dist /var/lib/otrs/Kernel/Config.pm
fi

rm /var/lib/otrs/Kernel/Config.pm.dist

/var/lib/otrs/bin/otrs.SetPermissions.pl --web-group=www-data

if [ -e /var/lib/otrs/Kernel/Config/Files/ZZZAAuto.pm ]; then
	su -s /bin/sh otrs -c "/var/lib/otrs/bin/otrs.Console.pl Maint::Config::Rebuild"
	su -s /bin/sh otrs -c "/var/lib/otrs/bin/otrs.Console.pl Maint::Cache::Delete"
fi

exit 0
diff --git a/testing/otrs/otrs.post-upgrade b/testing/otrs/otrs.post-upgrade
new file mode 120000
index 0000000000..a405284d6f
--- /dev/null
+++ b/testing/otrs/otrs.post-upgrade
@@ -0,0 +1 @@
otrs.post-install
\ No newline at end of file
diff --git a/testing/otrs/otrs.pre-install b/testing/otrs/otrs.pre-install
new file mode 100644
index 0000000000..377eb65a8a
--- /dev/null
+++ b/testing/otrs/otrs.pre-install
@@ -0,0 +1,8 @@
#!/bin/sh

addgroup -S -g 82 www-data 2>/dev/null

addgroup -S otrs 2>/dev/null
adduser -S -D -H -h /var/lib/otrs -s /sbin/nologin -G otrs -g otrs otrs 2>/dev/null

exit 0
diff --git a/testing/otrs/otrs.spawn-fcgi b/testing/otrs/otrs.spawn-fcgi
new file mode 100644
index 0000000000..c96d46e344
--- /dev/null
+++ b/testing/otrs/otrs.spawn-fcgi
@@ -0,0 +1,6 @@
FCGI_ADDRESS=127.0.0.1
FCGI_PORT=6877

FCGI_PROGRAM=/usr/bin/fcgiwrap
FCGI_USER=otrs
FCGI_GROUP=www-data
-- 
2.11.1



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
View this thread in the archives