Skip to content

Instantly share code, notes, and snippets.

@ccarrasc
ccarrasc / install-graphite.sh
Created July 19, 2013 17:04
Script to install graphite locally on CentOs
#!/bin/bash
# Add the EPEL repo if not added already
yum repolist | grep -i epel
if [ $? -ne 0 ]; then
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
fi
# Install the preqs
yum install gcc-c++ httpd python-devel python-pip python-sqlite2 \
@ccarrasc
ccarrasc / GetCookie.js
Last active December 18, 2015 16:49
Get cookie value (must be same domain)
var getCookie = function (key) {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; ++i) {
var currentKey = cookies[i].substr(0, cookies[i].indexOf('='));
currentKey = currentKey.replace(/^\s+|\s+$/g, "");
if (currentKey === key) {
return cookies[i].substr(cookies[i].indexOf('=') + 1);
}
}
@ccarrasc
ccarrasc / install_graphite.sh
Last active December 18, 2015 16:49
Install Graphite on CentOS 6
#!/bin/bash
# The current process has unrestricted/unlimited (root) access when the Effective User ID (EUID) is 0:
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mThis script must be run as root or it will fail\e[0m" 1>&2
exit 1
fi
# Make sure we are on CentOS
OS=`cat /etc/redhat-release | awk {'print $1}'`
@ccarrasc
ccarrasc / if_centos.sh
Last active March 1, 2019 22:50
Verify we are on CentOS
#!/bin/bash
OS=`cat /etc/redhat-release | awk {'print $1}'`
if [ "$OS" != "CentOS" ]; then
echo -e "\e[1;31mThis script is intended for CentOS only\e[0m" 1>&2
#exit 1
fi
@ccarrasc
ccarrasc / if_root.sh
Last active March 1, 2019 22:47
Verify a script is being executed as root. The current process has unrestricted/unlimited (root) access when the Effective User ID (EUID) is 0:
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mThis script must be run as root or it will fail\e[0m" 1>&2
exit 1
fi