2015-10-20 23:21:50 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# Niek Vlessert
|
|
|
|
|
|
|
|
USER=`whoami`
|
2015-11-10 19:43:46 +01:00
|
|
|
DISTRO=$(source /etc/os-release && echo $PRETTY_NAME)
|
2015-10-20 23:21:50 +02:00
|
|
|
if [ $USER != "root" ] ; then
|
|
|
|
SUDO=`which sudo | awk -F"/" '{print $NF}'`
|
|
|
|
if [ -z $SUDO ] ; then
|
|
|
|
echo "No root and no sudo... please run this as root or install sudo and make sure your user has permissions to use it."
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
read -p "The currently active user is not root but sudo is available... do you want to install using sudo? (y/n) " -n 1 -r
|
|
|
|
if ! [[ $REPLY =~ ^[yY]$ ]]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2015-11-10 19:43:46 +01:00
|
|
|
echo "This will do several things on your $DISTRO installation:"
|
2015-10-20 23:21:50 +02:00
|
|
|
echo "- Create user freeswitch and add it to group freeswitch"
|
|
|
|
FSPATH=@prefix@
|
|
|
|
if [[ $FSPATH == *"freeswitch"* ]]
|
|
|
|
then
|
2015-10-20 23:21:50 +02:00
|
|
|
echo "- Set permissions on @prefix@ and files in @bindir_expanded@"
|
2015-10-20 23:21:50 +02:00
|
|
|
fi
|
2015-11-10 19:43:46 +01:00
|
|
|
echo "- Install systemd unit file and other required files"
|
2015-10-20 23:21:50 +02:00
|
|
|
echo
|
2015-10-20 23:21:50 +02:00
|
|
|
read -p "Do you want to continue? (y/n) " -n 1 -r
|
|
|
|
if [[ $REPLY =~ ^[yY]$ ]]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "Installing..."
|
2015-11-10 19:43:46 +01:00
|
|
|
$SUDO useradd -d @confdir@ -r -U -s /bin/false -c "FreeSWITCH open source softswitch" freeswitch
|
2015-10-20 23:21:50 +02:00
|
|
|
if [[ $FSPATH == *"freeswitch"* ]]
|
|
|
|
then
|
|
|
|
$SUDO chown -R freeswitch:freeswitch @prefix@
|
|
|
|
$SUDO chmod -R ug=rwX,o= @prefix@
|
2015-10-20 23:21:50 +02:00
|
|
|
$SUDO chmod -R u=rwx,g=rx @bindir_expanded@/*
|
2015-10-20 23:21:50 +02:00
|
|
|
fi
|
2015-11-10 19:43:46 +01:00
|
|
|
$SUDO cp build/startup/freeswitch.service /etc/systemd/system/
|
|
|
|
$SUDO cp build/startup/freeswitch.tmpfile /etc/tmpfiles.d/freeswitch.conf
|
|
|
|
if [ -d /etc/sysconfig ]; then
|
|
|
|
$SUDO cp build/startup/freeswitch.default /etc/sysconfig/freeswitch
|
|
|
|
else
|
|
|
|
$SUDO cp build/startup/freeswitch.default /etc/default/freeswitch
|
|
|
|
fi
|
2015-10-20 23:21:50 +02:00
|
|
|
$SUDO systemd-tmpfiles --clean --create
|
|
|
|
$SUDO systemctl daemon-reload
|
|
|
|
echo
|
|
|
|
if [ -f @confdir@/vars.xml ] ; then
|
|
|
|
echo "You may now start Freeswitch using 'systemctl start freeswitch'"
|
|
|
|
else
|
|
|
|
echo "Make sure your config files are in place in @confdir@, if they are you can start Freeswitch using 'systemctl start freeswitch'"
|
|
|
|
fi
|
2015-10-20 23:21:50 +02:00
|
|
|
echo "Then start fs_cli by running @bindir_expanded@/fs_cli"
|
2015-10-20 23:21:50 +02:00
|
|
|
fi
|