akaros/scripts/ak-scripts/ak-kill-9pserver.sh
<<
>>
Prefs
   1#!/usr/bin/env bash
   2#
   3# Copyright (c) 2015 Google Inc.
   4# See LICENSE for details.
   5
   6function short_description() {
   7        echo "Kill the Go 9pserver for Akaros with the specified port number"
   8}
   9
  10function usage() {
  11        echo "Usage:"
  12        echo "    ${cmd} -h | --help"
  13        echo "    ${cmd} [ --ufs-port=<port> ]"
  14        echo ""
  15        echo "Options:"
  16        echo "    -h --help               Display this screen and exit"
  17        echo "    --ufs-port=<port>       Port the ufs server is on"
  18        echo "                            [default: 1025]"
  19}
  20
  21function main() {
  22        # Check the sanity of our incoming variables
  23        check_vars ufs_port
  24
  25        # Kill any old instances of the ufs server on ${ufs_port}
  26        local ufs_pid=$(ps aux | grep "ufs" | grep "\-addr=:${ufs_port}" \
  27                               | head -1 | awk '{print $2}' )
  28        if [ "${ufs_pid}" != "" ]; then
  29                echo "Killing old 9p server instance on port=${ufs_port} (pid ${ufs_pid})"
  30                echo "${ufs_pid}" | xargs kill
  31        fi
  32}
  33