Create minecraft server in linux

Make sure you have the latest java from oracle

# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Make a diretory for the server
# mkdir /opt/minecraft

Download minecraft jar

# cd /opt/minecraft && wget https://s3.amazonaws.com/Minecraft.Download/versions/1.8.1/minecraft_server.1.8.1.jar

Run the server for the first time, it will create its settings file and ask you to accept the eula

# java -Xms32M -Xmx512M -jar /opt/minecraft/minecraft_server.1.8.1.jar nogui

Quit by issuing ctrl-c and then edit eula.txt,set eula=true
Set your admin user in ops.json

[
  {
    "uuid": "093953b0-ee80-4a0c-a00e-5f13a1a69f25",
    "name": "CDDO",
    "level": 4
  }
]

You can get your user's uuid in http://minecraft-techworld.com/uuid-lookup-tool

Typical Puppet manifest file

class test_class {
    file { "/tmp/testfile":
       content => "Puppet installation, successful\n",
       ensure => present,
       mode   => 644,
       owner  => root,
       group  => root
    }
    file { '/media/HDS':
       ensure => directory,
       mode   => 644,
       owner  => root,
       group  => root
    }
    file { '/media/HDS/MP3':
       ensure => directory,
       mode   => 644,
       owner  => root,
       group  => root
    }
    fstab { "mp3":
	source => '//192.168.1.250/MP3',
	dest => '/media/HDS/MP3',
	type => 'cifs',
	opts => 'username=rdircio,password=whatever,iocharset=utf8,sec=ntlm'
    }
    file { '/media/HDS/VIDEO':
       ensure => directory,
       mode   => 644,
       owner  => root,
       group  => root
    }
    fstab { "video":
        source => '//192.168.1.250/VIDEO',
        dest => '/media/HDS/VIDEO',
        type => 'cifs',
        opts => 'username=rdircio,password=whatever,iocharset=utf8,sec=ntlm'
    }
    file { '/media/HDS/DOCUMENTS':
       ensure => directory,
       mode   => 644,
       owner  => root,
       group  => root
    }
    fstab { "documents":
        source => '//192.168.1.250/DOCUMENTS',
        dest => '/media/HDS/DOCUMENTS',
        type => 'cifs',
        opts => 'username=rdircio,password=whatever,iocharset=utf8,sec=ntlm'
    }
    file { '/media/HDS/pictures':
       ensure => directory,
       mode   => 644,
       owner  => root,
       group  => root
    }
    fstab { "pictures":
        source => '//192.168.1.250/pictures',
        dest => '/media/HDS/pictures',
        type => 'cifs',
        opts => 'username=rdircio,password=whatever,iocharset=utf8,sec=ntlm'
    }
    file { '/media/HDS/SW':
       ensure => directory,
       mode   => 644,
       owner  => root,
       group  => root
    }
    fstab { "sw":
        source => '//192.168.1.250/SW',
        dest => '/media/HDS/SW',
        type => 'cifs',
        opts => 'username=rdircio,password=whatever,iocharset=utf8,sec=ntlm'
    }
}

node "aspireone.lan" {
}

# tell puppet on which client to run the class
node "d510.lan" {
    include test_class
}

node "d610.lan" {
    include test_class
}

Puppet module primer

List installed modules

# puppet module list

Search for available modules

# puppet module search fstab
Notice: Searching https://forge.puppetlabs.com ...
NAME                      DESCRIPTION                                  AUTHOR        KEYWORDS
AlexCline-fstab           The fstab module helps puppet manage ent...  @AlexCline    fstab linux augeas
AlexCline-mounts          The mounts module will help manage mount...  @AlexCline    ext nfs linux fstab
domcleal-augeasproviders  Alternative Augeas-based providers for P...  @domcleal     ssh nrpe host fstab

Install a module

# puppet module install AlexCline-fstab

setup a puppet master and a client in ubuntu 14.x

Make sure all nodes have ntp and are in sync:

# ntpq -pn

Install packages in the puppet server:

# apt-get install facter puppet puppetmaster

Install packages in the puppet clients:

# apt-get install facter puppet

Stop and start puppet in puppet server:

# service puppetmaster stop && service puppetmaster start && service puppetmaster status

Add server section in each puppet client /etc/puppet/puppet.conf:

[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
certificate_revocation = false
[agent]
server = aspireone

List and sign the client cert requests in the puppet master server:

# puppet cert list && puppet cert sign d510.lan && puppet cert sign d610.lan

In case the certs get messed up… in the master server:

 # puppet cert sign -all && puppet cert clean --all 

And in the agent servers:

 # rm -rf /var/lib/puppet/ssl/* && puppet agent --no-daemonize --server aspireone --onetime --verbose && puppet agent --test

gluster 3.5 install and volume operations in ubuntu 14.04

Add package repository to 2 nodes

# add-apt-repository ppa:semiosis/ubuntu-glusterfs-3.5 && apt-get update

Install package

# apt-get install glusterfs-server

Join peers into cluster (where “d510” and “d610” are 2 server names known to each other either by dns or /etc/hosts)

# gluster peer probe d510
# gluster peer probe d610

Create a volume and start it

# gluster volume create vol1 replica 2 transport tcp d510:/gluster-storage d610:/gluster-storage force
# gluster volume start vol1

Check volume status

# gluster volume info all

Check peer status

# gluster peer status

Mount a glusterfs volume in a glusterfs client server

# mount -t glusterfs d510:/vol1 /glustermount

Remove a volume

# gluster volume stop volume1 && gluster volume delete volume1

Remove a node (server) from gluster

# gluster peer detach aspireone

Install a gluster client

#apt-get install glusterfs-client

Remove a brick from a volume with 3 bricks, telling gluster we will now have only 2 replicas:

gluster volume remove-brick replica 2 volume1 aspireone:/gluster-storage

A typical entry in /etc/fstab for a client gluster fs is

 d510:/vol1 /glustermount glusterfs defaults 0 0 

Get vlan using snoop

You could use this script snoopdcp.sh, usage is like this:

# ./snoopdcp.sh nxge1

The script goes like this:

#!/bin/bash

Interface=$1

if [[ -z "$Interface" ]]
then
  echo "[FATAL]Usage $0 "
  exit 1
fi


#snoopfile=$(mktemp /tmp/snoopy.XXXX)
snoopfile=/tmp/snoopy.XXXX.$$
snoop -d $Interface -c 1 -vv  -o $snoopfile 'dst 01:00:0c:cc:cc:cc and length > 50'
instr=$(snoop -i $snoopfile  -x 26 | nawk -F: ' { print $2 } ' |  cut -b1-41|  sed -e 's/ //g' | nawk 'BEGIN {ORS=""} {print toupper($1)}')
rm -f -- $snoopfile

while  [[ -n "$instr" ]]
do
  typ=`echo $instr | cut -b1-4`
  lhex=`echo $instr | cut -b5-8`
  length=$(echo "ibase=16; $lhex*2" | bc)
  next=$(echo "ibase=16; $lhex*2+1" | bc)
  if [ $length -gt 8 ]
  then
    texthex=`echo $instr | cut -b9-$length`
  else
    texthex=""
  fi
  #  echo "$typ $lhex $texthex"
  if [ $typ == "0001" ]
  then
    printf "Switchname: "
    while  [ $texthex ]
    do
      charhex=`echo $texthex | cut -b1-2`
      chardec=$(echo "ibase=16; $charhex" | bc)
      printf "%b" `printf '\x%x' $chardec 2>/dev/null`
      texthex=`echo $texthex | cut -b3-`
    done
    echo " "
  fi
  if [ $typ == "0003" ]
  then
    printf "Switchport: "
    while  [ $texthex ]
    do
      charhex=`echo $texthex | cut -b1-2`
      chardec=$(echo "ibase=16; $charhex" | bc)
      printf "%b" `printf '\x%x' $chardec 2>/dev/null`
      texthex=`echo $texthex | cut -b3-`
    done
    echo " "
  fi
  if [ $typ == "000A" ]
  then
    echo "VLAN: 0x$texthex $(echo "ibase=16; $texthex" | bc)"
  fi
  if [ $typ == "000B" ]
  then
    echo "Duplex: $texthex"
  fi
  instr=`echo $instr | cut -b$next-`
done

post a tweet to my twitter, using python’s tweepy

I automated a twitter update from a random fortune quote, using python and the tweepy library.
First i installed tweepy

# pip install tweepy

Then, created /opt/bin/tweepy

#!/opt/bin/python
import tweepy, sys, commands
quote=commands.getoutput("/opt/bin/fortune")
consumer_key, consumer_secret, access_token, access_token_secret = "xxxxxx", "xxxx", "xxx", "xxx"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
#print "Successfully logged in as " + api.me().name + "."
api.update_status(quote)

And.. that’s it!. As easy as 1..2..