qubes-updates-proxy-forwarder 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/bash
  2. #
  3. # Updates proxy forwarder Startup script for the updates proxy forwarder
  4. #
  5. # chkconfig: 345 85 15
  6. # description: forwards connection to updates proxy over Qubes RPC
  7. #
  8. # processname: ncat
  9. # pidfile: /var/run/qubes-updates-proxy-forwarder.pid
  10. #
  11. # Source function library.
  12. # shellcheck disable=SC1091
  13. . /etc/rc.d/init.d/functions
  14. # Source Qubes library.
  15. # shellcheck source=init/functions
  16. . /usr/lib/qubes/init/functions
  17. # Source networking configuration.
  18. # shellcheck disable=SC1091
  19. . /etc/sysconfig/network
  20. # Check that networking is up.
  21. [ "$NETWORKING" = "no" ] && exit 0
  22. exec="/usr/bin/ncat"
  23. prog=$(basename $exec)
  24. pidfile="/var/run/qubes-updates-proxy-forwarder.pid"
  25. # shellcheck disable=SC1091
  26. [ -e /etc/sysconfig/qubes-updates-proxy-forwarder ] && . /etc/sysconfig/qubes-updates-proxy-forwarder
  27. lockfile=/var/lock/subsys/qubes-updates-proxy-forwarder
  28. start() {
  29. have_qubesdb || return
  30. if ! qsvc updates-proxy-setup ; then
  31. # updates proxy configuration disabled
  32. exit 0
  33. fi
  34. if qsvc qubes-updates-proxy ; then
  35. # updates proxy running here too, avoid looping traffic back to itself
  36. exit 0
  37. fi
  38. [ -x $exec ] || exit 5
  39. echo -n $"Starting $prog (as Qubes updates proxy forwarder): "
  40. # shellcheck disable=SC2016
  41. start-stop-daemon \
  42. --exec $exec \
  43. --pidfile "$pidfile" \
  44. --make-pidfile \
  45. --background \
  46. --start \
  47. -- \
  48. -k -l -e 'qrexec-client-vm $default qubes.UpdatesProxy'
  49. retval=$?
  50. echo
  51. [ $retval -eq 0 ] && touch $lockfile
  52. return $retval
  53. }
  54. stop() {
  55. echo -n $"Stopping $prog: "
  56. killproc -p $pidfile "$prog"
  57. retval=$?
  58. echo
  59. [ $retval -eq 0 ] && rm -f $lockfile
  60. return $retval
  61. }
  62. restart() {
  63. stop
  64. start
  65. }
  66. force_reload() {
  67. restart
  68. }
  69. rh_status() {
  70. status "$prog"
  71. }
  72. rh_status_q() {
  73. rh_status >/dev/null 2>&1
  74. }
  75. case "$1" in
  76. start)
  77. rh_status_q && exit 0
  78. $1
  79. ;;
  80. stop)
  81. rh_status_q || exit 0
  82. $1
  83. ;;
  84. restart)
  85. $1
  86. ;;
  87. force-reload)
  88. force_reload
  89. ;;
  90. status)
  91. rh_status
  92. ;;
  93. condrestart|try-restart)
  94. rh_status_q || exit 0
  95. restart
  96. ;;
  97. *)
  98. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|force-reload}"
  99. exit 2
  100. esac
  101. exit $?