g4u/slurpdisk:
#!/bin/sh
#
# fetch disk image via ftp & write to disk
#
# (c) Copyright 2003 Hubert Feyrer
#
user_server=$1
image=$2
disk=$3
user=`echo $user_server | sed 's/@.*$//'`
server=`echo $user_server | sed 's/^[^@]*@//'`
if [ "$user" = "$server" -o "$user" = "" ]; then
# no user@ given - use default
user=install
fi
if [ "$disk" = "" ]; then
disk=wd0 # Change this to "sd0" for a SCSI disk
fi
if [ "$image" = "" ]; then
image=r${disk}d.gz
fi
if [ "$server" = "" ]; then
echo "Usage: $0 server-ip [image] [disk]"
echo "e.g.: $0 ftp.my.com"
echo " $0 user@my-ftp.serv.er"
echo ""
echo "Defaults: image=$image, disk=$disk, user=$user"
exit 1
fi
#echo HF: user=$user
#echo HF: server=$server
#echo HF: image=$image
#echo HF: disk=$disk
#exit 666
ftp -o "| progress -z dd obs=1m of=/dev/r${disk}d" ftp://${user}@${server}/${image}
|
g4l/restore_disk:
#!/bin/sh
#
#
#
#
# Usage: ./restore_disk
#
#
#
#
#
#
#show license
echo "g4l, Copyright (C) 2004 nme"
echo "g4l comes with ABSOLUTELY NO WARRANTY; for details"
echo "see 'license/gpl.txt'. This is free software, and"
echo "you are welcome to redistribute it under certain"
echo "conditions; see 'license/redist.txt' for details."
echo
echo
sleep 5
version="g4l (gh*st for linux) v0.1, (c) nme 27.2.2004"
imgpath=img
user_pass_server=$1
image=$2
disk=$3
gzip=$4
user=`echo $user_pass_server | sed 's/:.*$//'`
password=`echo $user_pass_server | sed 's/.*://' | sed 's/@.*//'`
server=`echo $user_pass_server | sed 's/.*.@//'`
if [ "$user" = "$user_pass_server" -o "$user" = "$server" ] ; then
#no user given or error, set default user "g4l" with default password "g4l"
user=g4l
password=g4lg4l
fi
if [ "$disk" = "" ] ; then
#no disk given, set default disk to backup "hda"
disk=hda
fi
if [ "$image" = "" ] ; then
#no imagename given, set default imagename with default gzip ending
image=$disk.img.gz
fi
if [ "$gzip" != "OFF" ] ; then
#gzip switch not set to OFF, set to ON
gzip=ON
fi
if [ "$server" = "" ] ; then
echo $version
echo "Usage: $0 [user:password@]ftp_ip [img_file] [dest_disk] [gzip(ON/OFF)]"
echo "example: $0 bigboss:secretPW@192.168.0.10 hda.img.gz hda"
echo " $0 192.168.0.10 hda.img.gz"
echo ""
echo "default: user=$user, password=$password, image=$image, disk=$disk, gzip=$gzip"
exit 1
fi
echo $version
echo "input seems to be OK"
echo "g4l staring..."
for i in 5 4 3 2 1 ; do
echo $i ; sleep 1
done
echo "working...Press ^C to cancel backup at any time."
if [ "$gzip" = "ON" ] ; then
#restore image from ftp and dump to disk with GZIP support on !
echo "GZIP is $gzip !"
time ftp -o "|gunzip -c -|dd bs=1M of=/dev/$disk" ftp://$user:$password@$server/$imgpath/$image
echo
echo "Restore done..."
fi
if [ "$gzip" = "OFF" ] ; then
#restore image from ftp and dump to disk with GZIP support off !
echo "GZIP is $gzip !"
time ftp -o "|dd bs=1M of=/dev/$disk" ftp://$user:$password@$server/$imgpath/$image
echo
echo "Restore done..."
fi
|
g4u/slurppart:
#!/bin/sh
#
# fetch partition image via ftp & write to disk
#
# (c) Copyright 2003 Hubert Feyrer
#
user_server=$1
image=$2
diskpart=$3
user=`echo $user_server | sed 's/@.*$//'`
server=`echo $user_server | sed 's/^[^@]*@//'`
if [ "$user" = "$server" -o "$user" = "" ]; then
# no user@ given - use default
user=install
fi
if [ "$diskpart" = "" ]; then
diskpart=wd0d # Change this to "sd0" for a SCSI disk
fi
if [ "$image" = "" ]; then
image=r${diskpart}.gz
fi
if [ "$server" = "" ]; then
echo "Usage: $0 server-ip [image] [disk+partition]"
echo "e.g.: $0 ftp.my.com wd0g-image.gz wd0g"
echo " $0 user@my-ftp.serv.er" wd0e.gz wd0e
echo ""
echo "Defaults: image=$image, disk+partition=${diskpart}, user=$user"
exit 1
fi
disk=`echo $diskpart | sed s,.$,,`
#echo HF: user=$user
#echo HF: server=$server
#echo HF: image=$image
#echo HF: diskpart=$diskpart
#echo HF: disk=$disk
#exit 666
disklabel -W $disk
ftp -o "| progress -z dd obs=1m of=/dev/r${diskpart}" ftp://${user}@${server}/${image}
|
g4l/restore_part:
#!/bin/sh
#
#
#
#
# Usage: ./restore_part
#
#
#
#
#
#
#show license
echo "g4l, Copyright (C) 2004 nme"
echo "g4l comes with ABSOLUTELY NO WARRANTY; for details"
echo "see 'license/gpl.txt'. This is free software, and"
echo "you are welcome to redistribute it under certain"
echo "conditions; see 'license/redist.txt' for details."
echo
echo
sleep 5
version="g4l (gh*st for linux) v0.1, (c) nme 27.02.2004"
imgpath=img
user_pass_server=$1
image=$2
diskpart=$3
gzip=$4
user=`echo $user_pass_server | sed 's/:.*$//'`
password=`echo $user_pass_server | sed 's/.*://' | sed 's/@.*//'`
server=`echo $user_pass_server | sed 's/.*.@//'`
if [ "$user" = "$user_pass_server" -o "$user" = "$server" ] ; then
#no user given or error, set default user "g4l" with default password "g4l"
user=g4l
password=g4lg4l
fi
if [ "$diskpart" = "" ] ; then
#no disk given, set default disk to backup "hda"
diskpart=hda1
fi
if [ "$image" = "" ] ; then
#no imagename given, set default imagename with default gzip ending
image=$diskpart.img.gz
fi
if [ "$gzip" != "OFF" ] ; then
#gzip switch not set to OFF, set to ON
gzip=ON
fi
if [ "$server" = "" ] ; then
echo "Usage: $0 [user:password@]ftp_ip [img_file] [dst_partition] [gzip(ON/OFF)]"
echo "example: $0 bigboss:secretPW@192.168.0.10 hda.img.gz hda"
echo " $0 192.168.0.10 hda.img.gz"
echo ""
echo "default: $0 user=$user, password=$password, image=$image, partition=$diskpart, gzip=$gzip"
exit 1
fi
echo $version
echo "input seems to be OK"
echo "g4l starting..."
for i in 5 4 3 2 1 ; do
echo $i ; sleep 1
done
echo "working...Press ^C to cancel backup at any time."
if [ "$gzip" = "ON" ] ; then
#restore image from ftp and dump to disk with GZIP support on !
echo "GZIP is $gzip !"
time ftp -o "|gunzip -c -|dd bs=1M of=/dev/$diskpart" ftp://$user:$password@$server/$imgpath/$image
echo
echo "Restore done..."
fi
if [ "$gzip" = "OFF" ] ; then
#restore image from ftp and dump to disk with GZIP support off !
echo "GZIP is $gzip !"
time ftp -o "|dd bs=1M of=/dev/$diskpart" ftp://$user:$password@$server/$imgpath/$image
echo
echo "Restore done..."
fi
|
g4u/uploaddisk:
#!/bin/sh
#
# write disk-image to file on FTP server
#
# (c) Copyright 2003 Hubert Feyrer
#
tmpfile=/tmp/ftpput.$$
user_server=$1
file=$2
disk=$3
user=`echo $user_server | sed 's/@.*$//'`
server=`echo $user_server | sed 's/^[^@]*@//'`
if [ "$user" = "$server" -o "$user" = "" ]; then
# no user@ given - use default
user=install
fi
if [ "$disk" = "" ]; then
disk=wd0 # Change this to "sd0" for a SCSI disk
fi
if [ "$file" = "" ]; then
file=r${disk}d.gz
fi
if [ "$server" = "" ]; then
echo "Usage: $0 [user@]FTPserverIP [file] [disk]"
echo "e.g. $0 ftp.my.com my-r${disk}d.gz sd0"
echo " GZIP=1 $0 ... (for minimum compression)"
echo " $0 user@ftp.my.com image.gz"
echo ""
echo "Default: file=$file disk=$disk, user=$user, GZIP=9"
exit 1
fi
gzip_opt=-${GZIP}
if [ "$gzip_opt" = "-" ]; then
gzip_opt=-9
fi
unset GZIP # gzip(1) processes the variable differently
#echo HF: file=$file
#echo HF: disk=$disk
#echo HF: user=$user
#echo HF: server=$server
#exit 666
echo -n "Enter password for $user@$server: "
read pass
if [ "$pass" = "" ]; then
echo "Empty password not allowed, aborting."
exit 1
fi
# Clear screen to wipe password
echo "[H[2J"
echo "[1mWelcome to g4u, starting upload of ${disk} now...[0m"
echo ""
rm -f $tmpfile
echo >>$tmpfile open $server
echo >>$tmpfile user $user $pass
echo >>$tmpfile bin
echo >>$tmpfile put - $file
echo >>$tmpfile bye
#echo 'dd if=/dev/r'${disk}'d bs=1m | progress ftpput $tmpfile '${gzip_opt}
#echo tmpfile:
#cat $tmpfile
#
#for i in 5 4 3 2 1 ; do
# echo $i ; sleep 1
#done
dd if=/dev/r${disk}d bs=1m \
| progress sh ftpput $tmpfile ${gzip_opt}
rm -f $tmpfile
|
g4l/backup_disk:
#!/bin/sh
#
#
#
#
# Usage: ./backup_disk
#
#
#
#
#
#
#show license
echo "g4l, Copyright (C) 2004 nme"
echo "g4l comes with ABSOLUTELY NO WARRANTY; for details"
echo "see 'license/gpl.txt'. This is free software, and"
echo "you are welcome to redistribute it under certain"
echo "conditions; see 'license/redist.txt' for details."
echo
echo
sleep 5
version="g4l (gh*st for linux) v0.1, (c) nme 27.02.2004"
ftpfile=/.netrc
user_pass_server=$1
file=$2
disk=$3
gzip=$4
user=`echo $user_pass_server | sed 's/:.*$//'`
password=`echo $user_pass_server | sed 's/.*://' | sed 's/@.*//'`
server=`echo $user_pass_server | sed 's/.*.@//'`
if [ "$user" = "$user_pass_server" -o "$user" = "$server" ] ; then
#no user given or error, set default user "g4l" with default password "g4l"
user=g4l
password=g4lg4l
fi
if [ "$disk" = "" ] ; then
#no disk given, set default disk to backup "hda"
disk=hda
fi
if [ "$file" = "" ] ; then
#no filename given, set default filename with default gzip ending
file=$disk.img.gz
fi
if [ "$gzip" != "OFF" ] ; then
#gzip switch not set to OFF, set to ON
gzip=ON
fi
if [ "$server" = "" ] ; then
echo $version
echo "Usage: $0 [user:password@]ftp_ip [dst_file] [src_disk] [gzip(ON/OFF)]"
echo "example: $0 bigboss:secretPW@192.168.0.10 my-image-file.gz hda ON"
echo " $0 192.168.0.10 my-image-file.gz"
echo ""
echo "default: user=$user, password=$password, file=$file, disk=$disk, gzip=$gzip"
exit 1
fi
rm -f $ftpfile
echo >>$ftpfile default login $user password $password
echo >>$ftpfile macdef init
echo >>$ftpfile cd img
echo >>$ftpfile put - $file
echo >>$ftpfile quit
echo >>$ftpfile
chmod 700 /$ftpfile
echo $version
echo "Input seems to be OK"
echo "g4l starting..."
for i in 5 4 3 2 1 ; do
echo $i ; sleep 1
done
echo "working...Press ^C to cancel backup at any time."
if [ "$gzip" = "ON" ] ; then
#create image on ftp with GZIP support on !
echo "GZIP is $gzip !"
time dd if=/dev/$disk bs=1M | gzip -c - | ftp $server
echo
echo "Backup done..."
fi
if [ "$gzip" = "OFF" ] ; then
#create image on ftp without gzip
echo "GZIP is $gzip !"
time dd if=/dev/$disk bs=1M | ftp $server
echo
echo "Backup done..."
fi
rm -f $ftpfile
|
g4u/uploadpart:
#!/bin/sh
#
# write partition-image to file on FTP server
#
# (c) Copyright 2003 Hubert Feyrer
#
tmpfile=/tmp/ftpput.$$
user_server=$1
file=$2
diskpart=$3
user=`echo $user_server | sed 's/@.*$//'`
server=`echo $user_server | sed 's/^[^@]*@//'`
if [ "$user" = "$server" -o "$user" = "" ]; then
# no user@ given - use default
user=install
fi
if [ "$diskpart" = "" ]; then
diskpart=rwd0d # Change this to "rsd0d" for a SCSI disk
fi
if [ "$file" = "" ]; then
file=${diskpart}.gz
fi
if [ "$server" = "" ]; then
echo "Usage: $0 [user@]FTPserverIP [file] [disk+partition]"
echo "e.g. $0 ftp.my.com my-r${disk}d.gz sd0f"
echo " GZIP=1 $0 ... (for minimum compression)"
echo " $0 user@ftp.my.com image.gz"
echo ""
echo "Default: disk+partition=${diskpart}, user=$user, GZIP=9"
exit 1
fi
gzip_opt=-${GZIP}
if [ "$gzip_opt" = "-" ]; then
gzip_opt=-9
fi
unset GZIP # gzip(1) processes the variable differently
#echo HF: file=$file
#echo HF: diskpart=$diskpart
#echo HF: user=$user
#echo HF: server=$server
#echo HF: gzip_opt=$gzip_opt
#exit 666
echo -n "Enter password for $user@$server: "
read pass
if [ "$pass" = "" ]; then
echo "Empty password not allowed, aborting."
exit 1
fi
# Clear screen to wipe password
echo "[H[2J"
echo "[1mWelcome to g4u, starting upload of ${diskpart} now...[0m"
echo ""
rm -f $tmpfile
echo >>$tmpfile open $server
echo >>$tmpfile user $user $pass
echo >>$tmpfile bin
echo >>$tmpfile put - $file
echo >>$tmpfile bye
#echo '( cat $tmpfile ; dd progress=1 if=/dev/r'${diskpart}' bs=1m | gzip '${gzip_opt}' ) | ftp -n'
#echo tmpfile:
#cat $tmpfile
#
#for i in 5 4 3 2 1 ; do
# echo $i ; sleep 1
#done
dd if=/dev/r${diskpart} bs=1m \
| progress sh ftpput $tmpfile ${gzip_opt}
rm -f $tmpfile
|
g4l/backup_part:
#!/bin/sh
#
#
#
#
# Usage: ./backup_part
#
#
#
#
#
#
#show license
echo "g4l, Copyright (C) 2004 nme"
echo "g4l comes with ABSOLUTELY NO WARRANTY; for details"
echo "see 'license/gpl.txt'. This is free software, and"
echo "you are welcome to redistribute it under certain"
echo "conditions; see 'license/redist.txt' for details."
echo
echo
sleep 5
version="g4l (gh*st for linux) v0.1, (c) nme 27.02.2004"
ftpfile=/.netrc
user_pass_server=$1
file=$2
diskpart=$3
gzip=$4
user=`echo $user_pass_server | sed 's/:.*$//'`
password=`echo $user_pass_server | sed 's/.*://' | sed 's/@.*//'`
server=`echo $user_pass_server | sed 's/.*.@//'`
if [ "$user" = "$user_pass_server" -o "$user" = "$server" ] ; then
#no user given or error, set default user "g4l" with default password "g4l"
user=g4l
password=g4lg4l
fi
if [ "$diskpart" = "" ] ; then
#no disk given, set default disk to backup partition "hda1"
diskpart=hda1
fi
if [ "$file" = "" ] ; then
#no filename given, set default filename with default gzip ending
file=$diskpart.img.gz
fi
if [ "$gzip" != "OFF" ] ; then
#gzip switch not set to OFF, set to ON
gzip=ON
fi
if [ "$server" = "" ] ; then
echo $version
echo "Usage: $0 [user:password@]ftp_servers_ip [dst_file] [src_part.] [gzip(ON/OFF)]"
echo "example: $0 bigboss:secretPW@192.168.0.10 my-image-file.gz hda1 ON"
echo " $0 192.168.0.10 my-image-file.gz"
echo ""
echo "default: user=$user, password=$password, file=$file, partition=$diskpart, gzip=$gzip"
exit 1
fi
rm -f $ftpfile
echo >>$ftpfile default login $user password $password
echo >>$ftpfile macdef init
echo >>$ftpfile cd img
echo >>$ftpfile put - $file
echo >>$ftpfile quit
echo >>$ftpfile
chmod 700 /$ftpfile
echo $version
echo "Input seems to be OK"
echo "g4l starting..."
for i in 5 4 3 2 1 ; do
echo $i ; sleep 1
done
echo "working...Press ^C to cancel backup at any time."
if [ "$gzip" = "ON" ] ; then
#create image on ftp with GZIP support on !
echo "GZIP is $gzip !"
time dd if=/dev/$diskpart bs=1M | gzip -c - | ftp $server
echo
echo "Backup done..."
fi
if [ "$gzip" = "OFF" ] ; then
#create image on ftp without gzip
echo "GZIP is $gzip !"
time dd if=/dev/$diskpart bs=1M | ftp $server
echo
echo "Backup done..."
fi
rm -f $ftpfile
|
|
g4l/g4l:
#!/bin/sh
#
#
#
#
#
#
#
: ${DIALOG=dialog}
: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_ESC=255}
tempfilemain=`tempfile 2>/dev/null` || tempfilemain=/tmp/testmain&&
trap "rm -f $tempfilemain" 0 1 2 5 15
tempfilenet=`tempfilenet 2>/dev/null` || tempfilenet=/tmp/testnet$$
trap "rm -f $tempfilenet" 0 1 2 5 15
tempfileftp=`tempfileftp 2>/dev/null` || tempfileftp=/tmp/testftp$$
trap "rm -f $tempfileftp" 0 1 2 5 15
tempfileback=`tempfileback 2>/dev/null` || tempfileback=/tmp/testback$$
trap "rm -f $tempfileback" 0 1 2 5 15
tempfilebackpart=`tempfilebackpart 2>/dev/null` || tempfilebackpart=/tmp/testbackpart$$
trap "rm -f $tempfilebackpart" 0 1 2 5 15
tempfilename=`tempfilename 2>/dev/null` || tempfilename=/tmp/testname$$
trap "rm -f $tempfilename" 0 1 2 5 15
tempfilegzip=`tempfilegzip 2>/dev/null` || tempfilegzip=/tmp/testgzip$$
trap "rm -f $tempfilegzip" 0 1 2 5 15
tempfilerest=`tempfilerest 2>/dev/null` || tempfilerest=/tmp/testrest$$
trap "rm -f $tempfilerest" 0 1 2 5 15
tempfilerestoart=`tempfilerestpart 2>/dev/null` || tempfilerestpart=/tmp/testrestpart$$
trap "rm -f $tempfilerestpart" 0 1 2 5 15
ftpfile=.netrc
imagepath=img
backtitle="g4l v0.12, (c) nme 2004"
$DIALOG --backtitle "$backtitle" \
--title "INFORMATION" --clear \
--yesno "g4l - Gh*st for Linux \n \
Copyright (C) 2004 nme \n\n \
g4l comes with ABSOLUTELY NO WARRANTY; for details \n \
see 'licencse/gpl.txt'. This is free Software, and \n \
your are welcome to redistribute it under certain \n \
conditions; see 'licencse/redist.txt' for details. \n\n \
USE AT OWN RISK!\n \
Accept these conditions? YES to proceed, NO to quit. " 15 61
case $? in
0)
#Yes chosen
#go to main screen
while [ "$retvalmain" != "1" ]
do
$DIALOG --clear --backtitle "$backtitle" \
--title "MAIN MENU" \
--menu "Chose one of the following options: \n\n" 20 65 10 \
"Set Network" "Configure device eth0" \
"Set FTP data" "Configure FTP IP and Username/Pass" \
"Set filename" "Set target/source filename for image" \
"Toggle Compression" "Set GZip Comression ON/OFF" \
"Backup Disk" "Create a drive Image on the FTP" \
"Restore Disk" "Write image from FTP to disk" \
"Backup Partition" "Create a partition image on FTP" \
"Restore Partition" "Write image from FTP to partition" \
"Show GPL" "Displays the GNU Public License" \
"Show Redist" "Displays the redistributional conditions" 2> $tempfilemain
retvalmain=$?
choicemain=`cat $tempfilemain`
case $retvalmain in
0)
#echo "'$choicemain' chosen."
case $choicemain in
"Set Network")
$DIALOG --backtitle "$backtitle" \
--title "Set Network" --clear \
--inputbox "Set IP Address to match your subnet. \
\nExample: 192.168.0.5 \
\n\nEnter IP Address:" 16 51 2> $tempfilenet
retvalnet=$?
case $retvalnet in
0)
ipaddress=`cat $tempfilenet`
/sbin/ifconfig eth0 $ipaddress up
;;
1)
#echo "Cancel pressed."
;;
255)
if test -s $tempfilenet ; then
ipaddress=`cat $tempfilenet`
/sbin/ifconfig eth0 $ipaddress up
fi
;;
esac
;;
"Set FTP data")
$DIALOG --backtitle "$backtitle" \
--title "Set FTP data" --clear \
--inputbox "Enter Username, Password and IP Address of FTP Server. \
\nUse format user:password@ftp_ip \
\nExample: john:secret@192.168.0.1 \
\n\nFTP Data:" 16 51 2> $tempfileftp
retvalftp=$?
case $retvalftp in
0)
ftpdata=`cat $tempfileftp`
user=`echo $ftpdata | sed 's/:.*$//'`
password=`echo $ftpdata | sed 's/.*://' | sed 's/@.*//'`
server=`echo $ftpdata | sed 's/.*.@//'`
;;
1)
#echo "Cancel pressed."
;;
255)
if test -s $tempfileftp ; then
ftpdata=`cat $tempfileftp`
user=`echo $ftpdata | sed 's/:.*$//'`
password=`echo $ftpdata | sed 's/.*://' | sed 's/@.*//'`
server=`echo $ftpdata | sed 's/.*.@//'`
fi
;;
esac
;;
"Set filename")
$DIALOG --backtitle "$backtitle" \
--title "Set filename" --clear \
--inputbox "Enter filename of the image which is stored on the FTP server. \
\nExample: hda_workstation2.img \
\n\nFilename:" 16 51 2> $tempfilename
retvalname=$?
case $retvalnet in
0)
imagename=`cat $tempfilename`
;;
1)
#echo "Cancel pressed."
;;
255)
if test -s $tempfilename ; then
imagename=`cat $tempfilename`
fi
;;
esac
;;
"Toggle Compression")
$DIALOG --backtitle "$backtitle" \
--title "Toggle Compression" \
--radiolist "Choose wether to use GZip Compression or not. \
\nBe careful, GZip requires much CPU power!" 20 61 5 \
"ON" "GZip compression ON." ON \
"OFF" "GZip compression OFF." off 2> $tempfilegzip
retvalgzip=$?
choicegzip=`cat $tempfilegzip`
case $retvalgzip in
$DIALOG_OK)
gzip=`cat $tempfilegzip`
;;
$DIALOG_CANCEL)
#echo "Cancel pressed."
;;
$DIALOG_ESC)
if test -s $tempfilegzip ; then
gzip=`cat $tempfilegzip`
fi
;;
esac
;;
"Backup Disk")
if [ "$ipaddress" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "ERROR" --clear \
--msgbox "No Networtk IP Address for eth0 set! \n
->Back to Main Menu." 10 41
continue
fi
if [ "$user" = "$ftpdata" -o "$user" = "$server" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "No FTP User/Password set, using default \n
User: g4l \n
Password: g4lg4l" 10 41
#no user/pw given, set to default
user=g4l
password=g4lg4l
fi
if [ "$server" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "ERROR" --clear \
--msgbox "No FTP IP Address set! \n
->Back to Main Menu." 10 41
continue
fi
if [ "$imagename" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "No filename for image set, using default \n
Filename: image.img.gz" 10 41
imagename=image.img.gz
fi
if [ "$gzip" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "Compression not defined, using default \n
GZip compression: ON" 10 41
gzip=ON
fi
#cat /proc/partitions | awk '{print $3, $4}'
$DIALOG --backtitle "$backtitle" \
--title "Backup Drive" \
--radiolist "Choose Drive to backup\n\
Select from:" 20 61 5 \
"/dev/hda" "First IDE Drive." ON \
"/dev/hdb" "Second IDE Drive." off \
"/dev/hdc" "Third IDE Drive." off \
"/dev/hdd" "Fourth IDE Drive." off \
"/dev/sda" "First SCSI/sATA Drive." off \
"/dev/sdb" "Second SCSI/sATA Drive." off \
"/dev/sdc" "Third SCSI/sATA Drive." off \
"/dev/sdd" "Fourth SCSI/sATA Drive." off 2> $tempfileback
retvalback=$?
choiceback=`cat $tempfileback`
case $retvalback in
$DIALOG_OK)
#BACKUPDISK CODE HERE
disk=$choiceback
rm -f $ftpfile
echo >>$ftpfile default login $user password $password
echo >>$ftpfile macdef init
echo >>$ftpfile cd $imagepath
echo >>$ftpfile put - $imagename
echo >>$ftpfile quit
echo >>$ftpfile
chmod 700 $ftpfile
$DIALOG --backtitle "$backtitle" \
--title "About to backup disk" --clear \
--yesno "Collected information: \
\nLocal IP Address: $ipaddress \
\nFTP IP Address: $server \
\nUsername: $user \
\nPassword: $password \
\nTarget imagename: $imagename \
\nSource Drive: $disk \
\n\nAre you sure?" 15 61
case $? in
0)
#YES
if [ "$gzip" = "ON" ] ; then
#create image with gzip ON
time dd if=$disk bs=1M | gzip -c - | ftp $server >>/dev/tty2 2>>/dev/tty2 &
$DIALOG --backtitle "$backtitle" \
--title "Working..." --clear \
--msgbox "See transfer log on tty2 by pressing ALT+F2" 10 41
fi
if [ "$gzip" = "OFF" ] ; then
#create image with gzip OFF
time dd if=$disk bs=1M | ftp $server >>/dev/tty2 2>>/dev/tty2 &
$DIALOG --backtitle "$backtitle" \
--title "Working..." --clear \
--msgbox "See transfer log on tty2 by pressing ALT+F2" 10 41
fi
rm -f $ftpfile
;;
1)
#NO
;;
255)
#ESC
;;
esac
;;
$DIALOG_CANCEL)
#echo "Cancel pressed."
;;
$DIALOG_ESC)
#echo "ESC pressed."
;;
esac
;;
"Restore Disk")
if [ "$ipaddress" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "ERROR" --clear \
--msgbox "No Networtk IP Address for eth0 set! \n
->Back to Main Menu." 10 41
continue
fi
if [ "$user" = "$ftpdata" -o "$user" = "$server" ] ; then
#no user/pw given, set to default
user=g4l
password=g4lg4l
fi
if [ "$server" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "ERROR" --clear \
--msgbox "No FTP IP Address set! \n
->Back to Main Menu." 10 41
continue
fi
if [ "$imagename" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "No filename for image set, using default \n
Filename: image.img.gz" 10 41
imagename=image.img.gz
fi
if [ "$gzip" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "Compression not defined, using default \n
GZip compression: ON" 10 41
gzip=ON
fi
$DIALOG --backtitle "$backtitle" \
--title "Restore Drive" \
--radiolist "Choose drive to restore the image to \
\n\nSelect from:" 20 61 5 \
"/dev/hda" "First IDE Drive." ON \
"/dev/hdb" "Second IDE Drive." off \
"/dev/hdc" "Third IDE Drive." off \
"/dev/hdd" "Fourth IDE Drive." off \
"/dev/sda" "First SCSI/sATA Drive." off \
"/dev/sdb" "Second SCSI/sATA Drive." off \
"/dev/sdc" "Third SCSI/sATA Drive." off \
"/dev/sdd" "Fourth SCSI/sATA Drive." off 2> $tempfilerest
retvalrest=$?
choicerest=`cat $tempfilerest`
case $retvalrest in
$DIALOG_OK)
#RESTOREDISK CODE HERE
rest=$choicerest
$DIALOG --backtitle "$backtitle" \
--title "About to restore disk" --clear \
--yesno "Collected information: \
\nLocal IP Address: $ipaddress \
\nFTP IP Address: $server \
\nUsername: $user \
\nPassword: $password \
\nSource imagename: $imagename \
\nTarget disk: $rest \n\n \
\n\nAre you sure?" 15 61
case $? in
0)
#YES
if [ "$gzip" = "ON" ] ; then
#restore image with gzip ON
time ftp -o "|gunzip -c -|dd bs=1M of=$rest" ftp://$user:$password@$server/$imagepath/$imagename >>/dev/tty2 2>>/dev/tty2 &
$DIALOG --backtitle "$backtitle" \
--title "Working..." --clear \
--msgbox "See transfer log on tty2 by pressing ALT+F2" 10 41
fi
if [ "$gzip" = "OFF" ] ; then
#restore image with gzip OFF
time ftp -o "|dd bs=1M of=$rest" ftp://$user:$password@$server/$imagepath/$imagename >>/dev/tty2 2>>dev/tty2 &
$DIALOG --backtitle "$backtitle" \
--title "Working..." --clear \
--msgbox "See transfer log on tty2 by pressing ALT+F2" 10 41
fi
;;
1)
#NO
;;
255)
#ESC
;;
esac
;;
$DIALOG_CANCEL)
#echo "Cancel pressed."
;;
$DIALOG_ESC)
#echo "ESC pressed."
;;
esac
;;
"Backup Partition")
if [ "$ipaddress" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "ERROR" --clear \
--msgbox "No Networtk IP Address for eth0 set! \n
->Back to Main Menu." 10 41
continue
fi
if [ "$user" = "$ftpdata" -o "$user" = "$server" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "No FTP User/Password set, using default \n
User: g4l \n
Password: g4lg4l" 10 41
#no user/pw given, set to default
user=g4l
password=g4lg4l
fi
if [ "$server" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "ERROR" --clear \
--msgbox "No FTP IP Address set! \n
->Back to Main Menu." 10 41
continue
fi
if [ "$imagename" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "No filename for image set, using default \n
Filename: image.img.gz" 10 41
imagename=image.img.gz
fi
if [ "$gzip" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "Compression not defined, using default \n
GZip compression: ON" 10 41
gzip=ON
fi
#cat /proc/partitions | awk '{print $3, $4}'
$DIALOG --backtitle "$backtitle" \
--title "Backup Partition" \
--radiolist "Choose Partition to backup \
\n\nSelect from:" 20 61 10 \
"/dev/hda1" "First IDE Drive, first partition." ON \
"/dev/hda2" "First IDE Drive, second partition." off \
"/dev/hda3" "First IDE Drive, third partition." off \
"/dev/hda4" "First IDE Drive, fourth partition." off \
"/dev/hdb1" "Second IDE Drive, first partition." off \
"/dev/hdb2" "Second IDE Drive, second partition." off \
"/dev/hdb3" "Second IDE Drive, thirdt partition." off \
"/dev/hdb4" "Second IDE Drive, fourth partition." off \
"/dev/hdc1" "Third IDE Drive, first partition." off \
"/dev/hdc2" "Third IDE Drive, second partition." off \
"/dev/hdc3" "Third IDE Drive, third partition." off \
"/dev/hdc4" "Third IDE Drive, fourth partition." off \
"/dev/hdd1" "Fourth IDE Drive, first partition." off \
"/dev/hdd2" "Fourth IDE Drive, second partition." off \
"/dev/hdd3" "Fourth IDE Drive, third partition." off \
"/dev/hdd4" "Fourth IDE Drive, fourth partition." off \
"/dev/sda1" "First SCSI/sATA Drive, first partition." off \
"/dev/sda2" "First SCSI/sATA Drive, second partition." off \
"/dev/sda3" "First SCSI/sATA Drive, third partition." off \
"/dev/sda4" "First SCSI/sATA Drive, fourth partition." off \
"/dev/sdb1" "Second SCSI/sATA Drive, first partition." off \
"/dev/sdb2" "Second SCSI/sATA Drive, second partition." off \
"/dev/sdb3" "Second SCSI/sATA Drive, third partition." off \
"/dev/sdb4" "Second SCSI/sATA Drive, fourth partition." off \
"/dev/sdc1" "Third SCSI/sATA Drive, first partition." off \
"/dev/sdc2" "Third SCSI/sATA Drive, second partition." off \
"/dev/sdc3" "Third SCSI/sATA Drive, third partition." off \
"/dev/sdc4" "Third SCSI/sATA Drive, fourth partition." off \
"/dev/sdd1" "Fourth SCSI/sATA Drive, first partition." off \
"/dev/sdd2" "Fourth SCSI/sATA Drive, second partition." off \
"/dev/sdd3" "Fourth SCSI/sATA Drive, third partition." off \
"/dev/sdd4" "Fourth SCSI/sATA Drive, fourth partition." off 2> $tempfilebackpart
retvalbackpart=$?
choicebackpart=`cat $tempfilebackpart`
case $retvalbackpart in
$DIALOG_OK)
#BACKUPPART CODE HERE
part=$choicebackpart
rm -f $ftpfile
echo >>$ftpfile default login $user password $password
echo >>$ftpfile macdef init
echo >>$ftpfile cd $imagepath
echo >>$ftpfile put - $imagename
echo >>$ftpfile quit
echo >>$ftpfile
chmod 700 $ftpfile
$DIALOG --backtitle "$backtitle" \
--title "About to backup partition" --clear \
--yesno "Collected information: \
\nLocal IP Address: $ipaddress \
\nFTP IP Address: $server \
\nUsername: $user \
\nPassword: $password \
\nTarget imagename: $imagename \
\nSource partition: $part \
\n\nAre you sure?" 15 61
case $? in
0)
#YES
if [ "$gzip" = "ON" ] ; then
#create image with gzip ON
time dd if=$part bs=1M | gzip -c - | ftp $server >>/dev/tty2 2>>/dev/tty2 &
$DIALOG --backtitle "$backtitle" \
--title "Working..." --clear \
--msgbox "See transfer log on tty2 by pressing ALT+F2" 10 41
fi
if [ "$gzip" = "OFF" ] ; then
#create image with gzip OFF
time dd if=$part bs=1M | ftp $server >>/dev/tty2 2>>/dev/tty2 &
$DIALOG --backtitle "$backtitle" \
--title "Working..." --clear \
--msgbox "See transfer log on tty2 by pressing ALT+F2" 10 41
fi
rm -f $ftpfile
;;
1)
#NO
;;
255)
#ESC
;;
esac
;;
$DIALOG_CANCEL)
#echo "Cancel pressed."
;;
$DIALOG_ESC)
#echo "ESC pressed."
;;
esac
;;
"Restore Partition")
if [ "$ipaddress" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "ERROR" --clear \
--msgbox "No Networtk IP Address for eth0 set! \n
->Back to Main Menu." 10 41
continue
fi
if [ "$user" = "$ftpdata" -o "$user" = "$server" ] ; then
#no user/pw given, set to default
user=g4l
password=g4lg4l
fi
if [ "$server" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "ERROR" --clear \
--msgbox "No FTP IP Address set! \n
->Back to Main Menu." 10 41
continue
fi
if [ "$imagename" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "No filename for image set, using default \n
Filename: image.img.gz" 10 41
imagename=image.img.gz
fi
if [ "$gzip" = "" ] ; then
$DIALOG --backtitle "$backtitle" \
--title "WARNING" --clear \
--msgbox "Compression not defined, using default \n
GZip compression: ON" 10 41
gzip=ON
fi
$DIALOG --backtitle "$backtitle" \
--title "Restore Partition" \
--radiolist "Choose Partition to write the image to \
\n\nSelect from:" 20 61 10 \
"/dev/hda1" "First IDE Drive, first partition." ON \
"/dev/hda2" "First IDE Drive, second partition." off \
"/dev/hda3" "First IDE Drive, third partition." off \
"/dev/hda4" "First IDE Drive, fourth partition." off \
"/dev/hdb1" "Second IDE Drive, first partition." off \
"/dev/hdb2" "Second IDE Drive, second partition." off \
"/dev/hdb3" "Second IDE Drive, third partition." off \
"/dev/hdb4" "Second IDE Drive, fourth partition." off \
"/dev/hdc1" "Third IDE Drive, first partition." off \
"/dev/hdc2" "Third IDE Drive, second partition." off \
"/dev/hdc3" "Third IDE Drive, third partition." off \
"/dev/hdc4" "Third IDE Drive, fourth partition." off \
"/dev/hdd1" "Fourth IDE Drive, first partition." off \
"/dev/hdd2" "Fourth IDE Drive, second partition." off \
"/dev/hdd3" "Fourth IDE Drive, third partition." off \
"/dev/hdd4" "Fourth IDE Drive, fourth partition." off \
"/dev/sda1" "First SCSI/sATA Drive, first partition." off \
"/dev/sda2" "First SCSI/sATA Drive, second partition." off \
"/dev/sda3" "First SCSI/sATA Drive, third partition." off \
"/dev/sda4" "First SCSI/sATA Drive, fourth partition." off \
"/dev/sdb1" "Second SCSI/sATA Drive, first partition." off \
"/dev/sdb2" "Second SCSI/sATA Drive, second partition." off \
"/dev/sdb3" "Second SCSI/sATA Drive, third partition." off \
"/dev/sdb4" "Second SCSI/sATA Drive, fourth partition." off \
"/dev/sdc1" "Third SCSI/sATA Drive, first partition." off \
"/dev/sdc2" "Third SCSI/sATA Drive, second partition." off \
"/dev/sdc3" "Third SCSI/sATA Drive, third partition." off \
"/dev/sdc4" "Third SCSI/sATA Drive, fourth partition." off \
"/dev/sdd1" "Fourth SCSI/sATA Drive, first partition." off \
"/dev/sdd2" "Fourth SCSI/sATA Drive, second partition." off \
"/dev/sdd3" "Fourth SCSI/sATA Drive, third partition." off \
"/dev/sdd4" "Fourth SCSI/sATA Drive, fourth partition." off 2> $tempfilerestpart
retvalrestpart=$?
choicerestpart=`cat $tempfilerestpart`
case $retvalrestpart in
$DIALOG_OK)
#RESTOREPART CODE HERE
restpart=$choicerestpart
$DIALOG --backtitle "$backtitle" \
--title "About to restore partition" --clear \
--yesno "Collected information: \
\nLocal IP Address: $ipaddress \
\nFTP IP Address: $server \
\nUsername: $user \
\nPassword: $password \
\nSource imagename: $imagename \
\nTarget partition: $restpart \
\n\nAre you sure?" 15 61
case $? in
0)
#YES
if [ "$gzip" = "ON" ] ; then
#restore partimage with gzip ON
time ftp -o "|gunzip -c -|dd bs=1M of=$restpart" ftp://$user:$password@$server/$imagepath/$imagename >>/dev/tty2 2>>/dev/tty2 &
$DIALOG --backtitle "$backtitle" \
--title "Working..." --clear \
--msgbox "See transfer log on tty2 by pressing ALT+F2" 10 41
fi
if [ "$gzip" = "OFF" ] ; then
#restore partimage with gzip OFF
time ftp -o "|dd bs=1M of=$restpart" ftp://$user:$password@$server/$imagepath/$imagename >>/dev/tty2 2>>dev/tty2 &
$DIALOG --backtitle "$backtitle" \
--title "Working..." --clear \
--msgbox "See transfer log on tty2 by pressing ALT+F2" 10 41
fi
;;
1)
#NO
;;
255)
#ESC
;;
esac
;;
$DIALOG_CANCEL)
#echo "Cancel pressed."
;;
$DIALOG_ESC)
#echo "ESC pressed."
;;
esac
;;
"Show GPL")
expand license/gpl.txt > /tmp/gpl.expand
$DIALOG --backtitle "$backtitle" \
--clear --title "GNU PUBLIC LICENSE" \
--textbox "/tmp/gpl.expand" 22 77
case $? in
0)
;;
255)
;;
esac
;;
"Show Redist")
expand license/redist.txt > /tmp/redist.expand
$DIALOG --backtitle "$backtitle" \
--clear --title "Redistributional conditions" \
--textbox "/tmp/redist.expand" 22 77
case $? in
0)
;;
255)
;;
esac
;;
esac
;;
1)
echo "Thanks for using g4l. visit http://g4linux.tripod.com"
rm /tmp/*
;;
255)
echo "ESC pressed."
;;
esac
done
;;
1)
#No chosen
exit 0
;;
255)
#ESC hit
exit 0
;;
esac
|