qubes-updates-proxy-forwarder 2.2 KB

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