Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 1.19 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. For my other desktop:
  2.  
  3. Here's also /usr/local/bin/synergyc-ctl.sh (also attached):
  4. #!/bin/sh
  5. OP=${1}
  6.  
  7.     put the synergy server IP here (at boot time name lookup does not work
  8.     and synergyc will fail and exit, using the IP prevents the problem)
  9.     SERVER_IP=192.168.1.10
  10.  
  11. SYNERGYC=/usr/bin/synergyc
  12. PS=/bin/ps
  13. GREP=/bin/grep
  14. WC=/usr/bin/wc
  15. PIDOF=/sbin/pidof
  16. SLEEP=/bin/sleep
  17.  
  18.     check synergyc is running
  19.     function sc_check {
  20.     N=`${PS} -ef | ${GREP} "${SYNERGYC}" | ${GREP} -v "${GREP}" | ${WC} -l`
  21.     return $N
  22.     }
  23.  
  24.     kill synergyc if running
  25.     function sc_kill {
  26.     SIG=""
  27.     while true
  28.     do
  29.     sc_check
  30.     if [ $? -eq 1 ]
  31.     then
  32.     PIDS=`${PIDOF} "${SYNERGYC}"`
  33.     if [ ${PIDS} != "" ]
  34.     then
  35.     kill ${SIG} ${PIDS}
  36.     fi
  37.     else
  38.     break
  39.     fi
  40.  
  41.     ${SLEEP} 1
  42.     SIG="-9"
  43.     done
  44.     }
  45.  
  46.     start synergyc
  47.     function sc_start {
  48.     while true
  49.     do
  50.     ${SYNERGYC} "${SERVER_IP}"
  51.  
  52.     ${SLEEP} 2
  53.  
  54.     sc_check
  55.     if [ $? -eq 1 ]
  56.     then
  57.     break
  58.     fi
  59.     done
  60.     }
  61.  
  62. case "${OP}" in
  63. start)
  64. sc_kill
  65. sc_start
  66. ;;
  67. stop)
  68. sc_kill
  69. ;;
  70. *)
  71. echo "usage: synergyc-ctl [start|stop]"
  72. exit 1
  73. ;;
  74. esac
  75.  
  76. exit 0