#!/bin/sh
# first make sure you
# change ASTVARRUNDIR in the main asterisk makefile to look like this
#ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run/asterisk
# add something in here so it's all handled by variables for user and group
# makes more sense if people don't want the default 'asterisk and asterisk'
#
# then own the files to user asterisk
chown --recursive asterisk:asterisk /var/lib/asterisk
chown --recursive asterisk:asterisk /var/log/asterisk
chown --recursive asterisk:asterisk /var/run/asterisk
chown --recursive asterisk:asterisk /var/spool/asterisk
# for the faxing thing use this directory
chown --recursive asterisk:asterisk /var/spool/asterisk-fax
chown --recursive asterisk:asterisk /dev/zap
chmod --recursive u=rwX,g=rX,o= /var/lib/asterisk
chmod --recursive u=rwX,g=rX,o= /var/log/asterisk
chmod --recursive u=rwX,g=rX,o= /var/run/asterisk
chmod --recursive u=rwX,g=rX,o= /var/spool/asterisk
chmod --recursive u=rwX,g=rX,o= /dev/zap
# then own the directories that asterisk needs
chown --recursive root:asterisk /etc/asterisk
chmod --recursive u=rwX,g=rX,o= /etc/asterisk
# if you need to do some stuff in /dev
chown asterisk /dev/tty9
# for alsa
#chown asterisk /dev/dsp
#chown --recursive asterisk /dev/sound
#chown --recursive asterisk /dev/snd
# finally give the asterisk directory group writeable
# this is so the voicemail #'s can be changed
# is this the best way to do it, or should it be based on per file?
chmod g+w /etc/asterisk
# final final, make sure mpg123 is chmod u+s
chmod u+s /usr/local/bin/mpg123