Created
March 28, 2020 02:09
-
-
Save biagidp/085674c8567348cb701f9d64ac14b83f to your computer and use it in GitHub Desktop.
Troubleshooting starting synergyc with systemd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo systemctl daemon-reload | |
$ sudo systemctl enable synergyc.service | |
$ sudo systemctl start synergyc.service | |
$ sudo systemctl status synergyc.service | |
● synergyc.service - Start the synergyc client | |
Loaded: loaded (/etc/systemd/system/synergyc.service; enabled; vendor preset: enabled) | |
Active: active (running) since Fri 2020-03-27 21:06:28 CDT; 5s ago | |
Process: 3440 ExecStop=/usr/local/bin/synergyc-ctl.sh stop (code=exited, status=0/SUCCESS) | |
Process: 3716 ExecStart=/usr/local/bin/synergyc-ctl.sh start (code=exited, status=0/SUCCESS) | |
Main PID: 3730 (synergyc) | |
Tasks: 3 (limit: 4915) | |
CGroup: /system.slice/synergyc.service | |
└─3730 /usr/bin/synergyc --no-tray --name client-name --enable-crypto 192.168.1.73:24800 | |
Mar 27 21:06:25 biagidp-MacPro systemd[1]: Starting Start the synergyc client... | |
Mar 27 21:06:26 biagidp-MacPro synergyc[3730]: Synergy 1.11.0: [2020-03-27T21:06:26] WARNING: secondary screen unavailable: unable to open screen | |
Mar 27 21:06:28 biagidp-MacPro systemd[1]: Started Start the synergyc client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
OP=${1} | |
# put the synergy server IP here (at boot time name lookup does not work | |
# and synergyc will fail and exit, using the IP prevents the problem) | |
SERVER_IP=192.168.1.73:24800 | |
SYNERGYC=/usr/bin/synergyc | |
PS=/bin/ps | |
GREP=/bin/grep | |
WC=/usr/bin/wc | |
PIDOF=/bin/pidof | |
SLEEP=/bin/sleep | |
# check synergyc is running | |
sc_check() { | |
N=`${PS} -ef | ${GREP} "${SYNERGYC}" | ${GREP} -v "${GREP}" | ${WC} -l` | |
return $N | |
} | |
# kill synergyc if running | |
sc_kill() { | |
SIG="" | |
while true | |
do | |
sc_check | |
if [ $? -eq 1 ] | |
then | |
PIDS=`${PIDOF} "${SYNERGYC}"` | |
if [ ${PIDS} != "" ] | |
then | |
kill ${SIG} ${PIDS} | |
fi | |
else | |
break | |
fi | |
${SLEEP} 1 | |
SIG="-9" | |
done | |
} | |
# start synergyc | |
sc_start() { | |
COMMAND="${SYNERGYC} --no-tray --name client-name --enable-crypto ${SERVER_IP}" | |
while true | |
do | |
$COMMAND | |
${SLEEP} 2 | |
sc_check | |
if [ $? -eq 1 ] | |
then | |
break | |
fi | |
done | |
} | |
case "${OP}" in | |
start) | |
sc_kill | |
sc_start | |
;; | |
stop) | |
sc_kill | |
;; | |
*) | |
echo "usage: synergyc-ctl [start|stop]" | |
exit 1 | |
;; | |
esac | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Start the synergyc client | |
[Service] | |
ExecStart=/usr/local/bin/synergyc-ctl.sh start | |
ExecStop=/usr/local/bin/synergyc-ctl.sh stop | |
Type=forking | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment