Open main menu

CDOT Wiki β

SYA710 Lab02

Revision as of 18:28, 16 September 2008 by Selmys (talk | contribs) (New page: == SYA710 Lab #2 (Incomplete - do not start) == === Focus: Linux Startup === === PART A (System V on Fedora 8): === Perform the following steps: <ol> <li>Login to Fedora 8 Test as root.<...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SYA710 Lab #2 (Incomplete - do not start)

Focus: Linux Startup

PART A (System V on Fedora 8):

Perform the following steps:

  1. Login to Fedora 8 Test as root.
  2. Type in this script. The name of this script should be called carpal.
  3. #!/bin/sh
    #
    # carpal
    #
    # description: carpald is a program which wakes up every so often and 
    #              tells us that we need to take a break from the keyboard 
    #              or we'll lose all functinality of our wrists and never be 
    #              able to type again as long as we live.
    # chkconfig: 3 92 08
    
    [ -f /usr/local/sbin/carpald ] || exit 0
    
    # source function library
    . /etc/rc.d/init.d/functions
    
    case "$1" in 
      start) 
             echo -n "Starting carpald: "
             daemon /usr/local/sbin/carpald &
             echo
             touch /var/lock/subsys/carpald
             ;;
      stop)  
             echo -n "Stopping carpald services: "
             killproc /usr/local/sbin/carpald
             echo
             rm -f /var/lock/subsys/carpald
             ;;
      status) 
             status /usr/local/sbin/carpald
             ;;
      restart|reload)
             $0 stop
             $0 start
             ;;
      *)
             echo "Usage: carpal {start|stop|status|restart|reload}"
             exit 1
    	 ;;
    esac
    exit 0
    
  4. Save the script in /etc/init.d/ directory.
  5. Now create another script named carpald - this script will be the daemon. Your carpald script can look something like this - but feel free to elaborate.
    #!/bin/sh
    #loop forever
    while :
    do        
        # now sleep for 30 seconds       
        sleep 30       
        # after wakeup send message to all users       
        wall <<EOF               
    Ok people! Time to take a break before               
    you get carpal tunnel syndrome!
    EOF
    done
    
  6. Save your carpald script in directory /usr/local/sbin. Make sure the owner and permissions are set correctly.
  7. Now run the command
    	
    chkconfig --add carpal
    
  8. Now switch to runlevel 3 with the command
    	
    telinit 3
    
  9. Login as joker and observe what happens.
  10. Answer questions 1-14 in PART C and then do PART B.

PART B: (Upstart on Ubuntu 8.04)

Perform the following steps:

  1. Login to UbuntuHH Test as root.
  2. Answer the remaining questions in PART C and email your answers to your teacher.

PART C: - Questions

  1. What is your full name and Seneca student ID?
  2. What is the purpose of the wall command?
  3. Identify the full path and names of ALL startup/shutdown links created in step 6.
  4. What is the purpose of the chkconfig command?
  5. What is the purpose of the /etc/init.d/functions script?
  6. What is the difference between the init and telinit commands?
  7. What runlevels does Fedora 8 use and what is the purpose of each?
  8. What is the purpose of the daemon and killproc functions?
  9. What common arguments do startup scripts take?
  10. How is a daemon different from a regular user process?
  11. Where (what directory other than /proc) are process numbers normally saved for currently running daemons.
  12. What is the purpose of the dot (.) command and where is it used in this lab?
  13. What is a lock file used for?
  14. What is the full path name of the lock file used in this lab?