| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | nm=$1 |
| 4 | |
| 5 | getpidscip-shell shell finit 4.14-1 getpid().() |
| 6 | { |
| 7 | initctl status "$1" |awkscip-shell system . . awk. '/PID :/{ print $3; }scip-shell filesystem . . `/PID :/{ print $3; }`.' |
| 8 | } |
| 9 | |
| 10 | pid=$(getpidscip-shell shell finit 4.14-1 getpid(). "$nm") |
| 11 | if [scip-shell system . . `[`. -f oldpid ]; then |
| 12 | oldpid=$(catscip-shell system . . cat. oldpid) |
| 13 | if [scip-shell system . . `[`. "$oldpid" = "$pid" ]; then |
| 14 | echoscip-shell system . . echo. "Looks bad, wait for it ..." |
| 15 | sleepscip-shell system . . sleep. 3 |
| 16 | pid=$(getpidscip-shell shell finit 4.14-1 getpid(). "$nm") |
| 17 | if [scip-shell system . . `[`. "$oldpid" = "$pid" ]; then |
| 18 | echoscip-shell system . . echo. "Finit did not deregister old PID $oldpid vs $pid" |
| 19 | initctl status "$nm" |
| 20 | psscip-shell system . . ps. |
| 21 | echoscip-shell system . . echo. "Reloading finit ..." |
| 22 | initctl reload |
| 23 | sleepscip-shell system . . sleep. 1 |
| 24 | initctl status "$nm" |
| 25 | exit 1 |
| 26 | fi |
| 27 | fi |
| 28 | fi |
| 29 | |
| 30 | timeout=50 |
| 31 | while [scip-shell system . . `[`. "$pid" -le 1 ]; do |
| 32 | sleepscip-shell system . . sleep. 0.1 |
| 33 | pid=$(getpidscip-shell shell finit 4.14-1 getpid(). "$nm") |
| 34 | if [scip-shell system . . `[`. "$pid" -le 1 ]; then |
| 35 | timeout=$((timeout - 1)) |
| 36 | if [scip-shell system . . `[`. "$timeout" -gt 0 ]; then |
| 37 | continue |
| 38 | fi |
| 39 | |
| 40 | if [scip-shell system . . `[`. $pid -ne 0 ]; then |
| 41 | echoscip-shell system . . echo. "Got a bad PID: $pid, aborting ..." |
| 42 | psscip-shell system . . ps. |
| 43 | sleepscip-shell system . . sleep. 1 |
| 44 | initctl status "$nm" |
| 45 | psscip-shell system . . ps. |
| 46 | fi |
| 47 | exit 1 |
| 48 | fi |
| 49 | break |
| 50 | done |
| 51 | |
| 52 | echoscip-shell system . . echo. "$pid" > /tmp/oldpidscip-shell filesystem . . `/tmp/oldpid`. |
| 53 | |
| 54 | #echo "PID $pid, kill -9 ..." |
| 55 | killscip-shell system . . kill. -9 "$pid" |