diff --git a/resources/rhel/phabricator.init b/resources/rhel/phabricator.init new file mode 100644 --- /dev/null +++ b/resources/rhel/phabricator.init @@ -0,0 +1,85 @@ +#!/bin/sh +# +# phabricator - applications that help software companies build better software +# +# chkconfig: - 99 01 +# description: Phabricator is a collection of open source web \ +# applications that help software companies build better software. + +# http://www.phabricator.org +### BEGIN INIT INFO +# Provides: phabricator +# Required-Start: network mysqld +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: +# Default-Stop: +# Short-Description: +# Description: +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +exec="/opt/phacility/phabricator/bin/phd" +prog=$(basename $exec) +runas=phabricator +rundir=/var/run/phabricator + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +lockfile=/var/lock/subsys/$prog + +if ! [ -e "$rundir" ]; then + mkdir "$rundir" + chmod 0700 "$rundir" + chown phabricator:phabricator "$rundir" +fi + +start() { + echo -n $"Starting $prog: " + sudo -H -u "${runas}" $exec start + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + sudo -H -u "${runas}" $exec stop + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + sudo -H -u "${runas}" $exec restart +} + +case "$1" in + start|stop|restart) + $1 + ;; + force-reload) + restart + ;; + status) + sudo -H -u "${runas}" $exec status + ;; + try-restart|condrestart) + if status $prog >/dev/null ; then + restart + fi + ;; + reload) + action $"Service ${0##*/} does not support the reload action: " \ + /bin/false + exit 3 + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" + exit 2 +esac diff --git a/resources/rhel/phabricator.spec b/resources/rhel/phabricator.spec new file mode 100644 --- /dev/null +++ b/resources/rhel/phabricator.spec @@ -0,0 +1,158 @@ +%define version 0 +%define release %{build_timestamp}.1%{?dist} +%define build_timestamp %(date --utc +"%Y%m%d%H%M") + +Name: phabricator +Version: %{version} +Release: %{release} +Summary: collection of web applications to help build software + +Group: Web +License: Apache 2.0 +URL: http://www.phabricator.org +Source0: https://github.com/phacility/libphutil.git +Source1: https://github.com/phacility/arcanist.git +Source2: https://github.com/phacility/phabricator.git + +BuildRequires: git +BuildArch: noarch +Requires(pre): shadow-utils +Requires(post): chkconfig +Requires(preun): chkconfig initscripts +Requires: httpd git php php-cli php-mysql php-process php-devel php-gd +Requires: php-pecl-apc php-pecl-json php-mbstring mysql-server +Requires: phabricator-arcanist = %{version}-%{release} +Requires: phabricator-libphutil = %{version}-%{release} +AutoReq: no + +%description +Phabricator is an open source collection of web applications which help +software companies build better software. + +%package arcanist +Summary: command-line interface to Phabricator +Requires: php-cli +Requires: phabricator-libphutil = %{version}-%{release} +AutoReq: no + +%description arcanist +Arcanists provides command-line access to many Phabricator tools (like +Differential, Files, and Paste), integrates with static analysis ("lint") and +unit tests, and manages common workflows like getting changes into Differential +for review. + +%package libphutil +Summary: a collection of utility classes and functions for PHP +AutoReq: no + +%description libphutil +libphutil is a collection of utility classes and functions for PHP. Some +features of the library include: +- libhutil library system +- futures +- filesystem +- xsprintf +- AAST/PHPAST +- Remarkup +- Daemons +- Utilities + +%prep +if [[ ! -e libphutil ]] +then + git clone https://github.com/phacility/libphutil.git +else + (cd libphutil && git pull --rebase) +fi + +if [[ ! -e arcanist ]] +then + git clone https://github.com/phacility/arcanist.git +else + (cd arcanist && git pull --rebase) +fi + + +if [[ ! -e phabricator ]] +then + git clone https://github.com/phacility/phabricator.git +else + (cd phabricator && git pull --rebase) +fi + + +%build +echo Nothing to build. + +%install +DEST=${RPM_BUILD_ROOT}/opt/phacility +mkdir -p ${DEST} +for dir in libphutil arcanist phabricator; do + export dir + ( cd $dir ; git archive --format=tar HEAD ) | + ( cd ${DEST}; mkdir $dir; cd $dir; tar -x ) + echo "$dir $( cd $dir ; git rev-list -n1 HEAD )" >>${DEST}/GIT-REVS +done + +mkdir -p ${RPM_BUILD_ROOT}/var/lib/phabricator +mkdir ${RPM_BUILD_ROOT}/var/lib/phabricator/files +mkdir ${RPM_BUILD_ROOT}/var/lib/phabricator/repo + +mkdir -p ${RPM_BUILD_ROOT}%{_initddir} +cp phabricator/resources/rhel/phabricator.init \ + ${RPM_BUILD_ROOT}%{_initddir}/phabricator + +mkdir -p ${RPM_BUILD_ROOT}/var/log/phabricator + +%clean +rm -rf $RPM_BUILD_ROOT + +%pre +getent group phabricator >/dev/null || groupadd -r phabricator +getent passwd phabricator >/dev/null || \ + useradd -r -g phabricator -d /var/lib/phabricator -s /sbin/nologin \ + -c "Daemon user for Phabricator" phabricator + +%post +CFG=/opt/phacility/phabricator/bin/config +if ! [ -e /opt/phacility/phabricator/conf/local/local.json ]; then + $CFG set repository.default-local-path /var/lib/phabricator/repo + $CFG set storage.local-disk.path /var/lib/phabricator/files + $CFG set storage.upload-size-limit 10M + $CFG set phabricator.base-uri http://$(hostname -f)/ + $CFG set metamta.default-address phabricator@$(hostname -f) + $CFG set metamta.domain $(hostname -f) + $CFG set phd.user phabricator + $CFG set phd.log-directory /var/log/phabricator + $CFG set phd.pid-directory /var/run/phabricator +fi + +/sbin/chkconfig --add phabricator + +%preun +if [ $1 -eq 0 ] ; then + /sbin/service phabricator stop >/dev/null 2>&1 + /sbin/chkconfig --del phabricator +fi + + + +%files +%defattr(-,root,root,-) +/opt/phacility/phabricator +%attr(0755,-,-) %{_initddir}/phabricator +%dir %attr(0750, phabricator, phabricator)/var/lib/phabricator +%dir %attr(2750, phabricator, phabricator) /var/lib/phabricator/repo +%dir %attr(0700, apache, apache) /var/lib/phabricator/files +%dir %attr(0750, phabricator, phabricator)/var/log/phabricator + +%files arcanist +/opt/phacility/arcanist +/opt/phacility/GIT-REVS + +%files libphutil +/opt/phacility/libphutil +/opt/phacility/GIT-REVS + + +%changelog