Quote:
Originally Posted by Tinkster
What *is* configsave, where did it come from?
|
A tool in slackware that save a system configuration for a cd boot.
Here is the script
umount /dev/fd0
rmdir /mnt/jaime
mount_file "$1" "$2" # save file.tgz
cp $TARINC $TARINC.X
tar -C / -czg $TARINC.X -f $CONFIGSAVE $EXCLUDE $INCLUDE
rm $TARINC.X
umount_file_if_mounted
die
;;
'restore')
mount_file "$1" "$2"
if [ -r "$CONFIGSAVE" ];
then
tar -C / -xzf $CONFIGSAVE
umount_file_if_mounted
die "restore config done."
else
umount_file_if_mounted
die "cannot read $CONFIGSAVE"
fi
;;
'makedb')
createdb
die "done creating database."
;;
'--help')
echo "dbdiff v0.99 database-based differences finder"
echo "usage: $0 (call without arguments for interactive menus)"
echo " $0 save filename|devicename"
echo " $0 restore filename|devicename"
echo " $0 makedb"
;;
*)
dialog --title "DBDIFF: save or restore changes" --menu \
"Use this dialog box to select your action.\n\
All the settings and all new or modified files from\n\
/root, /etc and /usr/local will be saved or restored.\n\n" 10 58 0 \
"save" "Save all changes against database" \
"restore" "Restore all changes against database" 2>$TMPFILE
if [ ! "$?" = 0 ]; then exit; fi
$0 `cat $TMPFILE`
rm -f $TMPFILE
;;
esac
root@cdrouter:/usr/bin# clear
root@cdrouter:/usr/bin# cat configsave
#!/bin/bash
#
# DB Diff - compare current state with the database and save only changed files
#
# License: GNU General Public License
# Author: Tomas Matejicek <http://www.slackware-live.org>
#
. /etc/dbdiff/config
function createdb()
{
echo -n "" >$TARINC
echo -n "" >$TARINC.X
tar -C / -cg $TARINC -f /dev/null $EXCLUDE $INCLUDE
}
function die()
{
if [ ! "$1" = "" ]; then echo "$1"; fi
exit
}
# select the device or filename
function mount_file()
{
if [ "$1" = "save" ]; then WORD="to"; else WORD="from"; fi
if [ "$2" = "" ]; then
dialog --title "DBDIFF: $1 changes" --inputbox \
"Enter the filename or devicename you wish to\n\
$1 your settings $WORD:\n\nexample: \n\
/dev/fd0 ... to work with your floppy drive \n\
/dev/sda1 ... to work with your USB FLASH disk \n\
/mnt/hda1/file.tgz ... to work with a regular file\n\n" 0 0 "" 2>$TMPFILE
if [ ! "$?" = 0 ]; then exit; fi
MOUNTFILE=`cat "$TMPFILE"`
rm -f $TMPFILE
if [ "$MOUNTFILE" = "" ]; then
die "You have to enter a file name or device name."
fi
else
MOUNTFILE="$2"
fi
if [ ! `echo $MOUNTFILE | grep "^/dev/"` = "" ]; then # we need to mount device
mkdir -p $MOUNTPOINT
if [ "$?" != 0 ]; then
die "cannot create directory $MOUNTPOINT"
fi
mount $MOUNTFILE $MOUNTPOINT
if [ "$?" != 0 ]; then
die "error while mounting $MOUNTFILE to $MOUNTPOINT"
fi
CONFIGSAVE="$MOUNTPOINT/$CONFIGSAVE"
UMOUNT=1
else
UMOUNT=0
if [ -d "$MOUNTFILE" ]; then
CONFIGSAVE="$MOUNTFILE/$CONFIGSAVE"
else
CONFIGSAVE="$MOUNTFILE"
fi
fi
if [ "`basename \"$CONFIGSAVE\" .tgz`" = "`basename \"$CONFIGSAVE\"`" ]; then
CONFIGSAVE="$CONFIGSAVE.tgz"
fi
}
# umount mountpoint if it is mounted by mount_file()
function umount_file_if_mounted()
{
if [ "$UMOUNT" = 1 ]; then
umount $MOUNTPOINT
rm -Rf $MOUNTPOINT
fi
}
# ==========================================================
if [ ! "`echo \"$0\" | grep configsave`" = "" ]; then
dbdiff save $1
exit
fi
if [ ! "`echo \"$0\" | grep configrestore`" = "" ]; then
dbdiff restore $1
exit
fi
if [ "$1" != "makedb" -a ! -r "$TARINC" ]; then
die "The database is not created. Use: $0 makedb"
exit
fi
case "$1" in
'save')
#
# quick fix jaime
#
mkdir /mnt/jaime
mount /dev/fd0 /mnt/jaime
rm -f /mnt/jaime/confsave.tgz
umount /dev/fd0
rmdir /mnt/jaime
mount_file "$1" "$2" # save file.tgz
cp $TARINC $TARINC.X
tar -C / -czg $TARINC.X -f $CONFIGSAVE $EXCLUDE $INCLUDE
rm $TARINC.X
umount_file_if_mounted
die
;;
'restore')
mount_file "$1" "$2"
if [ -r "$CONFIGSAVE" ];
then
tar -C / -xzf $CONFIGSAVE
umount_file_if_mounted
die "restore config done."
else
umount_file_if_mounted
die "cannot read $CONFIGSAVE"
fi
;;
'makedb')
createdb
die "done creating database."
;;
'--help')
echo "dbdiff v0.99 database-based differences finder"
echo "usage: $0 (call without arguments for interactive menus)"
echo " $0 save filename|devicename"
echo " $0 restore filename|devicename"
echo " $0 makedb"
;;
*)
dialog --title "DBDIFF: save or restore changes" --menu \
"Use this dialog box to select your action.\n\
All the settings and all new or modified files from\n\
/root, /etc and /usr/local will be saved or restored.\n\n" 10 58 0 \
"save" "Save all changes against database" \
"restore" "Restore all changes against database" 2>$TMPFILE
if [ ! "$?" = 0 ]; then exit; fi
$0 `cat $TMPFILE`
rm -f $TMPFILE
;;
esac
root@cdrouter:/usr/bin#