Start, Stop & Restart NFSv4 Services Script in CentOS


#!/bin/bash

_me=${0##*/}

RHEL/CentOS init.d Script Names
_server=”/etc/init.d/rpcbind /etc/init.d/rpcidmapd /etc/init.d/nfslock /etc/init.d/nfs”
_client=”/etc/init.d/rpcbind /etc/init.d/rpcidmapd /etc/init.d/nfslock”
_action=”$1″

Running Client Script stop|start|restart|status
runme(){
local i=”$1″
local a=”$2″
for t in $i
do
$t $a
done
}

usage(){
echo “$_me start|stop|restart|reload|status”;
exit 0
}

[ $# -eq 0 ] && usage

Main Logic
case $_me in
nfs.server) runme “$_server” “$_action” ;;
nfs.client) runme “$_client” “$_action” ;;
*) usage
esac

Advertisements

R-Studio Automated Using Script


#!/bin/bash

if [ “lsb_release -is” == “Ubuntu” ] || [ “lsb_release -is” == “Debian” ]
then
sudo apt-get -y install r-base gdebi-core libapparmor1;
sudo wget http://download2.rstudio.org/rstudio-server-0.98.1103-amd64.deb;
sudo gdebi rstudio-server-0.98.1103-amd64.deb;

elif [ “lsb_release -is” == “CentOS” ] || [ “lsb_release -is” == “RedHat” ]
then
sudo yum -y install R openssl098e;
sudo wget http://download2.rstudio.org/rstudio-server-0.98.1103-x86_64.rpm;
sudo yum -y install –nogpgcheck rstudio-server-0.98.1103-x86_64.rpm;
else
echo “Unsupported Operating System”;
fi

sudo rm -f rstudio-server-*;
sudo rstudio-server verify-installation;

Django Automated Script


#!/bin/bash

if [ “lsb_release -is” == “Ubuntu” ] || [ “lsb_release -is” == “Debian” ]
then
sudo apt-get -y install python python-pip python-setuptools python-django;
sudo apt-get -y build-dep python-mysqldb;
sudo apt-get -y install python-mysqldb python-dev git-core;

elif [ “lsb_release -is” == “CentOS” ] || [ “lsb_release -is” == “RedHat” ]
then
sudo wget http://mirrors.nl.eu.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6-8.noarch.rpm;
sudo rm -f epel-release-6-8.noarch.rpm;
sudo yum -y install epel-release python Django MySQL-python;

else
echo “Unsupported Operating System”;
fi

Python-Impala Driver
git clone https://github.com/cloudera/impyla.git;
sudo python impyla/setup.py install;

Screenshot-1

Apache Password Protect Dir


 Apache Config
<Directory /home/user/public_html>
AllowOverride AuthConfig
</Directory>

Alias /protected “/home/user/public_html/protected”
<Location “/protected/”>
SetHandler None
Options -Indexes +FollowSymLinks
allow from all
</Location>

Auth_* Modules Needed
a2enmod auth_basic

Passwd File, Outside Directory Served
htpasswd -c /home/user/.htpasswd myuser

/home/user/public_html/protected/.htaccess file
AuthType Basic
require user myuser
AuthName ‘Protected’
AuthUserFile /home/user/.htpasswd

Adding User in Linux System Script


#!/bin/bash

Script to Add a User to Linux System
if [ $(id -u) -eq 0 ]; then
read -p “Enter username : ” username
read -s -p “Enter password : ” password
egrep “^$username” /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo “$username exists!”
exit 1
else
pass=$(perl -e ‘print crypt($ARGV[0], “password”)’ $password)
useradd -m -p $pass $username
[ $? -eq 0 ] && echo “User has been added to system!” || echo “Failed to add a user!”
fi
else
echo “Only root may add a user to the system”
exit 2
fi

Virtual Box Installation Script


#!/bin/bash

Updating System
sudo apt-get update
sudo apt-get upgrade

Add Virtualbox Repository
sudo sh -c ‘echo “deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib” >> /etc/apt/sources.list’

Downloading Oracle Virtual Box
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add –

Installing Virtualbox 4.2
sudo apt-get install virtualbox-4.2

Desktop Environment Installation on Ubuntu Server


#!/bin/bash

Updating System
sudo apt-get update

Updating Dist-Packages
sudo apt-get upgrade

Installing Ubuntu Desktop on Ubuntu Server
sudo apt-get install ubuntu-desktop

Start GUI
startx

Installing Desktop Manager
sudo apt-get install –no-install-recommends ubuntu-desktop

Installing Xfsc
sudo apt-get install xubuntu-desktop

Installing KDE Desktop
sudo apt-get install kubuntu-desktop