Saturday, March 29, 2014

Windows Batch Scripting Tips

Find files recursively

for /r %%f in (*.abc) do echo %%f

or

for /f "delims=|" %%f in ('dir /B /S *.abc') do echo %%f

Block of statements

(The parentheses must be used exactly as shown)

if %VAR% == 0 (
    echo "statement 1"
    echo "statement 2"
)

Thursday, March 20, 2014

Setup Schroot Environment On Ubuntu

Here is my note about how to setup Ubuntu Lucid schroot environment on a Ubuntu box. Please refer to Ubuntu Document for details.

Software Prerequisits

sudo apt-get install debootstrap
sudo apt-get install schroot

Create a config file for Ubuntu Lucid (x86)

sudo vi /etc/schroot/chroot.d/lucid_i386.conf

Fill in the following content. Please make sure change the user bob to your actual username.

[lucid_i386]
description=Ubuntu 10.04 for i386
directory=/srv/chroot/lucid_i386
personality=linux32
type=directory
root-users=bob
users=bob

Get environment files

sudo mkdir -p /srv/chroot/lucid_i386
sudo debootstrap --arch=i386 lucid /srv/chroot/lucid_i386/ http://archive.ubuntu.com/ubuntu/

Done. Verify environment works

schroot -l
schroot -c lucid_i386 -u root
lsb_release -a

Here is the steps for Ubuntu Lucid (x64)

sudo vi /etc/schroot/chroot.d/lucid_amd64.conf
[lucid_amd64]
description=Ubuntu 10.04 for amd64
directory=/srv/chroot/lucid_amd64
#personality=linux32
type=directory
root-users=bob
users=bob
sudo mkdir -p /srv/chroot/lucid_amd64
sudo debootstrap --arch=amd64 lucid /srv/chroot/lucid_amd64/ http://archive.ubuntu.com/ubuntu/

For Debian Squeeze (x64)

sudo vi /etc/schroot/chroot.d/squeeze_amd64.conf
[squeeze_amd64]
description=Ubuntu 10.04 for amd64
directory=/srv/chroot/squeeze_amd64
#personality=linux32
type=directory
root-users=bob
users=bob
sudo mkdir -p /srv/chroot/squeeze_amd64
sudo debootstrap --arch=amd64 squeeze /srv/chroot/squeeze_amd64/ http://ftp.debian.org/debian/

Saturday, March 15, 2014

Setup Debian in a Virtualbox

The following tips can make it convenient to use debian in a virtual box, but please keep in mind that they are not good practices for a production server.

Disable Sudo Password Requirement

On ubuntu/debian, you could disable sudo password prompt by following the steps below.

sudo visudo

Change

%sudo ALL=(ALL) ALL

to

%sudo ALL=(ALL) NOPASSWD: ALL

Auto login

The following steps can let you log in automatically to a console when boots.

sudo vi /etc/inittab

Change the line

1:2345:respawn:/sbin/getty 38400 tty1

to

1:2345:respawn:/bin/login -f user </dev/tty1 >/dev/tty1 2>&1

Disable Grub Screen

The following steps can disable grub splash screen when boots

sudo vi /etc/default/grub

Change the value of GRUB_TIMEOUT to 0

And then run the following command to update grub config.

sudo update-grub