OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # This script will kill some important system daemons and make sure | 3 # This script will kill some important system daemons and make sure |
4 # that they have been automatically restarted. | 4 # that they have been automatically restarted. |
5 | 5 |
6 OLD_PID=0 | 6 OLD_PID=0 |
7 PID=0 | 7 PID=0 |
8 | 8 |
9 # Time to wait for upstart to restart a daemon in seconds | 9 # Time to wait for upstart to restart a daemon in seconds |
10 RESTART_TIMEOUT=5 | 10 RESTART_TIMEOUT=5 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 echo "Upstart and daemon pids don't match: $upstart_pid vs $pgrep_pid" | 42 echo "Upstart and daemon pids don't match: $upstart_pid vs $pgrep_pid" |
43 return 1 | 43 return 1 |
44 fi | 44 fi |
45 | 45 |
46 # Everything checks out. | 46 # Everything checks out. |
47 PID=$upstart_pid | 47 PID=$upstart_pid |
48 } | 48 } |
49 | 49 |
50 # The set of jobs (and corresponding daemon names) to test. | 50 # The set of jobs (and corresponding daemon names) to test. |
51 # TODO: Test more jobs that have the respawn stanza | 51 # TODO: Test more jobs that have the respawn stanza |
52 UPSTART_JOBS_TO_TEST="ntp:ntpd udev:udevd" | 52 UPSTART_JOBS_TO_TEST="htpdate:htpdate udev:udevd" |
53 | 53 |
54 for job in $UPSTART_JOBS_TO_TEST ; do | 54 for job in $UPSTART_JOBS_TO_TEST ; do |
55 | 55 |
56 JOB=$(echo "$job" | awk -F':' '{ print $1 }') | 56 JOB=$(echo "$job" | awk -F':' '{ print $1 }') |
57 DAEMON=$(echo "$job" | awk -F':' '{ print $2 }') | 57 DAEMON=$(echo "$job" | awk -F':' '{ print $2 }') |
58 | 58 |
59 get_job_pid "$JOB" "$DAEMON" | 59 get_job_pid "$JOB" "$DAEMON" |
60 if [ $PID -le 0 ] ; then | 60 if [ $PID -le 0 ] ; then |
61 echo "Error: It looks like job '$JOB' is not running." | 61 echo "Error: It looks like job '$JOB' is not running." |
62 exit 255 | 62 exit 255 |
(...skipping 16 matching lines...) Expand all Loading... |
79 exit 255 | 79 exit 255 |
80 fi | 80 fi |
81 if [ $PID -eq $OLD_PID ] ; then | 81 if [ $PID -eq $OLD_PID ] ; then |
82 echo "Error: Job '$JOB' retained the same pid; something went wrong." | 82 echo "Error: Job '$JOB' retained the same pid; something went wrong." |
83 exit 255 | 83 exit 255 |
84 fi | 84 fi |
85 | 85 |
86 done | 86 done |
87 | 87 |
88 exit 0 | 88 exit 0 |
OLD | NEW |