Various updates; Add logAxis patch for graphite; Add namespaces to summary scripts.
[myops.git] / web / setup.sh
index 8f8257d..a6155b8 100644 (file)
@@ -1,5 +1,48 @@
 #/bin/bash
 
+# todo: ssl support is not default for apache.
+#      + update scripts to allow both https/http.
+#      + add log axis patch. 
+
+
+########################################3
+
+if [ -z "$SETUP_IP" ] ; then
+       export IP=`ip addr show eth0 | grep -E "eth0$|eth0:[[:digit:]]+$" | tr '/' ' ' | awk '{print $2}'`
+else
+       export IP=$SETUP_IP
+fi
+if [ -z "$SETUP_HOST" ] ; then
+       if ! rpm -q bind-utils > /dev/null ; then
+               yum install -y bind-utils
+       fi
+       export HOST=`host $IP | cut -d ' ' -f 5 | tr [A-Z] [a-z] | sed -e 's/\.$//g'`
+else 
+       export HOST=$SETUP_HOST
+fi
+
+echo "---------------------------------------------------------------"
+echo "setup.sh will configure your system using the following values:"
+echo "IP:       $IP"
+echo "HOSTNAME: $HOST"
+echo ""
+echo "You can manually set the IP and HOST, by setting shell variables:"
+echo "export SETUP_IP="
+echo "export SETUP_HOST="
+echo "Proceed? (yes/no):"
+while read userinput ; do 
+       if [[ -z "$userinput" ]] ; then
+               echo "Assuming this is correct."
+               break
+       fi
+       if [[ "$userinput" = "yes" || "$userinput" = "y" ]] ; then
+               break
+       fi
+       if [[ "$userinput" = "no" || "$userinput" = "n" ]] ; then
+               exit
+       fi
+done
+
 if ! rpm -q bzr &> /dev/null ;  then 
        echo "bzr is not installed"
        exit    
@@ -9,18 +52,18 @@ if [ ! -d graphite ] ; then
        # just picked latest revno on 6/27/2011 for a static config
        echo "bzr branch -r revno:409 lp:graphite"
        bzr branch -r revno:409 lp:graphite
-       cd graphite/
        ./check-dependencies.py 
 fi
 
 if [ ! -d deps ] ; then
+       cd graphite/
        mkdir deps
        pushd deps/
 
-       wget http://launchpad.net/graphite/1.0/0.9.8/+download/graphite-web-0.9.8.tar.gz
-       wget http://launchpad.net/graphite/1.0/0.9.8/+download/carbon-0.9.8.tar.gz
-       wget http://launchpad.net/graphite/1.0/0.9.8/+download/whisper-0.9.8.tar.gz
-       wget http://launchpad.net/txamqp/trunk/0.3/+download/python-txamqp_0.3.orig.tar.gz
+    wget http://myops.planet-lab.org/files/graphite-web-0.9.8.tar.gz
+    wget http://myops.planet-lab.org/files/carbon-0.9.8.tar.gz
+    wget http://myops.planet-lab.org/files/whisper-0.9.8.tar.gz
+    wget http://myops.planet-lab.org/files/python-txamqp_0.3.orig.tar.gz
 
        tar -xvf python-txamqp_0.3.orig.tar.gz 
        tar -zxvf whisper-0.9.8.tar.gz 
@@ -55,6 +98,7 @@ if [ ! -d deps ] ; then
        sed -i -e 's|Alias /content/ .*|Alias /content/ /var/www/html/content/|g' /etc/httpd/conf.d/graphite-vhost.conf
        cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
        cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf
+       cp /opt/graphite/webapp/graphite/render/graphTemplates.conf /opt/graphite/conf
        cp /usr/share/myops/web/view/storage-schemas.conf /opt/graphite/conf/
 
        popd
@@ -64,12 +108,10 @@ if [ ! -d deps ] ; then
 
 fi
 
-
 # NOTE: TEMP hack for testing...
-sed -i -e 's/2003/3003/g' -e 's/2004/3004/g' -e 's/7002/6002/g' /opt/graphite/conf/carbon.conf
-sed -i -e 's/2003/3003/g' /usr/bin/sar2graphite.py
-sed -i -e 's/2003/3003/g' /usr/share/myops/web/collect/server/*.py
-
+#sed -i -e 's/2003/3003/g' -e 's/2004/3004/g' -e 's/7002/6002/g' /opt/graphite/conf/carbon.conf
+#sed -i -e 's/2003/3003/g' /usr/bin/sar2graphite.py
+#sed -i -e 's/2003/3003/g' /usr/share/myops/web/collect/server/*.py
 
 # setup db for graphite application
 cd /opt/graphite/webapp/graphite
@@ -91,7 +133,6 @@ EOF
 fi
 
 
-export HOST=`hostname`
 sed -i -e 's/HOSTNAME/'$HOST'/g' /var/www/html/PlanetLabConf/sysstat.cron
 sed -i -e 's/HOSTNAME/'$HOST'/g' /etc/cron.d/sysstat.cron
 sed -i -e 's/HOSTNAME/'$HOST'/g' /usr/share/myops/web/collect/server/load-graphite.py
@@ -110,14 +151,14 @@ yum groupinstall -y Development\ Tools
 
 pip install couchapp
 
-export IP=`ip addr show eth0 | grep -E "eth0$" | tr '/' ' ' | awk '{print $2}'`
 sed -i -e 's/;bind_address = 127.0.0.1/bind_address = '$IP'/g' /etc/couchdb/local.ini
-export PASSWORD=makethisrandom1
+export PASSWORD=couchpass$RANDOM
 sed -i -e 's/;admin = .*/admin = '$PASSWORD'/g' /etc/couchdb/local.ini
 
 service couchdb restart
 chkconfig couchdb on
 
+# give couch server time to boot up
 sleep 10
 pushd /usr/share/myops/web/query
 echo "couchapp push . http://admin:$PASSWORD@$HOST:5984/myops"
@@ -129,7 +170,7 @@ sed -i -e 's/IPADDR/'$IP'/g' /usr/share/myops/web/collect/client/upload.sh
 sed -i -e 's/IPADDR/'$IP'/g' /usr/share/myops/web/collect/client/update.sh
 sed -i -e 's/IPADDR/'$IP'/g' /usr/share/myops/web/collect/server/load_couch.py
 
-cp /usr/share/myops/web/collect/client/update.sh /var/www/html/PlanetLabConf/myops_update_sh
+ln /usr/share/myops/web/collect/client/update.sh /var/www/html/PlanetLabConf/myops_update_sh
 
 /usr/share/myops/web/collect/server/build.sh
 
@@ -141,7 +182,6 @@ fi
 mkdir -p /var/www/html/uploadlogs/raw
 chown -R apache.apache /var/www/html/uploadlogs
 
-
 chkconfig crond on
 service crond start