Thursday, April 13, 2017

aelO@ - OSX File Permissions

Most people know about the standard file permissions on *NIX systems.
However on OS-X there are actually 4 systems for setting file permissions/ACL's/Attributes/Flags:


Basic File Permissions

ls -l
chmod u+w FILE

Access Control List (ACL)

ls -le
chmod +a “everyone deny delete” FILE

Extended Attributes

ls -l@
xattr -d com.apple.quarantine FILE

File Flags

ls -lO
chflags nouchg FILE

Summary

You should also throw a -a option into the ls command, so that you show hidden (.) files, therefore if you want to see what permissions are being applied to all your files you need the following command:

ls -aelO@



Friday, October 2, 2015

Building Python GEvent on OSX 10.10.5


Download Source Files

You will need the following sources:
  • openssl-1.0.2d.tar.gz            (https://www.openssl.org/source/openssl-1.0.2d.tar.gz)
  • libevent-2.0.22-stable.tar.gz
  • gevent-1.0.2.tar.gz
Place the tar balls in /usr/local/src

Extract the tar-balls

cd /usr/local/src

tar -zxf openssl-1.0.2d.tar.gz
tar -zxf libevent-2.0.22-stable.tar.gz
tar -zxf gevent-1.0.2.tar.gz


Build the Dependencies


cd openssl-1.0.2d
./Configure darwin64-x86_64-cc shared
make
make test
sudo make install
cd ..




cd libevent-2.0.22-stable
export CFLAGS="-I/usr/local/ssl/include"
export LDFLAGS="-L/usr/local/ssl/lib"
./configure
make
make verify                      # Verify takes about 5 minutes (okay to skip)
sudo make install
cd ..


Setup Python, Pip and Virtual Environment


# Make sure your using python 2.7.x (not 3.x)
# I install python 2.7.10 from python.org so that I have pip
# Add the new python to your path

export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/2.7/bin
sudo pip install --upgrade pip




# Setup virtual environment wrapper

sudo pip install virtualenvwrapper
export WORKON_HOME=~/Envs
mkdir -p $WORKON_HOME
source /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh



Finally, Build GEvent


cd gevent-1.0.2
mkvirtualenv gevent-build
pip install greenlet
export CFLAGS="-I/usr/local/include -L/usr/local/lib"
curl https://gist.githubusercontent.com/dtrott/3168c6138fd27b4e6522/raw/43471b2ac530bcc81ea228f9d64537ab72d6225a/gevent-ev.patch | patch -p0
python setup.py bdist_wheel
python setup.py install



Re-Use GEvent in another Virtual Environment


#If you want to install gevent into another virtual env do:

mkvirtualenv MY_NEW_VIRTUAL_ENV
cd /usr/local/src/gevent-1.0.2
python setup.py install

Monday, August 11, 2014

Adding static Routes in OSX

Just a quick correction to this blog entry:

http://blog.irrashai.com/blog/2009/03/how-to-add-static-route-in-mac-os-x/


Note: Edit the IP addresses listed below to match your network.

Create two files:  /Library/StartupItems/AddRoutes/AddRoutes
 
#!/bin/sh

# Set static routing tables

. /etc/rc.common

StartService ()
{
  ConsoleMessage "Adding Static Routing Table"
  route -n add -net 10.0.255.0/24 10.1.1.1
}

StopService ()
{
return 0
}

StopService ()
{
return 0
}

RestartService ()
{
return 0
}

RunService "$1"

 And: /Library/StartupItems/AddRoutes/StartupParameters.plist

{
Description = "Add static routing tables";
Provides = ("AddRoutes");
Requires = ("Network");
OrderPreference = "None";
}


Set everything as executable:
chmod 755 /Library/StartupItems/AddRoutes/*

Finally, reboot and check if your new routes "stuck":
netstat -rn


Monday, February 24, 2014

Rabbit MQ - Replication Options

When you need to replicate data with Rabbit MQ there are three main choices:
  • Federation plugin (Federated Exchanges).
  • Shovel Plugin
  • Mirror Queues (Part of the basic Rabbit clustering)
A useful starting point when trying to decide which to use is to examine where the various options read messages from and where they write the messages to:


Message Source
Exchange Queue
Target Exchange Federated Exchange Shovel
Queue Mirror Queue

Note: The federation plugin actually creates a temporary queue bound to the source exchange in order to collect messages however since this queue is configured automatically you are effectively reading messages from the source exchange.

However there is a much easier way to choose the right option for you:

If you are replicating data between clusters you need either the federation plugin or the shovel plugin.
If you are simply want redundant copies of the data within the same cluster use mirror queues.

In practice the choice between the federation and shovel comes down to:
  • The federation plugin is much simpler to setup, however it only supports "pulling data".
  • Where as the shovel plugin has to be manually configured, but data can be pulled or pushed**. 
** Pushing data means that the system where the shovel plugin is installed is pushing data to the other clusters. Where as pulling means that the system where shovel is installed is pulling data from the remote cluster.

Therefore if your pulling data your better off with the federation plugin, however if you need to push it you will be forced to use shovel.

Thursday, January 2, 2014

Building Readline 6.2 on Mavericks

This is not a long post, as the only additional step I have introduced is Step #4 - editing the Makefile
  1. cd /usr/local/src
  2. tar -zvxf readline-6.2.tar.gz
  3. cd readline-6.2
  4. vi shlib/Makefile
  5. make
  6. sudo make install

When you edit the Makefile (Step # 4) make the following change:

Change line #84 from:
SHOBJ_LDFLAGS = -dynamic

To
SHOBJ_LDFLAGS = -dynamiclib

Friday, October 25, 2013

Fixing Ubuntu Postgres Install

Ubuntu chose to install the default database as LATIN1, this is a problem for "double byte" languages and may cause issues with other languages.

To fix it:

Switch to root then:

export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
pg_dropcluster --stop 9.1 main
pg_createcluster --start -e UTF-8 9.1 main
 
NOTE: This completely nukes your DB install,
don't do this if you already have data in the database.

Thursday, September 5, 2013

Accessing a LVM partion inside a Guest OS Raw Image

Sometimes its handy to be able to access the contents of a Guest OS image before/without booting it up.

It can be a pain as the kernel doesn't recognize the devices without a few extra commands.

For quick refence here they are:

To mount an LVM partition:

  • kpartx -a /var/lib/libvirt/images/CentOSGuest.img
  • pvscan
  • vgchange -ay vg_centguest
  • mount /dev/mapper/vg_centguest-lv_root /mnt
Note: The pvscan is optional, it's useful to allow you to check the group name.

Then to un-mount:
  • umount /mnt
  • vgchange -an vg_centguest
  • kpartx -d /var/lib/libvirt/images/CentGuesst.img

Behind the scenes, this will create a loop device /dev/loop0 so you may want to increase the number of available devices by editing /etc/modules.conf and add the following line:

options loop max_loop=64