Diminished2b Posted August 6, 2006 Share Posted August 6, 2006 Post your useful BASH scripts here (Original only). Umerge - For Gentoo Linux, unmerges multiple packages based on a keyword. I was disapointed that you couldn't use wildcards with emerge considering FreeBSD's Ports (Which are the role-model for portage) tools supported wildcards. #!/bin/bash keyword=$1 if [[ $1 = "" ]] then echo "Please input the keyword to be mass unmerged:" read keyword else : fi if [[ $keyword = "" ]]; then echo "You need to enter a keyword next time" exit fi ls -R /var/db/pkg/ | grep $keyword | sed 's/\/var\/db\/pkg\///g' | sed 's/://g' | sed 's/-r[0-9]$//g' | sed 's/\.//g' | sed 's/-[0-9]*$//g' | grep \/ | xargs emerge -pC echo "These are the packages that I will unmerge. Are you sure you want to go through with this? [y/n]:" read var if [ $var = "y" ]; then ls -R /var/db/pkg/ | grep $keyword | sed 's/\/var\/db\/pkg\///g' | sed 's/://g' | sed 's/-r[0-9]$//g' | sed 's/\.//g' | sed 's/-[0-9]*$//g' | grep \/ | xargs emerge -C else echo "Sorry to hear that, maybe you should revise your keyword" exit fi Kernel updater [incomplete] - Requires Lynx (Feel free to revise) - Updates your kernel to the latest with git-sources patches. Incomplete, needs work. (Feel free to revise). It was distro-dependant but I never got to redoing it for compatibility with any distro. You can probably just wget the latest Linux version, wget the latest scripts, untar, patch, cp, oldconfig, compile, cp, sed some lines in bootloader configuration file. #!/bin/bash installed=`uname -r` installed_ver=`echo $installed | cut -d- -f1 | awk -F "." '{ print $3 }'` installed_rc=`echo $installed | awk -F "-" '{ print $2 }' | cut -c3-` installed_git=`echo $installed | awk -F "git" '{ print $2 }'` current=`lynx -dump http://www.kernel.org/kdist/finger_banner | grep git | awk '{ print $11 }'` current_ver=`echo $current | cut -d- -f1 | awk -F "." '{ print $3 }'` current_rc=`echo $current | awk -F "-" '{ print $2 }' | cut -c3-` current_git=`echo $current | awk -F "git" '{ print $2 }'` if [ "$installed_ver" -lt "$current_ver" ]; then upgrade="1" elif [ "$installed_ver" -eq "$current_ver" ] && [ "$installed_rc" -lt "$current_rc" ]; then upgrade="1" elif [ "$installed_ver" -eq "$current_ver" ] && [ "$installed_rc" -eq "$current_rc" ] \ && [ "$installed_git" -lt "$current_git" ]; then upgrade="1" fi if [ -n "$upgrade" ] then echo -e "Your kernel version is out of date\n" #To be done fi #debug echo "Upgrade: $upgrade" echo "Installed: $installed" echo "Installed ver: $installed_ver" echo "Installed rc: $installed_rc" echo -e "Installed git: $installed_git\n" echo "Current: $current" echo "Current ver: $current_ver" echo "Current rc: $current_rc" echo "Current git: $current_git" Yeah, I know, not much. I'm working on a few more but I'm already heavily into something else. Link to comment Share on other sites More sharing options...
tunaboy692004 Posted August 6, 2006 Share Posted August 6, 2006 I havent really focused on BASH scripts, but if i get a chance i will post some i do use :) Current Goals80/80 Fletching60/75 Woodcutting97/100 Combat Link to comment Share on other sites More sharing options...
Diminished2b Posted August 6, 2006 Author Share Posted August 6, 2006 I've recently been messing with a Linux Distrobution written completely in BASH (The utilities, that is) called Sourcemage. It's cool, and it reminded me that BASH is good for higher-level things aswell. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now