Yeah, my bash scripting is horrid I know : )
Anyway, I wrote this and makes my life a lot easier.
I don't have to mirror an ftp and I don't have to manually check every
package(wanna-be dist upgrade). Hopefully this will make some cookers life
easier : P
And yes, some parts are really kludgy, sue me : p
#!/bin/bash
# Don't want the user to abort during a package install, could corrupt something
trap "" sigint
# Change the color back to white
rset() {
echo -e "\033[01;000m"
}
# purple used when upgrading/installing
getcol() {
echo -ne "\033[01;035m"
}
# green for normal messages and displaying packages
txtcol() {
echo -ne "\033[01;032m"
}
# cyan for the mup prompt
ps1col() {
echo -ne "\033[01;036m"
}
# use urpmi to get a package
get() {
getcol
/usr/bin/urpmi ${mup}
}
# remove whatever hdlists from /var/lib/urpmi(total kludge)
remove() {
/usr/sbin/urpmi.removemedia sun
}
# same as above we just add it back(more kludge), a.k.a. update the DB
add() {
/usr/sbin/urpmi.addmedia sun
ftp://sunsite.uio.no/pub/unix/Linux/Mandrake-devel/cooker/Mandrake/RPMS with
../base/hdlist.cz2
}
# Go through every package to see if needs there as an update
# all the elif are packages to ignore, mainly because i like to keep up to date
# with the helix folks, and some other packages(and once again total kludge).
upgrade() {
for i in `rpm --queryformat="%{NAME} " -qa`; do
if [[ $i == sawfish* ]]; then
false
elif [[ $i == xmms* ]]; then
false
elif [[ $i == gnome* ]]; then
false
elif [[ $i == glibc* ]]; then
echo
txtcol
echo $i
getcol
urpmi $i
elif [[ $i == glib* ]]; then
false
elif [[ $i == XFree86* ]]; then
false
elif [[ $i == pygtk-libglade* ]]; then
false
elif [[ $i == *rep* ]]; then
false
elif [[ $i == kernel* ]]; then
false
elif [[ $i == imlib* ]]; then
false
elif [[ $i == esound* ]]; then
false
elif [[ $i == libglade* ]]; then
false
elif [[ $i == gaim* ]]; then
alse
elif [[ $i == pygnome* ]]; then
false
elif [[ $i == gdk-pixbuf* ]]; then
false
elif [[ $i == bug* ]]; then
false
elif [[ $i == control-center* ]]; then
false
elif [[ $i == helix* ]]; then
false
elif [[ $i == Slay* ]]; then
false
elif [[ $i == evil7* ]]; then
false
elif [[ $i == pan* ]]; then
false
elif [[ $i == blackbox* ]]; then
false
elif [[ $i == openss* ]]; then
false
elif [[ $i == gtk+* ]]; then
false
elif [[ $i == Gconf* ]]; then
false
elif [[ $i == pygtk* ]]; then
false
elif [[ $i == abi* ]]; then
false
elif [[ $i == camserv* ]]; then
false
elif [[ $i == gmc* ]]; then
false
elif [[ $i == mc ]]; then
false
elif [[ $i == libxml* ]]; then
false
elif [[ $i == X11R6* ]]; then
false
elif [[ $i == libgtop* ]]; then
false
elif [[ $i == evolution* ]]; then
false
elif [[ $i == gtop* ]]; then
false
elif [[ $i == xscreensaver* ]]; then
false
elif [[ $i == gtk-engines* ]]; then
false
else
echo
txtcol
echo $i
getcol
urpmi $i
fi
done
}
# A pretty . loop, use it on abort.
ploop() {
slp="/bin/usleep 99999"
if [[ ! -x /bin/usleep ]]; then
slp="/bin/sleep 1"
fi
for loop in 0 1 2 3 4 5 6 7 8; do
${slp}
printf "."
done
printf "\n"
}
# make sure all our urpmi tools are there.
checkurp() {
if [[ ! -x /usr/bin/urpmi ]]; then
printf "/usr/bin/urpmi not found!\n"
printf "Aborting."
ploop
exit 0
elif [[ ! -x /usr/sbin/urpmi.addmedia ]]; then
printf "/usr/sbin/urpmi not found!\n"
printf "Aborting."
ploop
exit 0
elif [[ ! -x /usr/sbin/urpmi.removemedia ]]; then
printf "/usr/sbin/urpmi.removemedia not found!\n"
printf "Aborting."
ploop
exit 0
fi
}
# I feel that something like this should only be run as root, others may feel
# different, but by all means remove the command on startup(see at the bottom
# if you feel so : P
rootchk() {
if [[ ${UID} != 0 ]]; then
printf "You must be root to run mup.\n"
rset
exit 0
fi
}
# Get a yes or no answer(straight up stolen from msec( yoann : p)
WaitAnswer()
{
answer="nothing"
while [[ ${answer} != yes && ${answer} != no ]];
do
printf "yes/no : "
read answer
done
}
askup()
{
txtcol
printf "\n"
printf "Update the DB ?\n"
WaitAnswer
if [[ ${answer} == yes ]]; then
getcol
remove
add
printf "\n"
else
printf "\n"
fi
}
start() {
clear
mup
}
mup() {
ps1col
printf "(mup): "
read mup
ifmup
}
shell() {
printf "\n"
txtcol
printf "You are now in the Bourne Again Shell, type 'exit' at any time to get to
get\n"
printf "back to mup.\n"
rset
/bin/bash
}
run() {
txtcol
printf "Command: "
read cmd
/bin/bash -c "${cmd}"
}
help() {
txtcol
printf "update - update the local database"
printf "run - run a command outside of mup\n"
printf "shell - drop to a shell outside of mup\n"
printf "clear - clear the terminal screen\n"
printf "quit - quit mup\n"
printf "help - get this message\n"
}
cls() {
/usr/bin/clear
}
ifmup()
{
if [[ ${mup} == quit ]]; then
rset
exit 0
elif [[ -z ${mup} ]]; then
mup
elif [[ ${mup} == shell ]]; then
shell
mup
elif [[ ${mup} == run ]]; then
run
mup
elif [[ ${mup} == help ]]; then
help
mup
elif [[ ${mup} == update ]]; then
askup
mup
elif [[ ${mup} == clear ]]; then
cls
mup
elif [[ ${mup} == upgrade ]]; then
upgrade
mup
else
get ${mup}
printf "\n"
mup
fi
}
printf "\n"
rootchk
checkurp
start
#EOF
--
Bryan Paxton
I don't need to sleep or eat, I'll smoke a thousand cigarettes. - Sebadoh
Public key can be found at http://speedbros.org/Bryan_Paxton.asc