#!/bin/sh # Use the Bourne shell to run this script # This is a port build script it executes make, make install, rehash, # and make clean. You must be in the directory of the port you want # to build in. # This sets the functions of pwd (ponit which directory I am in) and whoami (identify current user ). pwd=`pwd` user=`whoami` # Identify if the user as root if [ "$user" = "root" ]; then # If the user is root output to screen echo "You are authorized to install ports. Please Stand By." # Check the current working directory to see if you are in /usr/ports/. The ports all have pkg-descr. This command looks for that. if [ -f $pwd/pkg-descr ]; then # If you are in /usr/ports in a proper directory with a pkg-descr, this will output to the screen. echo "Okay smart boy you seem to be in the right place." # This begins the loop for YES, NO or other responses from the user until [ "$response" = "YES" ] || [ "$response" = "NO" ] # The loop continues here with do as in do this or that. do # Output to screen echo "Would you like the port installed[YES/NO]?" # Read the what the user types read response # The YES variable, if the user types YES do this if [ "$response" = "YES" ]; then # and output this to the screen echo "Here we go!" # Since the answer was YES begin to install the port by making sure the script goes to the same directory the user is in. (It is a bit redundant but safe) cd $pwd # Continue with the make, make install, rehash, and make clean for the port. make && make install && rehash && make clean # Else if the response is NO, begin this procedure. elif [ "$response" = "NO" ]; then # If the response is NO output this to the screen echo "Why did you bother me then? Go away!" # If the response is neither YES or NO, it belongs to the 'other' category. So something else must be done. else # If the respoonse isn't YES or NO but something 'other', output this to the screen. echo "How about learning to type YES or NO dummy!" # Closing tag for the if that begins with the YES,NO ,or 'other' . fi # Closes the loop that begins with the 'until'. For YES, NO, or 'other'. done # If you are not in the ports directory, something else must be done else # Output this to the screen if you are not in the ports directory. echo "Hey dummy! How about making sure you are in the ports directory and quit wasting my time." # Closing tag for the if that checks if you are in the ports tree fi # If you are not root, something else must be done. else # Output to screen if you are not root. echo "You are not authorized to install ports. Please leave me alone." # Closing tag for the if that checks if you are root. fi