updated on Sat Jan 14 00:11:12 UTC 2012
[aur-mirror.git] / freeswitch / run_log.freeswitch
bloba8ca52c32ec505a81d729a108e4607ecd1a92746
1 #!/bin/sh -e
2 if [ $0 != "./run" ];then
3 echo "This script meant to be linked as ./run in a service/log directory only!"
4 exit 1
5 fi
6 logdir=$(basename $(pwd))
7 if [ "$logdir" != "log" ];then
8 echo "This script meant to be run from a service/log directory only!"
9 exit 1
11 if [ -w /var/log ];then
12 if [ -f ./conf ];then
13 source ./conf
15 user_group=${USERGROUP:-daemon:adm}
16 service=$(basename $(dirname $(pwd)))
17 [ -d "/var/log/$service" ] || mkdir -p "/var/log/$service"
18 [ -L ./main ] || [ -d ./main ] || ln -s "/var/log/$service" ./main
19 [ -L ./current ] || ln -s main/current
20 usergroup=$(stat -c "%U:%G" "/var/log/$service")
21 if [ "$usergroup" != "$user_group" ];then
22 chown -R $user_group "/var/log/$service"
24 echo Logging as $user_group to /var/log/$service
25 exec chpst -u $user_group svlogd -t ./main
26 else
27 echo Logging in $PWD
28 exec svlogd -t ./