added aur/freeswitch-git

This commit is contained in:
Kevin Mihelich 2012-04-22 18:19:39 -04:00
parent 2592c56fd4
commit c930873f06
9 changed files with 675 additions and 0 deletions

View file

@ -0,0 +1,33 @@
2010-11-15 TJ Vanderpoel <tj@rubyists.com>
* 20101126-8 :
Added /var/spool/freeswitch/storage
2010-10-26 TJ Vanderpoel <tj@rubyists.com>
* 20101026-7 :
Changed handling of configuration so that it
will not be overwritten on upgrades
* 20101026-5 :
Removed libtool files from lib dirs
Moved primary --prefix to /var/lib/freeswitch
More symlinks to get the mod/*.so files into
/usr/lib/freeswitch where namcap wants them.
* 20101026-4 :
Got rid of empty vars in PKGBUILD
* 20101026-3 :
Moved ChangeLog to changelog= and out of the sources
array.
Using $srcdir instead of $startdir for install commands
* 20101026-2 :
Added README and /usr/share/doc/freeswitch files
* 20101026-1 :
added ChangeLog.
Tidied up the /etc/rc.d/freeswitch script and added
the 'fgstart' option to start under a supervisor such
as runit or daemontools.

232
aur/freeswitch-git/PKGBUILD Normal file
View file

@ -0,0 +1,232 @@
# This builds the FreeSWITCH open source telephone engine
# from the freeswitch git. It enables the following modules
# not enabled in the standard freeswitch build:
# * mod_callcenter
# * mod_xml_curl
# And disables the following standard modules:
# * mod_dialplan_asterisk
# * mod_say_ru
# * mod_spidermonkey
# * mod_lua
# You can modify this and other options in the BUILD CONFIGURATION section below
# Built using http://wiki.archlinux.org/index.php/VCS_PKGBUILD_Guidelines
# Maintainer: TJ Vanderpoel <tj@rubyists.com>
# BUILD CONFIGURATION BEGINS #
# ENABLE THIS IF YOU WANT ODBC IN THE CORE (uncomment it)
# You must have unixodbc installed or the build will fail
#_odbc=--enable-core-odbc-support
# SET THIS TO GET HIGHER QUALITY SOUNDFILES
# Value can be "hd-", "uhd-", or "cd-" to get 16k, 32k, or 48k sounds.
# By default we only download the 8k sounds. If you only use g711 or
# 8k codecs, leave this as-is
_sounds=""
# ADDED MODULES
# If you don't need/want these modules remove them from _enabled_modules
# You can add any modules here you wish to add, make sure they're not
# in _disabled_modules, though
#
# xml_int/mod_xml_curl - Remote http dialplan lookups/control
# xml_int/mod_xml_cdr - Remote http dialplan lookups/control
# applications/mod_callcenter - Inbound call queueing system
_enabled_modules=(xml_int/mod_xml_curl
xml_int/mod_xml_cdr
formats/mod_shout
applications/mod_callcenter)
# DISABLED MODULES
# Remove from _disabled_modules if you want to build these
#
# languages/mod_spidermonkey - server-side javascript
# languages/mod_lua - server-side lua
# say/mod_say_ru - Russian phrases
# dialplans/mod_dialplan_asterisk - Legacy dialplan
_disabled_modules=(languages/mod_spidermonkey
languages/mod_lua
say/mod_say_ru
dialplans/mod_dialplan_asterisk)
# NOTE: We build --without-python due to Arch defaulting python3 as python.
# Uncomment the following to attempt building it anyway
#_python=--with-python
# CONCURRENT BOOTSTRAP
# Uncomment this to enable backgrounded concurrent bootstrap operations.
# You will suffer a lot of autotools scroll from this, Fair Warning.
#_concurrent="-j"
# BUILD CONFIGURATION ENDS #
# #
# CHANGE ANYTHING BELOW HERE AT YOUR OWN RISK! #
# #
plugrel=1
pkgname=freeswitch-git
pkgver=20120422
pkgrel=1
pkgdesc="Open Source soft switch (telephony engine) built from a specific, stable git commit tag"
arch=('i686' 'x86_64')
url="http://freeswitch.org"
license=('MPL')
depends=("util-linux-ng")
makedepends=('git' 'libjpeg' 'curl')
optdepends=('unixodbc: for odbc support in the core'
'python: for some contrib scripts')
provides=('freeswitch')
conflicts=('freeswitch')
install=freeswitch.install
source=('freeswitch.conf.d' 'freeswitch.rc.conf' 'README.freeswitch' 'run.freeswitch' 'run_log.freeswitch' 'conf_log.freeswitch')
changelog='ChangeLog'
_gitroot="git://git.freeswitch.org/freeswitch.git"
_gitname="freeswitch"
enable_module() {
_fs_mod=$1
sed -i -e "s|^#${_fs_mod}|${_fs_mod}|" modules.conf
}
disable_module() {
_fs_mod=$1
sed -i -e "s|^${_fs_mod}|#${_fs_mod}|" modules.conf
}
build() {
cd "$srcdir"
msg "Connecting to GIT server...."
if [ -d $_gitname ] ; then
cd $_gitname
git pull origin master
msg "The local files are updated."
else
git clone --depth 1 $_gitroot
msg "FreeSWITCH repository cloned"
fi
msg "GIT checkout done or server timeout"
msg "Starting make..."
rm -rf "$srcdir/$_gitname-build"
cp -a "$srcdir/$_gitname/" "$srcdir/${_gitname}-build"
cd "$srcdir/$_gitname-build"
# BUILD BEGINS
msg "Bootstrapping..."
./bootstrap.sh ${_concurrent} > /dev/null
msg "Bootstrap Complete"
# MODULE ENABLE/DISABLE
for _mod in ${_enabled_modules[@]};do
msg "Enabling $_mod"
enable_module $_mod
done
for _mod in ${_disabled_modules[@]};do
msg "Disabling $_mod"
disable_module $_mod
done
msg "Module Configuration Complete, Stop Now with Ctrl-C if the above is not correct"
sleep 5
# CONFIGURE
./configure --prefix=/var/lib/freeswitch ${_python:---without-python} \
--bindir=/usr/bin --sbindir=/usr/sbin --localstatedir=/var \
--sysconfdir=/etc/freeswitch --datarootdir=/usr/share \
--libexecdir=/usr/lib/freeswitch --libdir=/usr/lib/freeswitch \
--includedir=/usr/include/freeswitch ${_odbc} \
--with-recordingsdir=/var/spool/freeswitch/recordings \
--with-dbdir=/var/spool/freeswitch/db \
--with-pkgconfigdir=/usr/lib/pkgconfig \
--with-logfiledir=/var/log/freeswitch \
--with-modinstdir=/usr/lib/freeswitch/mod \
--with-rundir=/run/freeswitch
# COMPILE
make
}
enable_mod_xml() {
_fs_mod=$(basename $1)
if [ "x$(grep $_fs_mod $pkgdir/etc/freeswitch/autoload_configs/modules.conf.xml)" == "x" ];then
msg "Adding missing module ${_fs_mod} to modules.conf.xml"
sed -i -e "s|^\(\s*</modules>\)|\t\t<\!-- added by archlinux package -->\n\t\t<load module=\"${_fs_mod}\"/>\n\1|" \
"$pkgdir/etc/freeswitch/autoload_configs/modules.conf.xml"
else
msg "Enabling module ${_fs_mod} in modules.conf.xml"
sed -i -e "s|^\(\s*\)<\!--\s*\(<load module=\"${_fs_mod}\"/>\)\s*-->|\1\2|" \
"$pkgdir/etc/freeswitch/autoload_configs/modules.conf.xml"
fi
}
disable_mod_xml() {
_fs_mod=$(basename $1)
msg "Disabling module ${_fs_mod} in modules.conf.xml"
sed -i -e "s|^\(\s*\)\(<load module=\"${_fs_mod}\"/>\)|\1<\!-- \2 -->|" \
"$pkgdir/etc/freeswitch/autoload_configs/modules.conf.xml"
}
package() {
cd "$srcdir/$_gitname-build"
make DESTDIR="$pkgdir/" install
make DESTDIR="$pkgdir/" ${_sounds}moh-install
make DESTDIR="$pkgdir/" ${_sounds}sounds-install
cd "$pkgdir" # MUY IMPORTANT, $PWD is $pkgdir from here on out
# Mangle freeswitch's installed dirs into a more compliant structure,
# leaving symlinks in their place so freeswitch doesn't notice.
ln -s /var/log/freeswitch var/lib/freeswitch/log
ln -s /var/spool/freeswitch/db var/lib/freeswitch/db
ln -s /var/spool/freeswitch/recordings var/lib/freeswitch/recordings
install -D -m 0755 -d var/spool/freeswitch/storage && \
ln -s /var/spool/freeswitch/storage var/lib/freeswitch/storage
rm usr/lib/freeswitch/mod/*.la 2>/dev/null|| true
rm usr/lib/freeswitch/*.la 2>/dev/null || true
ln -s /usr/lib/freeswitch/mod var/lib/freeswitch/mod
install -D "$srcdir/freeswitch.rc.conf" etc/rc.d/freeswitch
install -D -m 0644 "$srcdir/freeswitch.conf.d" etc/conf.d/freeswitch
install -D -m 0644 "$srcdir/README.freeswitch" usr/share/doc/freeswitch/README
cp -a "$srcdir/${_gitname}-build/docs" usr/share/doc/freeswitch
install -D -m 0755 -d usr/share/doc/freeswitch/support-d
cp -a "$srcdir/${_gitname}-build/support-d" usr/share/doc/freeswitch/
install -D -m 0755 -d usr/share/doc/freeswitch/scripts
cp -a "$srcdir/${_gitname}-build/scripts" usr/share/doc/freeswitch/
# Copy upstream confs
install -D -m 0755 -d usr/share/doc/freeswitch/examples/conf.default
install -D -m 0755 -d usr/share/doc/freeswitch/examples/conf.archlinux
ln -s /etc/freeswitch var/lib/freeswitch/conf
cp -a etc/freeswitch/* usr/share/doc/freeswitch/examples/conf.default/
for _mod in ${_enabled_modules[@]};do
enable_mod_xml $_mod
done
for _mod in ${_disabled_modules[@]};do
disable_mod_xml $_mod
done
mv etc/freeswitch/* usr/share/doc/freeswitch/examples/conf.archlinux/
rmdir etc/freeswitch
install -D -m0755 -d usr/share/freeswitch/conf
install -D -m 0755 "$srcdir/run.freeswitch" etc/sv/freeswitch/run
install -D -m 0755 "$srcdir/run_log.freeswitch" etc/sv/freeswitch/log/run
install -D -m 0644 "$srcdir/conf_log.freeswitch" etc/sv/freeswitch/log/conf
}
md5sums=('f674b302edeb1895bbefcaf7bb8510ca'
'9952aa0f114ee890ebd1170b7264e907'
'bfa0c6c70c8173bc78fd228bd42a98ef'
'4126dcbe4e1e4f689230a0fe40edcb68'
'e9f0bdde366bca6fd29a9202818f3591'
'e6411d793501c29ec4afd6d54018de1b')

View file

@ -0,0 +1,228 @@
== USAGE ==
Start the freeswitch daemon with /etc/rc.d/freeswitch.
Add 'freeswitch' to DAEMONS in /etc/rc.conf and it will start at boot time.
All configuration is done in /etc/freeswitch/.
/usr/bin/fs_cli will bring up the console to freeswitch once it's running.
== SUPPORT ==
See http://wiki.freeswitch.org for up-to-date configuration documentation.
Official (paid) support available through http://freeswitch.org or
consulting at freeswitch dot org.
#freeswitch on Freenode IRC network.
== DESCRIPTION ==
From http://freeswitch.org:
Welcome To FreeSWITCH
The World's First Cross-Platform Scalable FREE Multi-Protocol Soft Switch
FreeSWITCH is a scalable open source cross-platform telephony platform designed to route and
interconnect popular communication protocols using audio, video, text or any other form of media.
It was created in 2006 to fill the void left by proprietary commercial solutions. FreeSWITCH also
provides a stable telephony platform on which many telephony applications can be developed using
a wide range of free tools.
FreeSWITCH was originally designed and implemented by Anthony Minessale with the help of Brian West
and Michael Jerris. All 3 are former developers of the popular Asterisk open source PBX. The project
was initiated to focus on several design goals including modularity, cross-platform support,
scalability and stability. Today, many more developers and users contribute to the project on a daily
basis.
We support various communication technologies such as Skype, SIP, H.323 and GoogleTalk making it easy
to interface with other open source PBX systems such as sipXecs, Call Weaver, Bayonne, YATE or
Asterisk.
FreeSWITCH supports many advanced SIP features such as presence/BLF/SLA as well as TCP TLS and sRTP.
It also can be used as a transparent proxy with and without media in the path to act as a SBC
(session border controller) and proxy T.38 and other end to end protocols.
FreeSWITCH supports both wide and narrow band codecs making it an ideal solution to bridge legacy
devices to the future. The voice channels and the conference bridge module all can operate at 8, 12,
16, 24, 32 or 48 kilohertz and can bridge channels of different rates. The G.729 codec is also
available under a commercial license.
FreeSWITCH builds natively and runs standalone on several operating systems including Windows,
Mac OS X, Linux, BSD and Solaris on both 32 and 64 bit platforms.
FreeSWITCH supports FAX, both over audio and T.38, and can gateway between the two.
Our developers are heavily involved in open source and have donated code and other resources to other
telephony projects including openSER, sipXecs, The Asterisk Open Source PBX and Call Weaver.
== FEATURES ==
From http://wiki.freeswitch.org/wiki/Specsheet:
Possible Uses
* Rating & Routing Server
* Transcoding B2BUA
* IVR & Announcement Server
* Conference Server
* Voicemail Server
* SBC (Session Border Controller)
* Basic Topology Hiding Session Border Controller
* Zaptel, Sangoma, Rhino, PIKA Hardware Support (Analog and PRI), and Khomp Brazilian telephony hardware manufacturer
* Fax server
* T.38 gateway, termination, and origination mode
* T.30 to T.38 and T.38 to T.30 gateway
See also: mod_spandsp
And, of course, a PBX
Features
* Centralized User/Domain Directory (directory.xml)
* Nano Second CDR granularity
* Call recording (In Stereo caller/callee left/right)
* High Performance Multi-Threaded Core engine
* Configuration via cURL to your HTTP server (mod_xml_curl).
* XML Config files for easy parsing.
* Protocol Agnostic
* ZRTP support for transparent RTP based key exchange and encryption
* Configurable RFC 2833 Payload type
* Inband DTMF generation and detection.
* Software based Conference (no hardware requirement)
* Wideband Conferencing
* Media / No Media modes
* Proper ENUM/ISN dialing built in
* Detailed CDR in XML
* Radius CDR
* Subscription server
* Shared Line Appearances
* Bridged Line Appearances
* Enterprise/Carrier grade Eventing Engine. (XML Events, Name Value Events, Multicast Events)
* Loadable File formats and streaming
* Stream to and play from Shoutcast and Icecast
* Multi-lingual Speech Phrase Interface
* ASR/TTS support (native and via MRCP)
* Basic IP/PBX features
* Automated Attendant
* Custom Ring Back Tones (early_media)
* XML-RPC support
* Multiple format CDRs supported
* SQL Engine provides session persistence
* Thread Isolation
* Parallel Hunting
* Serial Hunting
* Mozilla Public License
* Support
* Paid support available
* Free support via IRC & E-mail
* Many supported codecs
* CELT (32 kHz ahd 48 kHz)
* G.722.1 (wideband)
* G.722.1C (wideband 32 kHz)
* G.722 (wideband)
* G.711
* G.726 (16k, 24k, 32k, 48k) AAL2 and RFC 3551
* G.723.1 (passthrough)
* G.729AB (Requires a license unless using passthrough)
* AMR (passthrough)
* iLBC
* Speex (narrow and wideband)
* LPC-10
* DVI4 (ADPCM) 8 kHz and 16 kHz
* SILK
* Video Codecs (passthrough):
* Theora
* H.261
* H.263
* H.264
* MP4
* More Codec Information: http://wiki.freeswitch.org/wiki/Codecs
* Live Migration of calls from one FreeSWITCH box to another. See
http://wiki.freeswitch.org/wiki/Freeswitch_HA
Applications
* Voicemail
* Multitenancy - Enterprise/Carrier configuration
* Time of Day Greetings
* Urgent Message Tagging
* E-mail Delivery
* Playback and Rerecord messages before delivery.
* Keys are templates so you can rearrange to fit your needs.
* Callback support from inside voicemail.
* Podcast of Voicemail (RSS)
* Message Waiting Indicator (MWI)
* Support for Queues (via mod_fifo or mod_callcenter)
* Parking (via mod_fifo)
* Conference
* Software based Conferencing without any hardware requirements.
* Wideband conferences.
* Multiple on-demand or scheduled conferences with entry/exit announcements
* Play files into the conference or a single member.
* Relationships
* TTS integration
* Transfers
* Outbound Calling
* Configurable Key Lay
* Volume, Gain and Energy level per call.
* Bridge to Conference transition
* Multi Party outbound dialing.
* Inbound Call Center Queues
* RSS Reader
* Fax endpoint, gateway and passthrough mode.
* T.30 (G.711) Audio Fax (via mod_spandsp) formerly known as mod_fax.
* T.38 faxing (gateway, endpoint and passthrough)
Protocols
* SIP
* UDP, TCP, SCTP and TLS transports for full SIP compliance.
* IPv6 Support
* SIP Session timers
* RTP Timers
* RFC 3263 (SRV and NAPTR)
* SRTP via SDES (Works with Polycom, Snom, Linksys and Grandstream)
* Blind SIP Registration
* STUN Support
* Jitter buffer
* NAT Support
* Distributed SIP registrations
* Late Codec Negotiation
* Multiple SIP registrations per user account.
* Multitenancy - Multiple SIP UAs
* SIP Reinvites.
* Can act as an SBC (Session Border Controller)
* Manage Presence
* SIP/SIMPLE (can gateway to other chat protocols)
* SIP Multicast Paging support for Linksys and Snom
* Intercom/AutoAnswer support.
* Call features like Call Hold (Re-INVITE), Blind Transfer (REFER), Call Forward (302), etc.
* Jingle
* Interop with Google Talk, Google Voice, and Telepathy
* H.323 with mod_opal (opalvoip.org)
* mod_h323 - H.323 Endpoint module based on the h323plus library.
* mod_skinny - Skinny Call Control Protocol (SCCP)
Languages
* JavaScript (Using the SpiderMonkey JavaScript engine.)
* ODBC Support from inside your JavaScript
* Extendable modules for JavaScript
* Tone Generation
* Python
* Perl
* Lua
Cross Platform
* Builds native on Windows in MSVC
* Builds on Mac OS X, Linux, Solaris and *BSD.
* Minimum/Recommended System Requirements
* 32-bit OS (64-bit recommended)
* 512MB RAM (1GB recommended)
* 50MB of Disk Space
* System requirements depend on your deployment needs. We recommend you plan for 50% duty cycle.
Performance
* Tested under load for over 100 hours
* 10,000,000+ calls
* At rates exceeding 50 CPS
* Performance will vary depending on application. You will need to test for your particular situation.

View file

@ -0,0 +1 @@
USERGROUP=freeswitch:daemon

View file

@ -0,0 +1,3 @@
# options to start freeswitch with
# We default to -nonat, if you need nat, remove it
FREESWITCH_OPTS="-nonat"

View file

@ -0,0 +1,52 @@
pre_install() {
getent group freeswitch > /dev/null
if [ $? -ne 0 ];then
echo 'Adding group freeswitch'
groupadd -r freeswitch
fi
id freeswitch > /dev/null
if [ $? -ne 0 ];then
echo 'Adding user freeswitch'
useradd -r freeswitch -g freeswitch
fi
}
post_install() {
echo "FreeSWITCH is installed!"
echo "<<<WARNING>>> You MUST change the default_password in /etc/freeswitch/vars.xml
Failure to do so will leave your default extension 1000 vulnerable"
echo "FreeSWITCH's default configuration is available in
/usr/share/doc/freeswitch/examples/conf.default, with this package's modified
version in /usr/share/doc/freeswitch/examples/conf.archlinux"
post_upgrade
}
post_upgrade() {
if [ -d /etc/freeswitch -a ! -L /etc/freeswitch ];then
echo "Moving your old configs (/etc/freeswitch) to /usr/share/freeswitch/conf/local"
mv /etc/freeswitch /usr/share/freeswitch/conf/local
ln -s /usr/share/freeswitch/conf/local /etc/freeswitch
fi
[ -d /usr/share/freeswitch/conf/pbx ] || cp -a /usr/share/doc/freeswitch/examples/conf.archlinux/ /usr/share/freeswitch/conf/pbx
chown -R freeswitch:freeswitch /usr/share/freeswitch/conf/pbx
if [ ! -L /etc/freeswitch ];then
echo "Linking /usr/share/freeswitch/conf/pbx to /etc/freeswitch"
ln -s /usr/share/freeswitch/conf/pbx /etc/freeswitch
fi
chown -R freeswitch:freeswitch /var/{run,spool,log}/freeswitch
chown -R freeswitch:freeswitch /etc/sv/freeswitch
echo "The running configuration directory is symlinked as /etc/freeswitch"
echo
echo "FreeSWITCH can be started with rc.d freeswitch start or /etc/sv/freeswitch/run"
echo "To start on boot add freeswitch to /etc/rc.conf or supervise the /etc/sv/freeswitch directory"
}
post_remove() {
rm /etc/freeswitch
echo "Not removing /usr/share/freeswitch/conf/ config directories!! If you do not want to keep them, rm -rf them away"
userdel freeswitch
getent group freeswitch &> /dev/null && groupdel freeswitch
true
}
# vim:set ts=2 sw=2 et:

View file

@ -0,0 +1,78 @@
#!/bin/bash
daemon_name=freeswitch
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/$daemon_name
get_pid() {
pidof -o %PPID $daemon_name
}
rundir=/run/freeswitch
[ -d $rundir ] || mkdir $rundir
chown freeswitch $rundir
case "$1" in
fgstart)
stat_busy "Starting $daemon_name daemon in the foreground"
stat_done
ulimit -s 240
exec su -c "/usr/bin/freeswitch $FREESWITCH_OPTS -nf" freeswitch
;;
start)
stat_busy "Starting $daemon_name daemon"
PID=$(get_pid)
if [ -z "$PID" ]; then
[ -f $rundir/$daemon_name.pid ] && rm -f $rundir/$daemon_name.pid
# RUN
ulimit -s 240
su -c "/usr/bin/freeswitch $FREESWITCH_OPTS" freeswitch
#
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
echo $(get_pid) > $rundir/$daemon_name.pid
add_daemon $daemon_name
stat_done
fi
else
stat_fail
exit 1
fi
;;
stop)
stat_busy "Stopping $daemon_name daemon"
PID=$(get_pid)
# KILL
[ ! -z "$PID" ] && kill $PID &> /dev/null
#
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
rm -f $rundir/$daemon_name.pid &> /dev/null
rm_daemon $daemon_name
stat_done
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
status)
stat_busy "Checking $daemon_name status";
ck_status $daemon_name
fs_cli -x 'status'
;;
*)
echo "usage: $0 {start|stop|restart|status|fgstart}"
esac
exit 0

View file

@ -0,0 +1,19 @@
#!/bin/sh -e
. /etc/conf.d/freeswitch
[ -d /run/freeswitch ] || mkdir /run/freeswitch
chown freeswitch /run/freeswitch
ulimit -c unlimited # The maximum size of core files created.
ulimit -d unlimited # The maximum size of a process's data segment.
ulimit -f unlimited # The maximum size of files created by the shell (default option)
ulimit -i unlimited # The maximum number of pending signals
ulimit -n 999999 # The maximum number of open file descriptors.
ulimit -q unlimited # The maximum POSIX message queue size
ulimit -u unlimited # The maximum number of processes available to a single user.
ulimit -v unlimited # The maximum amount of virtual memory available to the process.
ulimit -x unlimited # ???
ulimit -l unlimited # The maximum size that may be locked into memory.
ulimit -s 240 # The maximum stack size
ulimit -a # All current limits are reported.
echo "Starting Freeswitch with ${FREESWITCH_OPTS}"
exec chpst -u freeswitch:daemon /usr/bin/freeswitch -u freeswitch -g daemon -nf -nc ${FREESWITCH_OPTS} 2>&1

View file

@ -0,0 +1,29 @@
#!/bin/sh -e
if [ $0 != "./run" ];then
echo "This script meant to be linked as ./run in a service/log directory only!"
exit 1
fi
logdir=$(basename $(pwd))
if [ "$logdir" != "log" ];then
echo "This script meant to be run from a service/log directory only!"
exit 1
fi
if [ -w /var/log ];then
if [ -f ./conf ];then
source ./conf
fi
user_group=${USERGROUP:-daemon:adm}
service=$(basename $(dirname $(pwd)))
[ -d "/var/log/$service" ] || mkdir -p "/var/log/$service"
[ -L ./main ] || [ -d ./main ] || ln -s "/var/log/$service" ./main
[ -L ./current ] || ln -s main/current
usergroup=$(stat -c "%U:%G" "/var/log/$service")
if [ "$usergroup" != "$user_group" ];then
chown -R $user_group "/var/log/$service"
fi
echo Logging as $user_group to /var/log/$service
exec chpst -u $user_group svlogd -t ./main
else
echo Logging in $PWD
exec svlogd -t ./
fi