Friday, May 30, 2008

Auto install script Network Simulator NS-2

This scripts installs the AllinOne package of NS,NAM,TCL,TK. Please take note that these packages get installed in a specific account. If another user wants to get access to these packages he will have to add the environment variables given below in his ~/.bashrc file.


echo "This script installs NS-2 on Debian Linux(Need to be root)"
cd ~/.
mkdir ns-2
cd ns-2
tar -xzvf ns-allinone-2.31.tar.gz
cd ns-allinone-2.31/
sudo apt-get -y install build-essential autoconf automake libxmu-dev
echo "This command may generate some errors, and if it does, restart your computer and uncomment the step giving in script"
# Uncomment the following command
# sudo apt-get install -f build-essential libxt-dev lins-2.31bxt6 libsm-dev libsm6 libice-dev libice6 libxmu-dev
echo "If the script meshes up your environment variables then restore the backup file"
cp ~/.bashrc ~/.bashrc.bak_by_ns2

# Inserting paths in environment file.
echo "# LD_LIBRARY_PATH" >> ~/.bashrc
echo "OTCL_LIB=$HOME/ns-2/ns-allinone-2.31/otcl-1.13" >> ~/.bashrc
echo "NS2_LIB=$HOME/ns-2/ns-allinone-2.31/lib" >> ~/.bashrc
echo "X11_LIB=/usr/X11R6/lib" >> ~/.bashrc
echo "USR_LOCAL_LIB=/usr/local/lib" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$OTCL_LIB:$NS2_LIB:\$X11_LIB:\$USR_LOCAL_LIB" >> ~/.bashrc

echo "# TCL_LIBRARY" >> ~/.bashrc
echo "TCL_LIB=$HOME/ns-2/ns-allinone-2.31/tcl8.4.14/library" >> ~/.bashrc
echo "USR_LIB=/usr/lib" >> ~/.bashrc
echo "export TCL_LIBRARY=\$TCL_LIB:\$USR_LIB" >> ~/.bashrc

echo "# PATH" >> ~/.bashrc
echo "XGRAPH=$HOME/ns-2/ns-allinone-2.31/bin:$HOME/ns-2/ns-allinone-2.31/tcl8.4.14/unix:$HOME/ns-2/ns-allinone-2.31/tk8.4.14/unix" >> ~/.bashrc
echo "NS=$HOME/ns-2/ns-allinone-2.31/ns-2.31/" >> ~/.bashrc
echo "NAM=$HOME/ns-2/ns-allinone-2.31/nam-1.13/" >> ~/.bashrc
echo "PATH=\$PATH:\$XGRAPH:\$NS:\$NAM" >> ~/.bashrc

# Immediatly taking effect
source ~/.bashrc

# Validating installation
echo "Press Enter to Validate Installation(time consuming) or press CTR-C"
cd ns-2.31

No comments: