clevis.in 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2017 Shawn Rose
  4. #
  5. # Author: Shawn Rose <shawnandrewrose@gmail.com>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. PREREQ=""
  21. prereqs() {
  22. echo "$PREREQ"
  23. }
  24. case "$1" in
  25. prereqs)
  26. prereqs
  27. exit 0
  28. ;;
  29. esac
  30. [ -s /run/clevis.pid ] || exit 0
  31. pid=$(cat /run/clevis.pid)
  32. ps -l | awk -v pid="$pid" '$4==pid { system("kill " $3) }'
  33. kill "$pid"
  34. # Not really worried about downing extra interfaces: they will come up
  35. # during the actual boot. Might make this configurable later if needed.
  36. for iface in /sys/class/net/*; do
  37. if [ -e "$iface" ]; then
  38. ip link set dev "$iface" down
  39. ip addr flush dev "$iface"
  40. ip route flush dev "$iface"
  41. fi
  42. done