SAIL 4 RPM Scriptlets

From sailpbx
Revision as of 05:24, 1 March 2013 by Apmutha (talk | contribs) (# rpm -qp --qf "%{postin}\n" smesailenv-4.0.0-11.noarch.rpm)
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

# rpm -qp --qf "%{postin}\n" smesailenv-4.0.0-11.noarch.rpm

Shebang line missing.

        /bin/rm -rf /etc/e-smith/db/configuration/defaults/SIP
        /bin/rm -rf /etc/e-smith/db/configuration/defaults/IAX2
        /bin/rm -rf /etc/e-smith/db/configuration/defaults/sark

#       delete any old sark db entries
#        /sbin/e-smith/config delete sark
#       /bin/rm -rf /etc/rc.d/rc7.d/S95sark

        /sbin/e-smith/config set sark service status enabled access public
        /sbin/e-smith/config set dahdi service status enabled access public
        /sbin/e-smith/config set tftpd service status enabled access public
        /sbin/e-smith/config set setlan service status enabled access public
        /sbin/e-smith/config set sailSIP service status enabled access public UDPPort 5060
        /sbin/e-smith/config set sailIAX service status enabled access public UDPPort 4569
        /sbin/e-smith/config set sailRTP service status enabled access public UDPPorts 10000:20000
        /sbin/e-smith/config set sailAMI service status disabled access public TCPPort 5038
        /sbin/e-smith/config set httpd-srk service status enabled access public TCPPort 8443

# remove the old V3 structure for httpd (if exists)
        [ -e /opt/sark/httpd ] && /bin/rm /opt/sark/httpd

        [ ! -e /opt/sark/etc/httpd/sark.crt ] && /bin/mv /opt/sark/cache/sark.crt /opt/sark/etc/httpd
        [ ! -e /opt/sark/etc/httpd/sark.key ] && /bin/mv /opt/sark/cache/sark.key /opt/sark/etc/httpd
        /bin/chmod 644 /opt/sark/etc/httpd

        [ ! -d /var/log/sark ] && /bin/mkdir -p /var/log/sark
        /bin/chown www:www /var/log/sark

#       set tftp to run in ipv4 - necessary for sme8
        if [ -e /etc/rc.d/init.d/tftpd ] ; then
                /bin/sed -i 's/tftpd -l -v/tftpd -l --ipv4 -v/' /etc/rc.d/init.d/tftpd
        fi


        if [ ! -e /etc/rc.d/rc7.d/S94setlan ] ; then
                /bin/ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S94setlan
        fi
        if [ ! -e /etc/rc.d/rc7.d/S95dahdi ] ; then
                /bin/ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S95dahdi
        fi
        if [ ! -e /etc/rc.d/rc7.d/S96sark ] ; then
                /bin/ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S96sark
        fi
        if [ ! -e /etc/rc.d/rc7.d/S95tftpd ] ; then
                /bin/ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S95tftpd
        fi
        if [ ! -e /etc/rc.d/rc7.d/S95httpd-srk ] ; then
                /bin/ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S95httpd-srk
        fi

        /sbin/e-smith/db yum_repositories set asterisk-current repository \
        Name 'CentOS-$releasever - Asterisk - Current' \
        BaseURL 'http://packages.asterisk.org/centos/$releasever/current/$basearch/' \
        EnableGroups no \
        GPGCheck no \
        GPGKey http://packages.asterisk.org/RPM-GPG-KEY-Digium \
        Visible no \
        Exclude freetype,htop,iptraf,rsync,syslinux \
        status disabled

        /sbin/e-smith/db yum_repositories set digium-current repository \
        Name 'CentOS-$releasever - Digium - Current' \
        BaseURL 'http://packages.digium.com/centos/$releasever/current/$basearch/' \
        EnableGroups no \
        GPGCheck no \
        GPGKey http://packages.digium.com/RPM-GPG-KEY-Digium \
        Visible no \
        Exclude freetype,htop,iptraf,rsync,syslinux \
        status disabled

        /sbin/e-smith/signal-event yum-modify

Pre UnInstall

None

Post UnInstall

None