Last active
August 31, 2015 21:07
-
-
Save gabtastic/234e0131b331d78c6b16 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env sh | |
# Supervisor Agent Easy install | |
# Execute like this: | |
# curl -k https://gist.githubusercontent.com/gabtastic/910402ed1d027a5be332/raw -s | sh | |
function installpackage { | |
echo "Installing $1" | |
if rpm -q $1 > /dev/null; | |
then | |
echo " $1 package already installed ..." | |
else | |
sudo yum install -y $1 > /dev/null; | |
fi | |
} | |
function removepackage { | |
if rpm -q $1 > /dev/null; | |
then | |
sudo yum remove $1 > /dev/null; | |
else | |
echo "$1 package not installed." | |
fi | |
} | |
# Install gem fury repo | |
echo "Installing gemfury repo" | |
if [ ! -e /etc/yum.repos.d/gemfury.repo ] | |
then | |
sudo bash -c 'cat << EOF > /etc/yum.repos.d/gemfury.repo | |
[fury] | |
name=Gemfury Private Repo | |
baseurl=https://repo.fury.io/wQUZrGXsyxMh5KMQx3W4/intello/ | |
enabled=1 | |
gpgcheck=0 | |
EOF' | |
fi | |
# Remove ruby 1.8.5 if installed | |
removepackage ruby-1.8.5 | |
# install dependencies` | |
installpackage epel-release | |
installpackage libyaml | |
installpackage ruby.i386 | |
installpackage rubygem-eventmachine | |
installpackage rubygem-websocket-extensions | |
installpackage rubygem-websocket-driver | |
installpackage rubygem-hiredis | |
installpackage rubygem-unf_ext | |
installpackage rubygem-hitimes | |
installpackage rubygem-mysql | |
installpackage redis | |
# Start REDIS | |
sudo chkconfig redis on | |
sudo /etc/init.d/redis start | |
# Your environment should be set properly | |
# Missing /etc/profile.d/panorama.sh | |
if [ ! -e /etc/profile.d/panorama.sh ] | |
then | |
echo 'You are missing the environment profile panorama.sh in /etc/profile.d' | |
echo 'Creating basic config' | |
sudo bash -c 'cat << EOF > /etc/profile.d/panorama.sh | |
export PEPLINK_USERNAME="" | |
export PEPLINK_PASSWORD="" | |
export PEPLINK_PORT="" | |
export ZONEDIRECTOR_USERNAME="" | |
export ZONEDIRECTOR_PASSWORD="" | |
' | |
fi | |
# Supervisor Agent Connect wrapper | |
sudo bash -c 'cat << EOF > /usr/local/bin/supervisor_agent_connect | |
#!/bin/bash | |
source /etc/profile.d/panorama.sh | |
exec /usr/bin/supervisor_agent -c /etc/ihotel/supervisor_agent.json -l /var/log/iHotel/supervisor_connect.log connect | |
' | |
# Supervisor Agent Scheduler wrapper | |
sudo bash -c 'cat << EOF > /usr/local/bin/supervisor_agent_scheduler | |
#!/bin/bash | |
source /etc/profile.d/panorama.sh | |
env > /tmp/b.out | |
exec /usr/bin/supervisor_agent -c /etc/ihotel/supervisor_agent.json -l /var/log/iHotel/supervisor_scheduler.log start_scheduler | |
' | |
# Inittab entry | |
grep -q "666" /etc/inittab | |
rc=$?; | |
if [[ $rc != 0 ]]; | |
then | |
sudo bash -c 'cat << EOF >> /etc/inittab | |
666:345:respawn:/usr/local/bin/supervisor_agent_connect | |
' | |
fi | |
# Inittab entry | |
grep -q "667" /etc/inittab | |
rc=$?; | |
if [[ $rc != 0 ]]; | |
then | |
sudo bash -c 'cat << EOF >> /etc/inittab | |
667:345:respawn:/usr/local/bin/supervisor_agent_scheduler | |
' | |
fi | |
chmod +x /usr/local/bin/supervisor_agent_connect | |
chmod +x /usr/local/bin/supervisor_agent_scheduler | |
# Install supervisor gem ... | |
echo "Installing supervisor-agent gem" | |
sudo gem install supervisor-agent --pre --no-ri --no-rdoc --source https://[email protected]/intello/ | |
echo "Re-reading inittab" | |
init q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment