Re: Upgrade script....
"Gary L. Greene Jr." <[email protected]> Fri, 4 Mar 2005 20:48:13 -0500
| Newsgroups | gmane.linux.arklinux.devel |
|---|---|
| Organization | Paradise Technology Group |
| Message-ID | <[email protected]> |
On Friday 04 March 2005 8:19 pm, you wrote: > On Saturday 05 March 2005 02:12, Gary L. Greene Jr. wrote: > > This can be modified since it's under GPL for whatever reason... > > Looks good... I've attached a patch to make it even easier to use by > autodetecting whether or not the system is SMP rather than asking the user. > > LLaP > bero Thanks! Here's the patched version and updated to allow for translations.... -- Gary L. Greene, Jr. Sent from uriel 20:45:16 up 4 days, 12:21, 7 users, load average: 0.03, 0.03, 0.06
a2b-update-tool.sh
(application/x-shellscript, 9.7 KB)
#!/bin/bash
##############################################################################
#
# Author Gary Greene
# Copyright 2004
# licensed GPL v2
#
##############################################################################
trap "" 1 2 3 9
AllDone() {
clear
echo -en '\033[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\033[0m'
echo $""
echo $""
echo $"The update has completed. Please wait while rebooting your PC."
echo $""
echo $""
echo $""
sleep 15s
reboot now
}
RestoreSysData() {
clear
echo -en '\033[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\033[0m'
echo $""
echo $""
echo $"Restoring system configuration."
cp /mnt/dest/XF86Config* /mnt/dest/etc/X11/
cp /mnt/dest/host* /mnt/dest/etc/
cp /mnt/dest/modules.* /mnt/dest/etc/
cp /mnt/dest/shadow /mnt/dest/etc/
cp /mnt/dest/gshadow /mnt/dest/etc/
cp /mnt/dest/passwd /mnt/dest/etc/
cp /mnt/dest/group /mnt/dest/etc/
cp -r /mnt/dest/samba /mnt/dest/etc/
cp -r /mnt/dest/sysconfig /mnt/dest/etc/
umount /mnt/dest
AllDone
}
InstallGrubby() {
clear
echo -en '\033[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\033[0m'
echo $""
echo $""
echo $"Cleaning up bootloader...."
/mnt/dest/grubby --remove-kernel=/mnt/dest/boot/vmlinuz-2.4* --grub
cd /mnt/dest/boot
rm -rf vmlinuz-2.4*
rm -rf System.map-2.4*
rm -rf autoconf.h-2.4*
rm -rf config-2.4*
rm -rf initrd-2.4*
rm -rf module-info-2.4*
rm -rf version.h-2.4*
RestoreSysData
}
InstallUpdate() {
clear
echo -en '\033[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\033[0m'
echo $""
echo $""
echo $"Installing Ark Linux Beta1..."
cd /RPMS
destination=/mnt/dest
rpm --initdb --root=$destination
rpmoptions="-ivh --nodeps --force --root=$destination"
for package in *
do
if [ $package == "kernel-2*.rpm" ]; then
cd `uname -p`
if [ $smpval == 'y' ]; then
rpm $rpmoptions kernel-smp*.rpm
else
rpm $rpmoptions kernel-2*.rpm
fi
cd -
elif [ $package == "glibc*" ];then
cd `uname -p`
rpm $rpmoptions glibc*.rpm
cd -
else
rpm $rpmoptions $package
fi
done
InstallGrubby
}
DeleteSystem() {
clear
echo -en '\033[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\033[0m'
echo $""
echo $""
echo $"Preparing previous install for updates. This may take several minutes..."
cd /mnt/dest/
echo -n $" Processing: "
rm -rf bin
echo -n "#####"
rm -rf dev
echo -n "######"
rm -rf lib
echo -n "######"
rm -rf opt
echo -n "#####"
rm -rf sbin
echo -n "#####"
rm -rf srv
echo -n "#####"
rm -rf tmp
echo -n "#####"
rm -rf usr
echo -n "#######"
rm -rf var
echo -n "######"
echo $""
echo $""
echo $"Creating backup of system configuration data..."
tar -cjf /mnt/dest/etc.tar.bz2 /mnt/dest/etc
cp etc/X11/XF86Config* /mnt/dest/
cp etc/host* /mnt/dest/
cp etc/modules.* /mnt/dest/
cp etc/shadow /mnt/dest/
cp etc/gshadow /mnt/dest/
cp etc/passwd /mnt/dest/
cp etc/group /mnt/dest/
cp -r etc/samba /mnt/dest/
cp -r etc/sysconfig /mnt/dest/
rm -rf etc
InstallUpdate
}
Continue2input() {
echo $"This is your final confirmation!"
echo $"Do you still want to continue? [y,n] "
read continueAnswer
if [ $continueAnswer == "y" ]; then
DeleteSystem
else
echo $"Incorrect input."
Continue2
fi
}
Continue2() {
clear
echo -en '\033[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\033[0m'
echo $""
echo $""
echo -e $"\033[5;1mFINAL WARNING! \033[25;0m"
echo $"Are you sure you wish to continue? If you do, your personal data"
echo $"will remain safe, however, as previous stated, all programs will"
echo $"be reset!"
}
SMPCheck() {
clear
echo -en '\033[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\033[0m'
echo $""
echo $""
if [ "`getconf _NPROCESSORS_ONLN`" -gt 1 ]; then
smpval=y
else
smpval=n
fi
export smpval
Continue2
}
Continue1input() {
echo $"Do you still want to continue? [y,n] "
read continueAnswer
if [ $continueAnswer == "y" ]; then
SMPCheck
else
echo $"Incorrect input."
Continue1
fi
}
Continue1() {
clear
echo -en '\033[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\033[0m'
echo $""
echo $""
echo -e $"\033[5;1mIMPORTANT! \033[25;0m"
echo $"Any 3rd party applications and software from the online apt repository will"
echo $"be removed!"
Continue1input
}
ConfirmUdateContinue() {
clear
echo -en '\E[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\E[0m'
echo $""
echo $""
echo $"Found your Ark Linux installation."
echo $""
echo $"To update your computer, this tool will remove all programs from"
echo $"your computer and then install the new versions from the install CD."
echo $"Your personal data, and system configuration will not be deleted."
echo $""
echo $"Should we continue the update? [y,n] "
Continue1
}
AutoDiscovery() {
line_count=$( wc -l < /proc/partitions )
destination="/mnt/dest"
for partline in `seq $line_count`
do
read nil1 nil2 nil3 partname
if mount -t ext3 /dev/$partname $destination 2>/dev/null; then
if [ -e $destination/etc/ark-release ]; then
true
else
umount $destination 2>/dev/null
fi
fi
done </proc/partitions
ConfirmUdateContinue
}
AutomaticPartSelection() {
clear
echo -en '\E[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\E[0m'
echo $""
echo $""
echo $"Please Wait while we discover which disk and partition holds your"
echo $"Ark Linux install...."
echo $""
echo $""
echo $"Please wait while finding your root partition...."
sleep 5s
AutoDiscovery
}
ManualPartSelection() {
clear
echo -en '\E[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\E[0m'
echo $""
echo $""
echo $"Please enter the partition in the format of hdxx, where xx is"
echo $"the disks letter (a through g) and partition number (1 through 10)"
echo -c $"(SCSI and SATA disk partitions use sdxx): "
read partition
echo $""
echo $""
destination="/mnt/dest"
mount -t ext3 /dev/$partition $destination
if [ $? -eq 0 ]; then
echo $"Partition Mounted OK."
ConfirmUdateContinue
else
echo $"ERROR!!! Partition mounted with errors! Cannot continue!"
exit 1
fi
}
CheckPartitionsInput() {
echo -n $"How should we detect your partition? [1,2] "
read response
if [ $response -eq 1 ]; then
ManualPartSelection
elif [ $response -eq 2 ]; then
AutomaticPartSelection
else
echo $"Incorrect input."
CheckPartitionsInput
fi
}
CheckPartitions() {
clear
echo -en '\E[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\E[0m'
echo $""
echo $""
echo $"The first thing we need to check is where Ark Linux is installed on"
echo $"your computer. If you know which partition it is installed on,"
echo $"please select the manual partition selection. If not, let the "
echo $"updater choose the partition for you automatically."
echo $""
echo $""
echo $" 1. Manual partition selection"
echo $" 2. Automatic partition selection ( RECOMMENDED )"
echo $""
CheckPartitionsInput
}
WelcomeInput() {
echo -n $"Do you wish to proceed? [y,n] "
read line
if [ $line == "y" ]; then
CheckPartitions;
elif [ $line == "n" ]; then
echo $"Thank you for choosing Ark Linux."
else
echo $"Incorrect input."
WelcomeInput
fi
}
Welcome() {
clear
echo -en '\E[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\E[0m'
echo $""
echo $""
echo $"This tool will update your Ark Linux 1.0.0-alpha12.2 system to"
echo $"1.0.0-beta1. Before running this update, we need to gather a little"
echo $"information to allow the update to run smoothly."
echo $""
WelcomeInput
}
Help() {
clear
echo -en '\E[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\E[0m'
echo $""
echo $"This tool is for use to upgrade a Ark Linux Alpha12 system to Beta1."
echo $"Following is the options that can be passed to the utility:"
echo $""
echo $"\t -h: Shows this help text and exits"
echo $"\t -v: Displays the version of this utility"
echo $""
exit 0;
}
Version() {
clear
echo -en '\E[4m''\E[31m'$"Ark "
echo -en '\E[34m'$"Linux"
echo -e '\E[39m'$" Alpha12 to Beta1 update tool"'\E[0m'
echo $""
echo $"Version 1.0-b1"
echo $'Author Gary Greene <[email protected]>'
exit 0;
}
case $1 in
-h)
Help
;;
-v)
Version
;;
*)
Welcome;
;;
esac
exit 0;
signature.asc
(application/pgp-signature, 190 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.12 (GNU/Linux) iD8DBQBCKQ/hpYIGqyXDl5wRAh4nAJ9v+PpcYT6f4AJU/vMRcBjnVxVSQACcDA5E 5Gb7I+3pXUoD8/uRNpc6xS4= =QRm8 -----END PGP SIGNATURE-----