docker1&2 setup note

FLOATING_RANGE=192.168.140.0/27
FIXED_RANGE=10.11.12.0/24
FIXED_NETWORK_SIZE=256
FLAT_INTERFACE=eth1
ADMIN_PASSWORD=g
MYSQL_PASSWORD=g
RABBIT_PASSWORD=g
SERVICE_PASSWORD=g
SERVICE_TOKEN=g
SCHEDULER=nova.scheduler.filter_scheduler.FilterScheduler
VIRT_DRIVER=docker
SCREEN_LOGDIR=$DEST/logs/screen
----------------------------------------------------------------
 cat install_docke0.sh
#!/usr/bin/env bash

# **install_docker.sh** - Do the initial Docker installation and configuration

# install_docker.sh
#
# Install docker package and images
# * downloads a base busybox image and a glance registry image if necessary
# * install the images in Docker's image cache


# Keep track of the current directory
SCRIPT_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $SCRIPT_DIR/../..; pwd)

# Import common functions
source $TOP_DIR/functions

# Load local configuration
source $TOP_DIR/stackrc

FILES=$TOP_DIR/files

# Get our defaults
source $TOP_DIR/lib/nova_plugins/hypervisor-docker

SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}


# Install Docker Service
# ======================

# Stop the auto-repo updates and do it when required here
NO_UPDATE_REPOS=True

# Set up home repo
curl https://get.docker.io/gpg | sudo apt-key add -
install_package python-software-properties && \
    sudo sh -c "echo deb $DOCKER_APT_REPO docker main > /etc/apt/sources.list.d/docker.list"
apt_get update
install_package --force-yes lxc-docker-${DOCKER_PACKAGE_VERSION} socat
###############################################################################################
cat install_docke1.sh
#!/usr/bin/env bash

# **install_docker.sh** – Do the initial Docker installation and configuration

# install_docker.sh
#
# Install docker package and images
# * downloads a base busybox image and a glance registry image if necessary
# * install the images in DockerÂ’s image cache

# Keep track of the current directory
SCRIPT_DIR=$(cd $(dirname $0?) && pwd)
TOP_DIR=$(cd $SCRIPT_DIR/../..; pwd)

# Import common functions
source $TOP_DIR/functions

# Load local configuration
source $TOP_DIR/stackrc

FILES=$TOP_DIR/files

# Get our defaults
source $TOP_DIR/lib/nova_plugins/hypervisor-docker

SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}

# Install Docker Service
# ======================

# Stop the auto-repo updates and do it when required here
NO_UPDATE_REPOS=True

# Start the daemon – restart just in case the package ever auto-starts…
#restart_service docker

echo Waiting for docker daemon to start
DOCKER_GROUP=$(groups | cut -d' ' -f1)
CONFIGURE_CMD="while ! /bin/echo -e 'GET /v1.3/version HTTP/1.0\n\n' | socat - unix-connect:$DOCKER_UNIX_SOCKET | grep -q '200 OK'; do

echo failure
sleep 1
done"
if ! timeout $SERVICE_TIMEOUT sh -c "$CONFIGURE_CMD"; then
die $LINENO docker did not start
fi

Changing Priority Values for process/scripts

Changing priority of process/or running script :
-------------------------------------------------
Use top or ps
------------------------------------------------
eg. ./myscript.sh
#ps -ef | grep myscript
get the process id...
eg.4545
#ps -o pid,comm,nice -p 4545            //pid,,comm=command,nice=nice value of process , -p = processid, -o = outputformat

#ps -efl     <displays nice values>
....
......
#renice -15 -p 4545

// / nice value ranges from -20 to 19 ..negative value have higher priority(eg.-20 is highest priority and 19 have lowest , default priority is 0)
==============================================
To set nice value/ priority for process/script/cmd to be started
======================================================
#nice -n 10 apt-get upgrade
#nice -n -11 ./myscript.sh

user del mod etc..

Display list of shell
Code:
less  /etc/shells
cat  /etc/shells
more /etc/shells
Change the user login shell to /bin/ksh for foo user
Code:
chsh -s /bin/ksh foo
chsh -s /bin/bash username

-----------------
Adding user
-----------------
Syntax: # useradd -s <SHELL> -m -d <HomeDir> -g <Group> UserName


-s SHELL : Login shell for the user.
-m : Create user’s home directory if it does not exist.
-d HomeDir : Home directory of the user.
-g Group : Group name or number of the user.
UserName : Login id of the user.

Create Linux User with Custom Configurations Using useradd Command
-----------------------------------------------------------------------------
The following example creates an account (lebron) with home directory /home/king, default shell as /bin/csh and with comment “LeBron James”.

# useradd -s /bin/csh -m -d /home/king -c "LeBron James" -g root lebron

# grep lebron /etc/passwd

lebron:x:513:0:LeBron James:/home/king:/bin/csh
 -------------------------
Verify user information:
-------------------------
# finger david

Output:

Login: david                      Name: david gilmour
Directory: /iscsi/user/vivek                Shell: /bin/bash
Last login Thu Sep 13 07:58 2007 (IST) on pts/1 from 10.16.15.2
No mail.
No Plan.
------------------------------------------------------------------------------------------------------
You can use the usermod command. The following (run as root) will change the user smith's 
home directory to /tmp/smith and move all of their files with it.

Code:
usermod -m -d   /tmp/smith smith


Add an Existing User to a Group
Next we’ll add a user to the group, using this syntax:
usermod -a -G <groupname> username
eg. usermod -a -G dockergroup  stackuser

Retain Un allocated space in USB drive


C:\Users\New Tech>diskpart
Microsoft DiskPart version 6.2.9200

Copyright (C) 1999-2012 Microsoft Corporation.
On computer: NPLP05

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          465 GB      0 B
  Disk 1    No Media           0 B      0 B                                 //this is dvd/cd ROM
  Disk 2    Online           14 GB      0 B

DISKPART> select disk 2

Disk 2 is now the selected disk.

DISKPART> clean

DiskPart succeeded in cleaning the disk.

DISKPART> create partition primary

DiskPart succeeded in creating the specified partition.

DISKPART> exit

Leaving DiskPart...

C:\Users\New Tech> / // the partition of usb drive is in FAT by default

Block Level Storage & File Level Storage

Anyone who has used a Storage Area Network (SAN) has probably used block level storage before. Block level storage presents itself to servers using industry standard Fibre Channel and iSCSI connectivity mechanisms. In its most basic form, think of block level storage as a hard drive in a server except the hard drive happens to be installed in a remote chassis and is accessible using Fibre Channel or iSCSI.

 When it comes to flexibility and versatility, you can't beat block level storage. In a block level storage device, raw storage volumes are created, and then the server-based operating system connects to these volumes and uses them as individual hard drives. This makes block level storage usable for almost any kind of application, including file storage, database storage, virtual machine file system (VMFS) volumes, and more. You can place any kind of file system on block level storage. So, if you're running Windows, your volumes will be formatted with NTFS; VMware servers will use VMFS.
Remember, when you use a block-based volume, you're basically using a blank hard drive with which you can do anything.
From a use case standpoint, there are a lot of applications that make use of this block-level shared storage, including:
  • Databases. This is especially true when you want to cluster databases, since clustered databases need shared storage.
  • Exchange. Although Microsoft has made massive improvements to Exchange, the company still does not support file level or network-based (as in, CIFS or NFS) storage. Only block level storage is supported.
  • VMware. Although VMware can use file level storage via Network File System (NFS), it's very common to deploy VMware servers that use shared VMFS volumes on block level storage.
  • Server boot. With the right kind of storage device, servers can be configured to boot from block level storage.
 File level storage is usually accessible using common file level protocols such as SMB/CIFS (Windows) and NFS (Linux, VMware). In the block level world, you need to create a volume, deploy an OS, and then attach to the created volume; in the file level world, the storage device handles the files and folders on the device.


The two most popular storage system technologies are file level storage and block level storage. File level storage is seen and deployed in Network Attached Storage (NAS) systems. Block level storage is seen and deployed in Storage Area Network (SAN) storage. In the article below, we will explain the major differences between file level storage vs. block level storage. File Level Storage - This storage technology is most commonly used for storage systems, which is found in hard drives, NAS systems and so on. In this File Level storage, the storage disk is configured with a protocol such as NFS or SMB/CIFS and the files are stored and accessed from it in bulk.
  • The File level storage is simple to use and implement.
  • It stores files and folders and the visibility is the same to the clients accessing and to the system which stores it.
  • This level storage is inexpensive to be maintained, when it is compared to its counterpart i.e. block level storage.
  • Network attached storage systems usually depend on this file level storage.
  • File level storage can handle access control, integrate integration with corporate directories; and so on.
Block Level Storage - In this block level storage, raw volumes of storage are created and each block can be controlled as an individual hard drive. These Blocks are controlled by server based operating systems and each block can be individually formatted with the required file system.
  • Block level storage is usually deployed in SAN or storage area network environment.
  • This level of storage offers boot-up of systems which are connected to them.
  • Block level storage can be used to store files and can work as storage for special applications like databases, Virtual machine file systems and so on.
  • Block level storage data transportation is much efficient and reliable.
  • Block level storage supports individual formatting of file systems like NFS, NTFS or SMB (Windows) or VMFS (VMware) which are required by the applications.
  • Each storage volume can be treated as an independent disk drive and it can be controlled by external server operating system.
  • Block level storage uses iSCSI and FCoE protocols for data transfer as SCSI commands act as communication interface in between the initiator and the target.

vim vim vim vim vim hacks text substitution useful :

 Search:
1)/searchtext
2)/\csearchtext                     ;for-case insensitive search

Also, \c can appear anywhere in the pattern, so if you type a pattern and then decide you wanted a case-insensitive search, just add a   \c   at the end.




You can set the ic option in Vim before the search:
:set ic
To go back to case-sensitive searches use:
:set noic
ic is shorthand for ignorecase

Substitute all occurrences of a text with another text in the whole file==
Syntax of the text substitution inside vim editor:

:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
--------------------------------------------------------
:%s/old-text/new-text/g

Following are three possible flags.

    [c] =Confirm each substitution.
    [g] =Replace all occurrences in the line.
    [i] =Ignore case for the pattern.
-----------------------------------------------------
her her Hiss iHis
her her is good
mood is her her odis
His
try cry fry fryedHis
-------------------------
:4s/\<His\>/test/g
---------output----------

her her Hiss iHis
her her is good
mood is her her odis
test
try cry fry fryedHis

:2,19s/\<test1\>/mountain/g

=====================================
her her Hiss iHis
her her is good
mood is her her odis
test
try cry fry fryedHis
~                                                                                                                        
:1,5s/\<her\>/nepal/g

Output>>
nepal nepal Hiss iHis
nepal nepal is good
mood is nepal nepal odis
test
try cry fry fryedHis
~
~
6 substitutions on 3 lines

IP Tables --netfilter.org

Next Previous Contents

6. Saying How To Mangle The Packets

So now we know how to select the packets we want to mangle. To complete our rule, we need to tell the kernel exactly what we want it to do to the packets.

6.1 Source NAT

You want to do Source NAT; change the source address of connections to something different. This is done in the POSTROUTING chain, just before it is finally sent out; this is an important detail, since it means that anything else on the Linux box itself (routing, packet filtering) will see the packet unchanged. It also means that the `-o' (outgoing interface) option can be used.
Source NAT is specified using `-j SNAT', and the `--to-source' option specifies an IP address, a range of IP addresses, and an optional port or range of ports (for UDP and TCP protocols only).
## Change source addresses to 1.2.3.4.
# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4

## Change source addresses to 1.2.3.4, 1.2.3.5 or 1.2.3.6
# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4-1.2.3.6

## Change source addresses to 1.2.3.4, ports 1-1023
# iptables -t nat -A POSTROUTING -p tcp -o eth0 -j SNAT --to 1.2.3.4:1-1023

Masquerading

There is a specialized case of Source NAT called masquerading: it should only be used for dynamically-assigned IP addresses, such as standard dialups (for static IP addresses, use SNAT above).
You don't need to put in the source address explicitly with masquerading: it will use the source address of the interface the packet is going out from. But more importantly, if the link goes down, the connections (which are now lost anyway) are forgotten, meaning fewer glitches when connection comes back up with a new IP address.
## Masquerade everything out ppp0.
# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

6.2 Destination NAT

This is done in the PREROUTING chain, just as the packet comes in; this means that anything else on the Linux box itself (routing, packet filtering) will see the packet going to its `real' destination. It also means that the `-i' (incoming interface) option can be used.
Destination NAT is specified using `-j DNAT', and the `--to-destination' option specifies an IP address, a range of IP addresses, and an optional port or range of ports (for UDP and TCP protocols only).
## Change destination addresses to 5.6.7.8
# iptables -t nat -A PREROUTING -i eth0 -j DNAT --to 5.6.7.8

## Change destination addresses to 5.6.7.8, 5.6.7.9 or 5.6.7.10.
# iptables -t nat -A PREROUTING -i eth0 -j DNAT --to 5.6.7.8-5.6.7.10

## Change destination addresses of web traffic to 5.6.7.8, port 8080.
# iptables -t nat -A PREROUTING -p tcp --dport 80 -i eth0 \
        -j DNAT --to 5.6.7.8:8080

Redirection

There is a specialized case of Destination NAT called redirection: it is a simple convenience which is exactly equivalent to doing DNAT to the address of the incoming interface.
## Send incoming port-80 web traffic to our squid (transparent) proxy
# iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 \
        -j REDIRECT --to-port 3128
Note that squid needs to be configured to know it's a transparent proxy!

6.3 Mappings In Depth

There are some subtleties to NAT which most people will never have to deal with. They are documented here for the curious.

Selection Of Multiple Addresses in a Range

If a range of IP addresses is given, the IP address to use is chosen based on the least currently used IP for connections the machine knows about. This gives primitive load-balancing.

Creating Null NAT Mappings

You can use the `-j ACCEPT' target to let a connection through without any NAT taking place.

Standard NAT Behavior

The default behavior is to alter the connection as little as possible, within the constraints of the rule given by the user. This means we won't remap ports unless we have to.

Implicit Source Port Mapping

Even when no NAT is requested for a connection, source port translation may occur implicitly, if another connection has been mapped over the new one. Consider the case of masquerading, which is rather common:
  1. A web connection is established by a box 192.1.1.1 from port 1024 to www.netscape.com port 80.
  2. This is masqueraded by the masquerading box to use its source IP address (1.2.3.4).
  3. The masquerading box tries to make a web connection to www.netscape.com port 80 from 1.2.3.4 (its external interface address) port 1024.
  4. The NAT code will alter the source port of the second connection to 1025, so that the two don't clash.
When this implicit source mapping occurs, ports are divided into three classes:
  • Ports below 512
  • Ports between 512 and 1023
  • Ports 1024 and above.
A port will never be implicitly mapped into a different class.

What Happens When NAT Fails

If there is no way to uniquely map a connection as the user requests, it will be dropped. This also applies to packets which could not be classified as part of any connection, because they are malformed, or the box is out of memory, etc.

Multiple Mappings, Overlap and Clashes

You can have NAT rules which map packets onto the same range; the NAT code is clever enough to avoid clashes. Hence having two rules which map the source address 192.168.1.1 and 192.168.1.2 respectively onto 1.2.3.4 is fine.
Furthermore, you can map over real, used IP addresses, as long as those addresses pass through the mapping box as well. So if you have an assigned network (1.2.3.0/24), but have one internal network using those addresses and one using the Private Internet Addresses 192.168.1.0/24, you can simply NAT the 192.168.1.0/24 source addresses onto the 1.2.3.0 network, without fear of clashing:
# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth1 \
        -j SNAT --to 1.2.3.0/24
The same logic applies to addresses used by the NAT box itself: this is how masquerading works (by sharing the interface address between masqueraded packets and `real' packets coming from the box itself).
Moreover, you can map the same packets onto many different targets, and they will be shared. For example, if you don't want to map anything over 1.2.3.5, you could do:
# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth1 \
        -j SNAT --to 1.2.3.0-1.2.3.4 --to 1.2.3.6-1.2.3.254

Altering the Destination of Locally-Generated Connections

The NAT code allows you to insert DNAT rules in the OUTPUT chain, but this is not fully supported in 2.4 (it can be, but it requires a new configuration option, some testing, and a fair bit of coding, so unless someone contracts Rusty to write it, I wouldn't expect it soon).
The current limitation is that you can only change the destination to the local machine (e.g. `j DNAT --to 127.0.0.1'), not to any other machine, otherwise the replies won't be translated correctly.

Next Previous Contents

How Do I install Python 2.7 on linux (UBUNTU 13.01)

1) #sudo apt-get install build-essential

2)#sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
 

3)#cd ~/Downloads/
 

4)# wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz

5) Extract and go to the dirctory:
--------------------------------------
#tar -xvf Python-2.7.5.tgz
#cd Python-2.7.5

6) Now, install using the command you just tried:
-----------------------------------------------
#./configure
#make
#sudo make altinstall or sudo make install (to set python 2.7 as default ver.)

Using htpasswd

Enforce user to use this plugin “HC Custom WP-Admin URL plugin” -

http://wordpress.org/plugins/hc-custom-wp-admin-url/

Medium but secure approach

i. Go to user home folder and run this cmd

$ htpasswd -c .wpadmin admin

ii. Change the .wpadmin user and group ownership to username.

iii. Goto public_html and open .htaccess, at the bottom of the file, add this

<FilesMatch "wp-login.php">

AuthName "Authorized Only"

AuthType Basic

AuthUserFile /home/username/.wpadmin

require valid-user

</FilesMatch>

NOTE: replace username with actual username.

Install from specific REPOSITORY (centos 6.5)

Query Available Packages From Selected YUM Repository

$ yum --disablerepo="*" --enablerepo="google" list available
Loaded plugins: dellsysidplugin2, refresh-packagekit
Available Packages
google-chrome-beta.i386                                                          5.0.307.9-39052                                                       google
google-chrome-unstable.i386                                                      5.0.322.2-38810                                                       google
google-desktop-linux.i386                                                        1.2.0-0088                                                            google
picasa.i386