#!/bin/bash echo "SET_SERVICES:OPENMOSIX Version 07202k3-e" echo "This one has no command-line arguments. Sorry, folks!" # This reads in a master services settings file and then compares it # with the services settings on the current system. # It creates a 'diff' file of the differences. # Then it offers reset the services on the current settings to match" # the master services settings file using the diff file. function COMPARE { # This finds the differences between the original services setting and a # master 'desired' services settings file. It then generates a 'diff' # file containing a listing of the services to be turned off to match the # master file. diff original_services openmosix_services | grep "<" | awk ' { print $2" "$5" "$6" "$7" "$8 }' > diff_services } function CHANGE { # This function reads through the diff file and offers to turn off the # services listed therein for run-levels 2 through 5. # Note: Most distros use levels 3 and 5, but Debian uses 2, and some others # use run-level 4 (I think Gentoo does.) # Find each line containg a service name one at a time. for i in `cat diff_services | awk ' { print $1 } '`; do echo "Do you wish to TURN_OFF $i?" #Give the service's present setting." echo "$i is now set as follows:" chkconfig --list $i read DUMMY case $DUMMY in Y|y|Yes|YES|yes) # If yes, turn off the service in runlevels 2 through 5. for j in 2 3 4 5; do cat diff_services | grep $i | grep "{$j}:on" if [ $? -ne 0 ]; then chkconfig --level $j $i off fi done ;; *) # If the user didn't say yes, don't do anything for # this service. Go on to the next one. echo "No change was made for service $i." ;; esac # Show the service (reset or not.) echo "$i is now set as follows:" chkconfig --list $i # That's all, folks! done } #ACTUAL PROGRAMME CODE. # This program only runs from /root/bin, not /usr/bin like the rest of the # Kludge Kollection. # Change to /root/bin. cd /root/bin # If the openmosix_services master file is missing, report it, tell how # to get the file, and then exit with an errorlevel of 1. if ! [ -f openmosix_services ]; then echo "Hey!" echo "You need the openmosix_services master file first." echo "Please go make one by doing " echo " " echo "chkconfig --list >openmosix_services" echo " " echo "on an openmosix host with properly configured services" echo "and then copy the file to /root/bin/openmosix_services" echo "on this host. Then re-run this program." exit 1 fi # Generate the file containing original service settings for this host. # This file will be compared with the 'master' file containing the desired # settings, namely 'openmosix_services'. chkconfig --list >original_services # Generate the diff file. COMPARE # Show me the diff file. echo "Diff file created and stored in diff_services." cat diff_services # Last chance to make sure we want to proceed. echo "Proceed?" read DUMMY case "$DUMMY" in y|Y) # Make the changes with the CHANGE function (above). CHANGE ;; *) # Don't change ANY services. Abort the whole thing. echo "No services were changed." ;; esac # All done. Wasn't that fun? exit 0