SAIL 4 RPM Scriptlets

From sailpbx
Revision as of 05:19, 1 March 2013 by Apmutha (talk | contribs) (Post Install)
Jump to: navigation, search

SAIL v4.0.0 RPM Scripts

The version referred to here is SAIL v4.0.0-43.

The following will yield all the scripts in one go:

rpm -qp --scripts filename.rpm

Pre Install

None

Post Install

# rpm -qp --qf "%{postin}\n" sail-4.0.0-43.noarch.rpm

/bin/grep -q www /etc/passwd
if [  "$?" -ne "0" ] ; then
        /usr/sbin/useradd -s /sbin/nologin www
fi

[ ! -e /etc/asterisk/sark_customer_agents_main.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_agents_main.conf
[ ! -e /etc/asterisk/sark_customer_extensions_globals.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_extensions_globals.conf
[ ! -e /etc/asterisk/sark_customer_iax_main.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_iax_main.conf
[ ! -e /etc/asterisk/sark_customer_queues_main.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_queues_main.conf
[ ! -e /etc/asterisk/sark_customer_sip_main.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_sip_main.conf
[ ! -e /etc/asterisk/sark_customer_vmail_main.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_vmail_main.conf

[ ! -e /etc/asterisk/sark_customer_agents_header.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_agents_header.conf
[ ! -e /etc/asterisk/sark_customer_queues_header.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_queues_header.conf
[ ! -e /etc/asterisk/sark_customer_vmail_header.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_vmail_header.conf

[ ! -e /etc/asterisk/sark_customer_manager.conf ] && /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_manager.conf

[ ! -e /opt/sark/otrr/var/spool/asterisk/monitor ] && /bin/mkdir -p /opt/sark/otrr/var/spool/asterisk/monitor
[ ! -e /opt/sark/mixmon/var/spool/asterisk/monitor ] && /bin/mkdir -p /opt/sark/mixmon/var/spool/asterisk/monitor
[ ! -e /var/spool/asterisk/monstage ] && /bin/mkdir -p /var/spool/asterisk/monstage
[ ! -e /var/spool/asterisk/monout ] && /bin/mkdir -p /var/spool/asterisk/monout

[ ! -e /opt/sark/passwd/htpasswd ] && /bin/cp -f /opt/sark/cache/htpasswd /opt/sark/passwd/htpasswd


if [ ! -e /etc/asterisk/sark_customer_iax_header.conf ]; then
        /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_iax_header.conf
        /bin/echo "language=en-gb" >> /etc/asterisk/sark_customer_iax_header.conf
fi

if [ ! -e /etc/asterisk/sark_customer_sip_header.conf ]; then
        /bin/cp -f /opt/sark/cache/template_cust.conf /etc/asterisk/sark_customer_sip_header.conf
        /bin/echo "language=en-gb" >> /etc/asterisk/sark_customer_sip_header.conf
fi

#/bin/grep -q asterisk /etc/group
#if [  "$?" -eq "0" ] ; then
        /usr/sbin/usermod -a -G asterisk www
        /usr/sbin/usermod -a -G nobody www
#fi

#
#       for file in `ls /opt/sark/etc/asterisk` ; do
#               if [ ! -e /etc/asterisk/$file ] ; then
#                               /bin/ln -s /opt/sark/etc/asterisk/$file /etc/asterisk/$file
#               fi
#       done
#

        /bin/chown -R www:www   /opt/sark/www
        /bin/chown -R www:www   /opt/sark/db
        /bin/chown -R www:www   /opt/sark/passwd
        /bin/chown -R www:www   /opt/sark/cache

        /bin/chown -R asterisk:asterisk /etc/dahdi
        /bin/chown -R asterisk:asterisk /opt/sark/otrr/var/spool/asterisk/monitor
        /bin/chown -R asterisk:asterisk /opt/sark/mixmon/var/spool/asterisk/monitor
#       /bin/chown -R asterisk:asterisk /opt/sark/etc/asterisk

        /bin/chown -R asterisk:asterisk /etc/asterisk
        /bin/chown -R asterisk:asterisk /var/lib/asterisk
        /bin/chown -R asterisk:asterisk /var/log/asterisk
        /bin/chown -R asterisk:asterisk /var/spool/asterisk

#        /bin/chmod 664 -R /opt/sark/etc/asterisk/*
        /bin/chmod 664 -R /etc/asterisk/*
        /bin/chmod 755 -R /opt/sark/www
        /bin/chmod 755 -R /opt/sark/generator
        /bin/chmod 755 -R /opt/sark/perl
        /bin/chmod 755 -R /opt/sark/scripts
        /bin/chmod 777 -R /tftpboot
                /bin/chmod +x  /opt/sark/service/*/run

/bin/grep -q '#include sark_manager.conf' /etc/asterisk/manager.conf
if [  "$?" -ne "0" ] ; then
        /bin/cp -f /opt/sark/cache/manager.conf /etc/asterisk
fi

/bin/grep -q '#include sark_customer_manager.conf' /etc/asterisk/sark_manager.conf
if [  "$?" -ne "0" ] ; then
        echo "#include sark_customer_manager.conf" >> /etc/asterisk/sark_manager.conf
fi

/bin/grep -q '#include sark_sip_notify.conf' /etc/asterisk/sip_notify.conf
if [  "$?" -ne "0" ] ; then
        echo "#include sark_sip_notify.conf" >> /etc/asterisk/sip_notify.conf
fi

if [ ! -e /opt/sark/db/sark.db ] ; then
        /bin/mv -f  /opt/sark/db/sarkstart.db /opt/sark/db/sark.db
fi

#if [ ! -e /service/sark ] ; then
        /bin/rm -rf /service/sark
        /bin/ln -s /opt/sark/service/sark /service/sark
#fi
#if [ ! -e /service/httpd-srk ] ; then
        /bin/rm -rf /service/httpd-srk
    /bin/ln -s /opt/sark/service/httpd-srk /service/httpd-srk
#fi
#if [ ! -e /service/srk-ua-helper ] ; then
        /bin/rm -rf /service/srk-ua-helper
    /bin/ln -s /opt/sark/service/srk-ua-helper /service/srk-ua-helper
#fi
#if [ ! -e /service/srk-ua-responder ] ; then
        /bin/rm -rf /service/srk-ua-responder
    /bin/ln -s /opt/sark/service/srk-ua-responder /service/srk-ua-responder
#fi

/bin/sh /opt/sark/scripts/update_db.sh >/dev/null
date --iso-8601=minutes > /opt/sark/db/.sail-install-date
echo "4.0.0-43" > /opt/sark/.sail-release

Pre UnInstall

None

Post UnInstall

None