qubes-updates-proxy-forwarder 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. start-stop-daemon \
  37. --exec $exec \
  38. --pidfile "$pidfile" \
  39. --make-pidfile \
  40. --background \
  41. --start \
  42. -- \
  43. -k -l -e 'qrexec-client-vm $default qubes.UpdatesProxy'
  44. retval=$?
  45. echo
  46. [ $retval -eq 0 ] && touch $lockfile
  47. return $retval
  48. }
  49. stop() {
  50. echo -n $"Stopping $prog: "
  51. killproc -p $pidfile $prog
  52. retval=$?
  53. echo
  54. [ $retval -eq 0 ] && rm -f $lockfile
  55. return $retval
  56. }
  57. restart() {
  58. stop
  59. start
  60. }
  61. force_reload() {
  62. restart
  63. }
  64. rh_status() {
  65. status $prog
  66. }
  67. rh_status_q() {
  68. rh_status >/dev/null 2>&1
  69. }
  70. case "$1" in
  71. start)
  72. rh_status_q && exit 0
  73. $1
  74. ;;
  75. stop)
  76. rh_status_q || exit 0
  77. $1
  78. ;;
  79. restart)
  80. $1
  81. ;;
  82. force-reload)
  83. force_reload
  84. ;;
  85. status)
  86. rh_status
  87. ;;
  88. condrestart|try-restart)
  89. rh_status_q || exit 0
  90. restart
  91. ;;
  92. *)
  93. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|force-reload}"
  94. exit 2
  95. esac
  96. exit $?