Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- if [ "$EUID" -ne 0 ]; then
- echo "This script needs to be run as root."
- echo "HINT: Run 'sudo !!' to run this script as root."
- exit 1
- fi
- export PYTHONPATH=/home/qlstats/XonStat/lib/python
- clear
- echo "Welcome to Install-QLStats.sh"
- echo "Created by Thomas Jones (thomas@tomtecsolutions.com)"
- echo -e "\n"
- read -p "Ready to install QLStats? [y/n]" -n 1
- if [ $REPLY != "y" ]; then
- echo -e "\nResponse was not 'y', exiting..."
- fi
- echo -e "\nInstalling packages..."
- echo "Installing git..."; sudo apt-get -y install git > ~/qlstatsinstall-log.txt
- echo "Installing node.js..."; sudo apt-get -y install nodejs > ~/qlstatsinstall-log.txt
- echo "Softlinking node.js..."; sudo ln -s /usr/bin/nodejs /usr/bin/node > ~/qlstatsinstall-log.txt 2>&1
- echo "Installing npm..."; sudo apt-get -y install npm > ~/qlstatsinstall-log.txt
- echo "Installing python 2.7..."; sudo apt-get -y install python > ~/qlstatsinstall-log.txt
- echo "Installing python 3.4..."; sudo apt-get -y install python3 > ~/qlstatsinstall-log.txt
- echo "Installing python-setuptools..."; sudo apt-get -y install python-setuptools > ~/qlstatsinstall-log.txt
- echo "Installing python-pip and python-dev..."; sudo apt-get -y install python-pip python-dev > ~/qlstatsinstall-log.txt
- echo "Installing pyzmq..."; sudo easy-install pyzmq > ~/qlstatsinstall-log.txt
- echo "Installing libzmq3, libzmq3-dev and libzmq3-dbg..."; sudo apt-get -y install libzmq3 libzmq3-dev libzmq3-dbg > ~/qlstatsinstall-log.txt
- echo "Installing postgresql..."; sudo apt-get -y install postgresql postgresql-server-dev-9.4 > ~/qlstatsinstall-log.txt
- echo "Installing pastescript..."; sudo python -m pip install pastescript > ~/qlstatsinstall-log.txt
- echo "Creating the QLStats account...";
- echo "Please enter a password for the new QLStats account:"; adduser --quiet --shell /bin/bash --gecos 0 qlstats
- cd /home/qlstats
- echo "export PYTHONPATH=/home/qlstats/XonStat/lib/python" >> .bashrc
- sudo -u qlstats git clone https://github.com/PredatH0r/XonStat.git
- sudo -u qlstats git clone https://github.com/antzucaro/xonstatdb.git
- cd XonStat/feeder; npm install; mkdir ql-match-jsons; mkdir lib; mkdir lib/python
- cd /var/lib/postgresql
- echo "Enter 'xonstat' (no quotes) at this password prompt:"; sudo -u postgres createuser -P xonstat
- if ! $(sudo -u postgres psql template1 -c 'SHOW SERVER_ENCODING' | grep -q UTF8); then
- sudo -u postgres psql postgres -c "update pg_database set datallowconn = TRUE where datname = 'template0';"
- sudo -u postgres psql template0 -c "update pg_database set datistemplate = FALSE where datname = 'template1';"
- sudo -u postgres psql template0 -c "drop database template1;"
- sudo -u postgres psql template0 -c "create database template1 with template = template0 encoding = 'UTF8';"
- sudo -u postgres psql template0 -c "update pg_database set datistemplate = TRUE where datname = 'template1';"
- sudo -u postgres psql template1 -c "update pg_database set datallowconn = FALSE where datname = 'template0';"
- fi
- sudo -u postgres psql postgres -c "CREATE DATABASE xonstatdb WITH ENCODING='UTF8' OWNER=xonstat CONNECTION LIMIT=-1;"
- sed '90s/peer/md5/' /etc/postgresql/9.4/main/pg_hba.conf
- cd /home/qlstats
- export PGPASSWORD="xonstat"
- sudo -u postgres psql -U xonstat xonstatdb -c "CREATE SCHEMA xonstat AUTHORIZATION xonstat; CREATE LANGUAGE plpgsql;"
- sudo -u postgres psql -U xonstat xonstatdb -c "\i /home/qlstats/xonstatdb/build/build_full.sql"
- sudo -u postgres psql -U xonstat xonstatdb -c "\i /home/qlstats/XonStat/sql/qlstats-init.sql"
- python setup.py install --home=/home/qlstats/XonStat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement