625 lines
16 KiB
HTML
625 lines
16 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Shell script</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.63
|
|
"><LINK
|
|
REL="HOME"
|
|
TITLE="GNU/Linux Post-Installation Checklist"
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Post-Installation Steps"
|
|
HREF="steps.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>GNU/Linux Post-Installation Checklist: Defying Murphy's Laws</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="steps.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
> </TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="SHELLSCRIPT"
|
|
>3. Shell script</A
|
|
></H1
|
|
><P
|
|
>The shell script (shivalik Ver. 1.0) is a convenient way to make
|
|
backups of essential files and information. After downloading the
|
|
script:</P
|
|
><P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>Make sure that you have logged in as "root"</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Save the script in a directory with "root" permissions,
|
|
say <TT
|
|
CLASS="FILENAME"
|
|
>/root/myscript</TT
|
|
> </P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Change to that directory i.e. <B
|
|
CLASS="COMMAND"
|
|
>cd /root/myscript</B
|
|
>
|
|
use gunzip to unzip the script i.e <B
|
|
CLASS="COMMAND"
|
|
>gunzip ./shivalik.gz</B
|
|
></P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><DIV
|
|
CLASS="NOTE"
|
|
><BLOCKQUOTE
|
|
CLASS="NOTE"
|
|
><P
|
|
><B
|
|
>IMPORTANT: </B
|
|
>You must read the warning given at the end of the
|
|
script. Proceed with the next steps, only if you agree to the
|
|
conditions specified in the warning...</P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
></P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>To execute the script: You must make the script executable (by root
|
|
only) <B
|
|
CLASS="COMMAND"
|
|
>chmod 700 ./shivalik</B
|
|
></P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Verify that the paths of the various files which are to be saved, are
|
|
correct and conform to your installation.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>You can execute the script correctly only if you are "root" (many
|
|
of the files being saved need root permissions).</P
|
|
></LI
|
|
></UL
|
|
><P
|
|
> Now you can execute (run) the above script (remember you must be
|
|
"root", to do this) -- type <B
|
|
CLASS="COMMAND"
|
|
>./shivalik</B
|
|
></P
|
|
><P
|
|
> The script is profusely documented. It does not modify (or
|
|
delete) any of your files or directories. It creates a
|
|
well-protected backup of some essential files and information.
|
|
The entire script is available for you to browse and understand
|
|
its working. Feel free to go through the script and add any
|
|
additional features, or files which you wish to be backed up.
|
|
You may also send your feedback to the author of this
|
|
script (<TT
|
|
CLASS="EMAIL"
|
|
><<A
|
|
HREF="mailto:algolog@hd1.vsnl.net.in"
|
|
>algolog@hd1.vsnl.net.in</A
|
|
>></TT
|
|
>).</P
|
|
><P
|
|
> Remember, the <B
|
|
CLASS="COMMAND"
|
|
>shivalik</B
|
|
> script is not a tool
|
|
for complete backup and recovery. Ideally, the best thing to do
|
|
would be to make a verbatim copy of your entire Linux
|
|
installation along with all files and directories. This is not
|
|
always possible, necessary, or advisable. The next best thing
|
|
would be to take a backup of the most essential information and
|
|
files. The <B
|
|
CLASS="COMMAND"
|
|
>shivalik</B
|
|
> script achieves this for
|
|
you. The script creates a directory called
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/</TT
|
|
>, and stores all essential
|
|
information (and files) there. To be absolutely prepared for any
|
|
eventuality, you must copy the entire
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/</TT
|
|
> on a removable medium, as
|
|
soon as the script is executed.</P
|
|
><P
|
|
><EM
|
|
>Recovery and Repair:</EM
|
|
> In the
|
|
event of any problems later, you can reconstruct the
|
|
damaged files by copying the files you have backed up in the
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/</TT
|
|
> directory. It is as simple
|
|
as that.</P
|
|
><P
|
|
> The structure of the <TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/</TT
|
|
> directory,
|
|
and files found within, will be as follows:</P
|
|
><P
|
|
></P
|
|
><DIV
|
|
CLASS="VARIABLELIST"
|
|
><DL
|
|
><DT
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/summary</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>Contains a summary report of the status of your system (memory,
|
|
partitions, mount points, disk usage). This file also has the list of
|
|
files which have been saved. It also contains admin info like date
|
|
and time of backup, shivalik version number etc.</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/postinfo.tar.gz</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>Contains a copy of the earlier postinfo (if any). This is a fall
|
|
back to a fall back!</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/snapshot.gz</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>Contains a gzipped structured listing of <EM
|
|
>ALL</EM
|
|
>
|
|
files and directories of your Linux system (the directories "tree").
|
|
You can unzip this file and use any plain text editor to know the
|
|
location of any file. Of course, you cannot retrieve the contents of
|
|
that file unless you had saved it explicitly elsewhere.</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/shivalik</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>This is a copy of the shivalik script which was used for making the
|
|
post install backup. At the time of recovery after an incident, you
|
|
can always examine this script to know how the backup was done
|
|
earlier. You will always have a consistent copy of the script and the
|
|
files created by the script.</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/etcfiles/</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>This <EM
|
|
>subdirectory</EM
|
|
> contains a copy of many
|
|
essential files from the <TT
|
|
CLASS="FILENAME"
|
|
>/etc/</TT
|
|
> directory of your
|
|
Linux installation. It also contains copies of the various
|
|
configuration files stored in the <TT
|
|
CLASS="FILENAME"
|
|
>/etc/</TT
|
|
>
|
|
directory.</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="FILENAME"
|
|
>/root/postinfo/otherfiles/</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>This <EM
|
|
>subdirectory</EM
|
|
> contains a copy of some
|
|
essential files (those which are not in the
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/etc/</TT
|
|
> directory) of your Linux installation. If
|
|
you want, you can add any other files here, and get it saved
|
|
automatically with others.</P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="SCRIPT"
|
|
>3.1. The script...</A
|
|
></H2
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="PROGRAMLISTING"
|
|
>#-----------------------------------------------
|
|
# shivalik \(Ver. 1.0\)
|
|
#Please read the WARNING section of this script first
|
|
|
|
#This script collects post installation information
|
|
#this can also be run occasionally to collect all useful
|
|
#information about your Linux installation, in one place
|
|
#The output will be written to /root/postinfo/
|
|
#a summary report will be written in /root/postinfo/summary
|
|
|
|
#For usage and related information, please consult:
|
|
#http://algolog.tripod.com/postlnx.htm
|
|
# ----------------------------------------------
|
|
|
|
clear
|
|
echo
|
|
echo "-----------------------------------------------------------"
|
|
echo This is the output of Partha\'s shivalik script \(Ver.1.0\)
|
|
echo You must be \"root\", for this script to work correctly
|
|
echo You must also read and accept the terms and warnings given
|
|
echo in the WARNINGS section of this script
|
|
echo "-----------------------------------------------------------"
|
|
echo
|
|
echo "### STEP 0 ### Preparation work"
|
|
echo First we create the /root/postinfo/ directory if does not exist already
|
|
test ! -d /root/postinfo && mkdir /root/postinfo
|
|
|
|
echo Saving current version of all postinfo files
|
|
echo But first we delete the earlier version i.e. current-1 version
|
|
test -e /root/postinfo/oldpostinfo* && rm /root/postinfo/oldpostinfo.tar.gz
|
|
#the oldpostinfo file is made temporarily in /root
|
|
#it will be moved to /root/postinfo
|
|
tar -zcvf /root/oldpostinfo.tar.gz /root/postinfo/*
|
|
|
|
#check if above tar succeeded
|
|
if
|
|
test -s /root/oldpostinfo.tar.gz
|
|
then
|
|
echo old postinfo saved in /root/oldpostinfo.tar.gz
|
|
ls -l /root/oldpostinfo*
|
|
else
|
|
echo Could not save oldpostinfo
|
|
echo Abandoning shivalik script
|
|
exit
|
|
fi
|
|
|
|
|
|
#now delete all the current postinfofiles
|
|
rm -rf /root/postinfo/*
|
|
#and start a new summary file
|
|
echo shivalik \(Ver. 1.0\) > /root/postinfo/summary
|
|
echo -n "Report created on: " >> /root/postinfo/summary
|
|
date -R >> /root/postinfo/summary
|
|
echo And now, move the oldpostinfo file to /root/postinfo/ directory
|
|
mv /root/oldpostinfo.tar.gz /root/postinfo
|
|
#
|
|
|
|
#copy the shivalik script
|
|
echo charity begins at home
|
|
echo We make a copy of the shivalik script
|
|
echo We make a copy of the shivalik script >> /root/postinfo/summary
|
|
echo in /root/postinfo/ >> /root/postinfo/summary
|
|
cp ./shivalik /root/postinfo/shivalik
|
|
|
|
#taking stock
|
|
echo
|
|
echo Contents of /root/postinfo at the end of STEP-0
|
|
ls -AlR /root/postinfo
|
|
echo End of "### STEP 0 ###
|
|
echo
|
|
#
|
|
#
|
|
echo
|
|
echo "### STEP 1 ### Make a snapshot of the system"
|
|
echo >> /root/postinfo/summary
|
|
echo "### STEP 1 ### A snapshot of all the files and directories" >> /root/postinfo/summary
|
|
echo The first step is to take stock of your computer contents
|
|
echo This is going to take several minutes
|
|
echo So, go and fetch your coffee mug !
|
|
ls -AlRH / >> /root/postinfo/snapshot
|
|
rm -f /root/postinfo/snapshot.gz
|
|
gzip /root/postinfo/snapshot
|
|
echo snapshot created
|
|
echo An exhaustive listing of all files has been made and >> /root/postinfo/summary
|
|
echo stored in /root/postinfo/snapshot.gz >> /root/postinfo/summary
|
|
ls -l /root/postinfo/snapshot.gz >> /root/postinfo/summary
|
|
|
|
# taking stock at the end of this step
|
|
echo
|
|
echo Contents of /root/postinfo at the end of this STEP
|
|
ls -l /root/postinfo
|
|
echo End of "### STEP 1 ###
|
|
echo
|
|
#
|
|
#
|
|
echo
|
|
|
|
echo "### STEP 2 ### Vital statistics"
|
|
echo >> /root/postinfo/summary
|
|
echo "### STEP 2 ### Vital statistics" >> /root/postinfo/summary
|
|
|
|
echo Collecting vital statistics
|
|
|
|
echo .....about memory
|
|
echo "---- cat /proc/meminfo ---------" >> /root/postinfo/summary
|
|
cat /proc/meminfo >> /root/postinfo/summary
|
|
|
|
echo .....about partitions and mountpoints
|
|
echo "---- cat /proc/partitions---------" >> /root/postinfo/summary
|
|
cat /proc/partitions >> /root/postinfo/summary
|
|
|
|
echo .....about diskspace used
|
|
echo "---- df ---------" >> /root/postinfo/summary
|
|
df >> /root/postinfo/summary
|
|
|
|
echo .....about modules
|
|
echo "---- cat /proc/modules ---------" >> /root/postinfo/summary
|
|
cat /proc/modules >> /root/postinfo/summary
|
|
|
|
# taking stock at the end of this step
|
|
|
|
echo
|
|
echo Contents of /root/postinfo at the end of STEP-2
|
|
ls -AlR /root/postinfo
|
|
echo End of "### STEP 2 ###
|
|
echo
|
|
#
|
|
#
|
|
echo
|
|
echo "### STEP 3 ### Now we save some important files from /etc "
|
|
echo This section may need some customising, depending on the
|
|
echo installation you have done, and the distribution you have used,
|
|
echo and the options you have chosen during installation.
|
|
|
|
echo >> /root/postinfo/summary
|
|
echo "### STEP 3 ### Now we save some important files from /etc" >> /root/postinfo/summary
|
|
test ! -d /root/postinfo/etcfiles && mkdir /root/postinfo/etcfiles
|
|
|
|
echo ..... saving XF86Config -- your XWindows config file
|
|
cp /etc/XF86Config /root/postinfo/etcfiles
|
|
echo "cp /etc/XF86Config /root/postinfo/" >> /root/postinfo/summary
|
|
|
|
echo ..... saving /etc/fstab file
|
|
cp /etc/fstab /root/postinfo/etcfiles
|
|
echo "cp /etc/fstab /root/postinfo/" >> /root/postinfo/summary
|
|
|
|
echo ..... saving /etc/profile file
|
|
cp /etc/profile /root/postinfo/etcfiles
|
|
echo "cp /etc/profile /root/postinfo/" >> /root/postinfo/summary
|
|
|
|
echo ..... saving /etc/profile.local file
|
|
cp /etc/profile.local /root/postinfo/etcfiles
|
|
echo "cp /etc/profile.local /root/postinfo/" >> /root/postinfo/summary
|
|
|
|
echo ".... saving /etc/*conf files"
|
|
cp /etc/*conf /root/postinfo/etcfiles
|
|
|
|
echo ".... saving /etc/*config files"
|
|
cp /etc/*config /root/postinfo/etcfiles
|
|
|
|
echo the following files from /etc have been copied to /root/postinfo/etcfiles >> /root/postinfo/summary
|
|
echo "/etc/*conf" >> /root/postinfo/summary
|
|
echo "/etc/*config" >> /root/postinfo/summary
|
|
|
|
# taking stock at the end of this step
|
|
echo
|
|
echo Contents of /root/postinfo at the end of this STEP-3
|
|
ls -AlR /root/postinfo
|
|
echo End of "### STEP 3 ###
|
|
echo
|
|
#
|
|
#
|
|
|
|
echo
|
|
echo "### STEP 4 ### Now we save some other important files"
|
|
echo This section may need some customising, depending on the
|
|
echo installation you have done, and the distribution you have used,
|
|
echo and the options you have chosen for the installation
|
|
echo The following stuff is designed for SuSe 7.1
|
|
|
|
echo "### STEP 4 ### Now we save some other important files" >> /root/postinfo/summary
|
|
echo in /root/postinfo/otherfiles >> /root/postinfo/summary
|
|
echo You can add any other files to backed up, here
|
|
test ! -d /root/postinfo/otherfiles && mkdir /root/postinfo/otherfiles
|
|
ls -l /root/postinfo/
|
|
|
|
echo ..... saving /etc/init.d/boot.local --
|
|
cp /etc/init.d/boot.local /root/postinfo/otherfiles
|
|
echo "cp /etc/init.d/boot.local /root/postinfo/otherfiles" >> /root/postinfo/summary
|
|
|
|
echo ..... saving /etc/init.d/halt.local --
|
|
cp /etc/init.d/halt.local /root/postinfo/otherfiles
|
|
echo "cp /etc/init.d/halt.local /root/postinfo/otherfiles" >> /root/postinfo/summary
|
|
|
|
# taking stock at the end of this step
|
|
echo
|
|
echo Contents of /root/postinfo at the end of this STEP-4
|
|
ls -AlR /root/postinfo
|
|
echo End of "### STEP 4 ###
|
|
echo
|
|
|
|
echo
|
|
echo "### STEP 999 ### Wrap up, clean up"
|
|
echo >> /root/postinfo/summary
|
|
|
|
echo "### STEP 999 ### Wrap up, clean up, sum up" >> /root/postinfo/summary
|
|
echo summing up, cleaning up
|
|
# for security reasons we make /root/postinfo inaccessible to
|
|
# and invisible to non-root
|
|
chmod 700 /root/postinfo
|
|
chmod 700 /root/postinfo/etcfiles
|
|
chmod 700 /root/postinfo/otherfiles
|
|
chmod 700 /root/postinfo/*
|
|
chmod 700 /root/postinfo/etcfiles/*
|
|
chmod 700 /root/postinfo/otherfiles/*
|
|
echo This is the contents of /root/postinfo >> /root/postinfo/summary
|
|
ls -AlR /root/postinfo >> /root/postinfo/summary
|
|
echo "###### THE END #####" >> /root/postinfo/summary
|
|
|
|
|
|
|
|
# taking stock at the end of this step
|
|
echo
|
|
echo Contents of /root/postinfo at the end of this STEP-999
|
|
ls -AlR /root/postinfo
|
|
echo End of "### STEP 999 ###"
|
|
echo
|
|
echo "###### THE END #####"
|
|
echo IMPORTANT: You must now copy all the files in /root/postinfo
|
|
echo to a safe location, preferably on a different drive or on
|
|
echo a removable backup medium.
|
|
echo " "
|
|
echo You will find a summary report of this procedure, in
|
|
echo /root/postinfo/summary
|
|
echo You will find the earlier version of summary \(if any\)
|
|
echo inside /root/postinfo/oldpostinfo.tar.gz
|
|
echo " "
|
|
|
|
#
|
|
echo "
|
|
#---------------------------------------------------------
|
|
# WARNING WARNING WARNING
|
|
# shivalik (ver. 1.0)
|
|
# This script is being made accessible to you without any
|
|
# warranties or assurances about its performance or
|
|
# usability for any purpose. Be informed that you are using
|
|
# this script out of your own initiative and willingness,
|
|
# and at your own risk and peril.
|
|
# You will find the latest version of this script, and related
|
|
# information at: http://algolog.tripod.com/postlnx.htm
|
|
# Copyrights and all rights reserved by:
|
|
# Dr. S. Parthasarathy (algolog@hd1.vsnl.net.in)
|
|
#--------------------------------------------------------
|
|
"</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="steps.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
> </TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Post-Installation Steps</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
> </TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |