SYA710 Lab02
Contents
SYA710 Lab #2 (Incomplete - do not start)
Focus: Linux Startup
PART A (System V on Fedora 8):
Perform the following steps:
- Login to Fedora 8 Test as root.
- Type in this script. The name of this script should be called carpal.
- Save the script in /etc/init.d/ directory.
- 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
- Save your carpald script in directory /usr/local/sbin. Make sure the owner and permissions are set correctly.
- Now run the command:
- Now switch to runlevel 3 with the command:
- Login as joker and observe what happens.
- Answer questions 1-14 in PART C and then do PART B.
#!/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
chkconfig --add carpal
telinit 3
PART B: (Upstart on Ubuntu 8.04)
Perform the following steps:
- Login to UbuntuHH Test as root.
- Now create a 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
- Save your carpald script in directory /usr/local/sbin. Make sure the owner and permissions are set correctly.
- Now create a job file named carpal (use vi) and place it in /etc/event.d/ directory. Ensure the permissions are set correctly.
- Now check carpal's status with this command:
- Start the carpal service with this command:
- Again check the status of the carpal service:
- Open several terminals and wait 30 seconds and observe what happens.
- Once you're sure the carpal service is running properly, you can stop it with this command:
- Answer the remaining questions in PART C and email your answers to your teacher.
- Write a short blog about Linux startup.
# carpal - carpald # # This service manages carpald to notify users of typing breaks # started until it is shut down again. start on stopped rc2 start on stopped rc3 start on stopped rc4 start on stopped rc5 stop on runlevel 0 stop on runlevel 1 stop on runlevel 6 respawn exec /usr/local/sbin/carpald
status carpal
start carpal
status carpal
stop carpal
PART C: - Questions
- What is your full name and Seneca student ID?
- What is the purpose of the wall command?
- Identify the full path and names of ALL startup/shutdown links created in step 6.
- What is the purpose of the chkconfig command?
- What is the purpose of the /etc/init.d/functions script?
- What is the difference between the init and telinit commands?
- What runlevels does Fedora 8 use and what is the purpose of each?
- What is the purpose of the daemon and killproc functions?
- What common arguments do startup scripts take?
- How is a daemon different from a regular user process?
- Where (what directory other than /proc) are process numbers normally saved for currently running daemons.
- What is the purpose of the dot (.) command and where is it used in this lab?
- What is a lock file used for?
- What is the full path name of the lock file used in this lab?