-
Notifications
You must be signed in to change notification settings - Fork 0
/
section7.sh
executable file
·37 lines (32 loc) · 1.09 KB
/
section7.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Exercise 1:
# Create a startup script for an application called sleep-walking-server, which is provided below.
# The script should be named sleepwalking and accept "start" and "stop" as arguments. If
# anything other than "start" or "stop" is provided as an argument, display a usage statement:
# "Usage sleep-walking-server start|stop" and terminate the script with an exit status of 1.
# To start sleepwalkingserver, use this command: "/tmp/sleep-walking-server &"
# To stop sleepwalkingserver, use this command: "kill $(cat /tmp/sleep-walking-server.pid)"
# Here is the contents of "sleep-walking-server". Be sure to put this file in /tmp and run chmod
# 755 /tmp/sleep-walking-server
# #!/bin/bash
# PID_FILE="/tmp/sleep-walking-server.pid"
# trap "rm $PID_FILE; exit" SIGHUP SIGINT SIGTERM
# echo "$$" > $PID_FILE
# while true
# do
# :
# done
function e1() {
case "$1" in
start)
/tmp/sleep-walking-server &
;;
stop)
kill $(cat /tmp/sleep-walking-server.pid)
;;
*)
echo "Usage sleep-walking-server start|stop"
;;
esac
}
e1 $@