Useful CLI tools (bash) for Arch Linux administration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
447 B

  1. #!/bin/env sh
  2. if [[ ${1} =~ ^(\-h|\-\-help)$ ]] || [[ -z ${1} ]]; then
  3. echo "
  4. Send a signal to a process in specified namespace.
  5. usage: $(basename $0) <signal> <processname> <namespace>
  6. "
  7. exit 0
  8. fi
  9. signal="${1}"
  10. processname="${2}"
  11. namespace="${3}"
  12. for pid in $(sudo ip netns pids ${namespace}); do
  13. if [[ $(sudo ps -q $pid -o command) =~ ^.*${processname}.* ]]; then
  14. sudo ip netns exec ${namespace} kill -${signal} ${pid}
  15. fi
  16. done