Last active
August 12, 2018 04:44
-
-
Save Ark74/7a86f28bd71cc9dad5fec9cb89a10d62 to your computer and use it in GitHub Desktop.
Patching Libretime Silan (Jessie/Stretch/Xenial/Trusty/Centos7)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# PatchSilan - A simple script for Libretime and silan backport easing its | |
# upgrade to a working release for Debian, Ubuntu & CentOS(7) - @Aug/10/2018 | |
#Check distro | |
if [ -f /etc/redhat-release ] | |
then | |
yum -y update && yum install -y wget | |
SILAN_RPM="$(rpm -q silan | cut -d '-' -f 2)" | |
elif [ -f /etc/debian_version ] | |
then | |
apt -qq update && apt install -y wget lsb-release apt-utils | |
SILAN_DEB="$(dpkg-query -W -f='${Version}' "silan")" | |
else | |
echo "Unkown distro" | |
fi | |
echo "Let's look and install backported silan" | |
set_deb() { | |
if [ "$(lsb_release -sc)" = "trusty" ] | |
then | |
release="https://github.com/Ark74/silan3.3/raw/Trusty/silan_0.3.3-1_amd64.deb" | |
elif [ "$(lsb_release -sc)" = "xenial" ] | |
then | |
release="https://github.com/Ark74/libretime/raw/master/installer/packages/silan-0.3.3/xenial/silan_0.3.3-1_amd64.deb" | |
elif [ "$(lsb_release -sc)" = "jessie" ] | |
then | |
release="https://github.com/Ark74/libretime/raw/master/installer/packages/silan-0.4.0/jessie/silan_0.4.0-1_amd64.deb" | |
elif [ "$(lsb_release -sc)" = "stretch" ] | |
then | |
release="https://github.com/Ark74/libretime/raw/master/installer/packages/silan-0.4.0/stretch/silan_0.4.0-1_amd64.deb" | |
else | |
echo "No deb backport package available!" | |
exit 1 | |
fi | |
} | |
set_centos_repos() { | |
source /etc/os-release | |
if [ $VERSION_ID == "7" ] | |
then | |
yum install -y epel-release | |
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro | |
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm | |
curl -o /etc/yum.repos.d/home:radiorabe:audio.repo \ | |
http://download.opensuse.org/repositories/home:/radiorabe:/audio/CentOS_7/home:radiorabe:audio.repo | |
else | |
echo "Repository not available" | |
exit 1 | |
fi | |
} | |
update_silan_deb() { | |
if dpkg --compare-versions "$SILAN_DEB" "lt" "0.3.3-1" | |
then | |
echo "Need to update silan" | |
wget $release -O /tmp/silan_update.deb | |
dpkg -i /tmp/silan_update.deb | |
apt install -fy | |
rm -rf /tmp/silan_update.deb | |
apt-cache policy silan | |
else | |
echo "Silan installed version Ok!" | |
apt-cache policy silan | |
fi | |
} | |
install_rpm() { | |
if [ "$SILAN_RPM" == "0.4.0" ] | |
then | |
echo "Seems than silan is ok" | |
yum info silan | |
else | |
yum install -y silan | |
yum info silan | |
fi | |
} | |
check_and_install_silan() { | |
if [ -f /etc/redhat-release ] | |
then | |
set_centos_repos | |
install_rpm | |
echo "Patching rpm silan complete!" | |
elif [ -f /etc/debian_version ] | |
then | |
set_deb | |
update_silan_deb | |
echo "Patching deb silan complete!" | |
else | |
echo "Unsupported distro and package." | |
exit 1 | |
fi | |
} | |
check_and_install_silan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment