Creating a chroot environment – the script.

2011-09-23 2 min read Bash Fedora Learning Linux

Here is the script, very simple and effective 🙂

#!/bin/bash -
#===============================================================================
#
#          FILE:  mkchroot.sh
#
#         USAGE:  ./mkchroot.sh
#
#   DESCRIPTION:  Make a  chroot environ and cd to it
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Amit Agarwal (aka), 
#       CREATED: 09/03/2011 02:53:37 PM IST
# Last modified: Sat Sep 03, 2011  03:11PM
#      REVISION:  ---
#===============================================================================

 binaries=( bash2 ls cat vi vim sudo)
#===  FUNCTION  ================================================================
#          NAME:  copy_binary
#   DESCRIPTION:  copy binary to chroot
#    PARAMETERS:
#       RETURNS:
#===============================================================================

copy_binary ()
{
   cmd=`which $1`
   echo $cmd
   cp $cmd bin/
   ldd $cmd
   while read line
   do
      while read ld
      do
         if [[ -f $ld ]]
         then
            echo copy $ld
            cp $ld lib/
            if [[ -L $ld ]]
            then
               ld1=$( ls -l $ld |sed 's/.*> //')
               echo "  copy $ld1"
               cp  /lib/$ld1 lib/
            fi
         fi
      done < <(echo $line|sed 's/.*> //'|sed 's/ .*//')
   done < <(ldd $cmd)
}	# ----------  end of function copy_binary  ----------

#===  FUNCTION  ================================================================
#          NAME:  init
#   DESCRIPTION:  Do the required initialization
#    PARAMETERS:
#       RETURNS:
#===============================================================================
init()
{
   mkdir -p {root,home,dev,etc,lib,usr,bin}
   mkdir -p usr/bin
   mkdir -p libexec/openssh



   mknod -m 666 dev/null c 1 3

   cd etc
   cp /etc/ld.so.cache .
   cp -avr /etc/ld.so.cache.d/ .
   cp -avr /etc/ld.so.conf.d/ .
   cp /etc/ld.so.conf .
   cp /etc/nsswitch.conf .
   cp /etc/passwd .
   cp /etc/group .
   cp /etc/hosts .
   cp /etc/resolv.conf .
   cd -
}
cd $1
if [[ -f .status ]]
then
   cat .status
   echo "Not running now"
else
   init
   for i in ${binaries[*]}
   do
       copy_binary $i
       cp -avr /etc/${i}* etc/
   done
   ln bin/bash2 bin/bash
   echo "complete" > .status
fi
cp -avr ~/bin/automation root/automation
sudo chroot .

.

Continue reading

Gnome 3 screenshot with conky dock

2011-08-18 1 min read Fedora GNOME

Just to give you a idea of how beautiful it looks, here’s a screenshot 🙂

[gnome3-desktop][1]
gnome3-desktop
Enhanced by Zemanta

Total upload and download on any interface.

2011-06-05 1 min read Bash Fedora

Something that I have been searching for a long time, finally some look inside the <a class=“zem_slink” title=“Procfs” rel=“wikipedia” href=“http://en.wikipedia.org/wiki/Procfs" _mce_href=“http://en.wikipedia.org/wiki/Procfs">/proc got me what I wanted. Hope this will save someone’s day. So far, the only option I could think of was to run conky which becomes a little heave on some of the very old laptops I have to use sometimes 🙁

  <td>
    <div class="text codecolorer">
      &nbsp;cat /proc/net/dev|grep eth2|awk '{print $2/1024/1024"&nbsp; "$10/1024/1024}'
    </div>
  </td>
</tr>
1
Enhanced by Zemanta

Unix shell script for removing duplicate files

2011-05-16 1 min read Bash Linux

The following shell script finds duplicate (2 or more identical) files and outputs a new shell script containing commented-out rm statements for deleting them (copy-paste from here):

::: updated on 02 May 20121, seems like wordpress did not like it so well so reformatting the code :::::::

#!/bin/bash -
#===============================================================================
#
#          FILE:  a.sh
#
#         USAGE:  ./a.sh
#
#   DESCRIPTION:
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Amit Agarwal (aka), amit.agarwal@roamware.com
#       COMPANY: blog.amit-agarwal.co.in
#       CREATED: 02/05/12 06:52:08 IST
# Last modified: Wed May 02, 2012  07:03AM
#      REVISION:  ---
#===============================================================================

OUTF=rem-duplicates.sh;
echo "#!/bin/sh" >$OUTF;
find "$@" -type f -exec md5sum {} \; 2>/dev/null | sort --key=1,32 | uniq -w 32 -d |cut -b 1-32 --complement |sed 's/^/rm -f/' >>$OUTF

Pretty good one line, I must say 🙂

Continue reading

Results of Fedora 16 Release Name Voting

2011-04-20 1 min read Fedora

Fedora 16 is codenamed Verne. Here are other details:

The voting has concluded for the Fedora 16 release name, and the
results are in!  Thank you to the Fedora community members who made
name suggestions and participated in the voting.

The Fedora 16 release name is: Verne

Voting period:  Tuesday 2011-04-05 00:00:00 to Monday 2011-04-11 23:59:59
Number of valid ballots cast:  421

Using the range voting method, each candidate could attain a maximum
of (421*9) = 3789 votes.

Continue reading

Introducing /run – what is this directory doing in my root directory?

2011-04-13 1 min read Linux

boot process with EFI on Intel Macs
Image via Wikipedia

http://lwn.net/Articles/436012/

There is a suggestion to add /run directory that will be mounted as tmpfs. This directory will be mounted early in the boot process and can be used in various scenario’s. I hope this will improve few things in the linux world.

Enhanced by Zemanta

sakura – Reaaly good terminal with very few dependencies.

2011-03-30 1 min read Fedora Uncategorized

I was searching for something in the Fedora repos and found a really good terminal, sakura. Its very much like Gnome-terminal. I did not find much difference other than using less memory.

To install:

  <td>
    <div class="text codecolorer">
      sudo yum install sakura
    </div>
  </td>
</tr>
1

and the details of the package:

Name        : sakura
Arch : i686
Version     : 2.3.8
Release     : 1.fc14
Size        : 137 k
Repo        : installed
From repo   : fedora
Summary     : Terminal emulator based on GTK and VTE
URL : http://pleyades.net/david/sakura.php
License     : GPLv2
Description : Sakura is a terminal emulator based on GTK and VTE. It’s a terminal emulator
with few dependencies, so you don’t need a full GNOME desktop installed to
have a decent terminal emulator.
Enhanced by Zemanta
Older posts Newer posts