Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install Scalr on Ubuntu 12.04 Precise Pangolin
export PASSWORD=yourpassword
export HOSTNAME='scalr'
export DOMAIN='.local'
export SCALR_BASE=/usr/local/scalr
export SCALR_HOME=$SCALR_BASE/scalr-home
export SCALR_FILES=$SCALR_BASE/scalr-files
export CURRENT=$SCALR_BASE/current
hostname $HOSTNAME
echo $HOSTNAME > /etc/hostname
echo " $HOSTNAME" >> /etc/hosts
chmod -R 777 /tmp/
apt-get -y install apache2-mpm-prefork php5 php5-mysql php5-curl php5-mcrypt \
php5-snmp libssh2-php apparmor-utils mailutils bind9 phpmyadmin \
php-pear rrdtool librrd-dev libcurl4-openssl-dev mysql-server snmp
echo '$cfg["AllowArbitraryServer"] = TRUE;' >> /etc/phpmyadmin/
useradd -d $SCALR_BASE -m -r -G www-data,bind scalr
usermod -G scalr www-data
mkdir -p $SCALR_HOME
mkdir -p $SCALR_FILES
curl -L > scalr-master-$(date '+%Y%m%d').tar.gz
tar -zxvf $SCALR_FILES/scalr-master-$(date '+%Y%m%d').tar.gz
ln -sf $(ls -rtd1 Scalr* | tail -1)/app current
ln -sf $(ls -rtd1 Scalr* | tail -1)/sql sql
mkdir -p $SCALR_HOME/etc
touch $SCALR_HOME/etc/.cryptokey
mkdir -p $SCALR_HOME/cache/smarty_bin
chmod 2755 $SCALR_BASE
chmod -R 2775 $SCALR_HOME/cache
cd $CURRENT ; ln -sf $SCALR_HOME/cache ; cd $SCALR_BASE
chmod 2775 $SCALR_HOME/etc/.cryptokey
cd $CURRENT/etc ; ln -sf $SCALR_HOME/etc/.cryptokey ; cd $SCALR_BASE
mkdir -p $SCALR_HOME/graphics
mkdir -p $SCALR_HOME/rrddata
mkdir -p $SCALR_HOME/log
chown -R scalr:scalr $SCALR_BASE
cp -rp $CURRENT/templates/en_US $SCALR_HOME/cache/smarty_bin/
mysql -uroot --password=$PASSWORD -e 'create database scalr; grant all on scalr.* to scalr@localhost identified by "'$PASSWORD'";flush privileges;'
mysql -uroot --password=$PASSWORD -e 'grant all on *.* to admin@localhost identified by "'$PASSWORD'" with grant option;flush privileges;'
mysql -uscalr --password=$PASSWORD scalr < $SCALR_BASE/sql/structure.sql
mysql -uscalr --password=$PASSWORD scalr < $SCALR_BASE/sql/data.sql
perl -i -pe "s/" $CURRENT/src/class.DBDNSZone.php
cp -p $CURRENT/src/Scalr/Net/Dns/Bind/Transports/LocalFs.php $CURRENT/src/Scalr/Net/Dns/Bind/Transports/LocalFs.php-dist
perl -i -pe 's/\(!\$retval\)/(\$retval === false)/g' $CURRENT/src/Scalr/Net/Dns/Bind/Transports/LocalFs.php
cp -p $CURRENT/src/structs/struct.CONFIG.php $CURRENT/src/structs/struct.CONFIG.php-dist
ip=$(ifconfig eth0 | grep inet | head -1 | awk ' { print $2 } ' | cut -f2 -d:)
perl -i -pe "s/^(.*PMA_INSTANCE_IP_ADDRESS = ).*/\$1 '$ip';/g" $CURRENT/src/structs/struct.CONFIG.php
for i in CPU LA MEM NET; do
mv $CURRENT/cron/watchers/class.${i}SNMPWatcher.php $CURRENT/cron/watchers/class.${i}SNMPWatcher.php-dist
curl${i}SNMPWatcher.php > $CURRENT/cron/watchers/class.${i}SNMPWatcher.php
chown scalr:scalr $CURRENT/cron/watchers/class.${i}SNMPWatcher.php
for i in RRD RRDGraph; do
mv $CURRENT/src/LibWebta/library/Data/RRD/class.${i}.php $CURRENT/src/LibWebta/library/Data/RRD/class.${i}.php-dist
curl${i}.php > $CURRENT/src/LibWebta/library/Data/RRD/class.${i}.php
chown scalr:scalr $CURRENT/src/LibWebta/library/Data/RRD/class.${i}.php
cat <<EOF> /etc/apache2/sites-available/scalr
<VirtualHost *:80>
ServerName \${HOSTNAME}\${DOMAIN}
DocumentRoot /usr/local/scalr/current/www
ErrorLog \${APACHE_LOG_DIR}/scalr-error.log
CustomLog \${APACHE_LOG_DIR}/scalr-access.log combined
<Directory /usr/local/scalr/current/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Alias /graphics "/usr/local/scalr/scalr-home/graphics"
<Directory /usr/local/scalr/current/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
a2ensite scalr
pecl install rrd
echo '' > /etc/php5/apache2/conf.d/rrd.ini
printf '\n\n\n\n' | pecl install pecl_http
echo '' > /etc/php5/apache2/conf.d/http.ini
a2enmod rewrite
service apache2 restart
[ -f $CURRENT/etc/config.ini ] && mv $CURRENT/etc/config.ini $CURRENT/etc/config.ini-old
cat > $CURRENT/etc/config.ini <<EOF
host = "localhost"
name = "scalr"
user = "scalr"
pass = "$PASSWORD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.