Skip to content

Instantly share code, notes, and snippets.

@Rockheung
Created May 27, 2018 23:52
Show Gist options
  • Save Rockheung/751df65360728723ba6990173b7a6ce3 to your computer and use it in GitHub Desktop.
Save Rockheung/751df65360728723ba6990173b7a6ce3 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
#@script : sb_installer.sh
#@about : install streambuilder on client side
#@usage :
# $ wget -q http://repo.streambuilder.pro/open/binary/sb_installer.sh && bash sb_installer.sh
#
# TODO:
# for centos:
# $ cat /etc/redhat-release
# display message about supported systems and exit
supported_systems() {
echo "Supported systems:"
echo " Ubuntu 14.04, 16.04 and CentOS 7"
exit 1
}
# operating system
OPSYS=`uname -s`
if [ "$OPSYS" != "Linux" ]; then
supported_systems
fi
if [ -f /etc/redhat-release ]; then
DISTR=$(head -1 /etc/redhat-release | awk '{print $1}')
if [ "$DISTR" = "CentOS" ]; then
RELEASE=$(head -1 /etc/redhat-release | awk '{print $4}' | cut -f1 -d".")
fi
else
# check if lsb_release installed
lsb_release > /dev/null 2>&1
LSB=$?
if [ $LSB = 0 ]; then
DISTR=$(lsb_release -a 2>/dev/null | grep "ID" | awk '{print $3}')
RELEASE=$(lsb_release -a 2>/dev/null | grep "Release" | awk '{print $2}')
if [ "$DISTR" = "Debian" ]; then
RELEASE="${RELEASE:0:3}"
fi
else
# /etc/issue exists in Ubuntu and Debian
if [ -f /etc/issue ]; then
DISTR=$(head -1 /etc/issue | awk '{print $1}')
if [ "$DISTR" = "Debian" -o "$DISTR" = "Ubuntu" ]; then
if [ "$DISTR" = "Debian" ]; then
RELEASE=$(head -1 /etc/issue | awk '{print $3}')
else
RELEASE=$(head -1 /etc/issue | awk '{print $2}')
RELEASE="${RELEASE:0:5}"
fi
else
supported_systems
fi
else
supported_systems
fi
fi
fi
# check supported operationg systems
if [ "$DISTR" = "CentOS" ]; then
if [ "$RELEASE" != "7" ]; then
supported_systems
fi
# read -p "Do you want to install web UI with streambuilder (y/n) [default: No]? " answer
DISTR="centos"
# update yum repository
sh -c "cat > /etc/yum.repos.d/streambuilder.repo << EOF
[streambuilder]
name=streambuilder
baseurl=http://repo.streambuilder.pro/rpm/centos/7
enabled=1
gpgcheck=0
EOF"
# update repositories metadata
yum makecache
# install streambuilder with dependencies
yum -y install streambuilder streambuilder-ui
# case ${answer:0:1} in
# y|Y )
# yum -y install streambuilder-ui
# ;;
# * )
# ;;
# esac
else
if [ "$DISTR" = "Ubuntu" ]; then
if [ "$RELEASE" = "14.04" -o "$RELEASE" = "16.04" ]; then
DISTR="ubuntu"
else
supported_systems
fi
else
supported_systems
fi
# read -p "Do you want to install web UI with streambuilder (y/n) [default: No]? " answer
# get pgp-key and install streambuilder package
sh -c "echo 'deb http://repo.streambuilder.pro/open/$DISTR/$RELEASE /' > /etc/apt/sources.list.d/streambuilder.list"
# register gpg-key
wget -q -O - http://repo.streambuilder.pro/open/binary/gpg.key | sudo apt-key add -
# update repositories
apt-get update
# install streambuilder with dependencies
apt-get install -f --yes --force-yes streambuilder streambuilder-ui
# case ${answer:0:1} in
# y|Y )
# apt-get install -f --yes --force-yes streambuilder-ui
# ;;
# * )
# ;;
# esac
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment