debauchee / barrier

Open-source KVM software
Other
27.73k stars 1.52k forks source link

onBoot #185

Open a7hybnj2 opened 6 years ago

a7hybnj2 commented 6 years ago

Operating Systems

Server: Arch from AUR

Client: Windows 10, Windows 8.1, and MacOS Mojave

I have tried looking at synergy help documents for a way to get barrier to boot before login windows so that, obviously, you can used a shared keyboard to login to multiple systems.

It seems that there are some versions of synergy that have a 'service' option at least for windows. I also tried some funny mac script that ultimately caused my OS to fail to boot and I had to recover-mode terminal delete the script to boot again.

It would be great to add a writeup to the wiki on how, if possible, to get the clients and server to start prior to login screens.

a7hybnj2 commented 6 years ago

UPDATE: I don't know exactly I was doing previously but it seems that my windows machine does indeed start barrier on boot. I wasn't patient enough to wait for it to connect, takes about 10-15 seconds after login screen is visible.

I start my server with the Arch(plasma) - System Settings - Startup and Shutdown - Autostart - "/bin/barriers -f --no-tray --debug INFO --name myPrivateName --enable-crypto -c /home/myPrivateUName/.barrier.conf --address :24800" and that starts the service just fine but only after login.

And mac...who knows EDIT: I have "/Applications/Barrier.app/Contents/MacOS/barrierc -f --no-tray --debug INFO --name myOtherPrivateName n --enable-drag-drop --enable-crypto [192.168.1.184]:24800"
added to login items for my user

AdrianKoshka commented 6 years ago

We don't really have an officially documented way of doing autostart as you said. I've been rather busy with other things in life, mostly having enough time to check issues daily and try to label them.

a7hybnj2 commented 6 years ago

I will take a look and try to document how, if ever, I get it to work. I will leave my notes here.

Windows: Done. Seems to enable auto start automatically.

Linux: Should be easy but I did read about KDE locking the keyboard down until after login. So, that might be an issue running server on a KDE box. Now 100% sure yet.

MacOS: Seems like the 'old way' pre 10.10 was easy using plist. I am still looking for a 10.14 way that doesn't lock up my system.

Ref1 Ref2 Ref3 Ref4

mgorbet commented 5 years ago

Any tips or links on how to get a raspberry pi to launch Barrier on startup would be very helpful. I tried cron @reboot but so far can't seem to get the syntax right ... or something.

What's the 'accepted wisdom' on this?

AdrianKoshka commented 5 years ago

I know I used systemd user services.

mgrant0 commented 4 years ago

To get Barrier to launch at startup on MacOS:

image

But it always comes up like this:

image

Is it possible to get it to start in client mode with a pre-configured IP address?

shymega commented 4 years ago

To get Barrier to launch at startup on MacOS:

image

But it always comes up like this:

image

Is it possible to get it to start in client mode with a pre-configured IP address?

Hm.. you might be able to use barrierc directly.

abudiar commented 4 years ago

To get Barrier to launch at startup on MacOS:

image

But it always comes up like this:

image

Is it possible to get it to start in client mode with a pre-configured IP address?

I've been able to get it to launch with a preconfigured ip address by:

  1. Setting the ip address, connect to server
  2. Quit Barrier through the top bar icon
  3. Relaunch Barrier
  4. Set Barrier to launch at login

Then once I restart it launches with the ip address already saved.

oppalla commented 3 years ago

I'm also trying to set Barrier to start as a service, like VNC server, in order to log in on macOS from my Windows host keyboard/mouse. unfortunately even clicking on Options > Open at login, I can't use my Windows Keyboard and Mouse to put my login credentials when I turn my iMac on. I'm running High Sierra 10.13.6.

any help will be appreciated!

xrpdevs commented 3 years ago

I run MacOS in a Proxmox/KVM instance with it's own GPU. Barrier server is on Manjaro (also KVM guest with own GPU) which is where the USB ports are plugged in.

I'm wondering if it would be possible to run barrierc as root pre-login via SSH with a hook script at VM launch time..

xrpdevs commented 3 years ago

Have you seen https://web.archive.org/web/20150511090759/http://synergy2.sourceforge.net/autostart.html ?

xrpdevs commented 3 years ago

Thinking this could be used for running barrier pre-login, if we modify the "KeepAlive" part to the StartupItems script to check for the presence of a file in say /tmp then we can tell the script to kill barrier once we're running barrier as our logged-in user (so clipboard works) then, assuming there are "OnLogOut" scripts for MacOS then remove the /tmp file so the StartupItems script re-launches barrierc (as root again)

OR, in the KeepAlive, look for a second barrier PID that isn't root's copy, if found, terminate, not found, restart.. this seems like a more practical/elegant solution.

xrpdevs commented 3 years ago

It is annoying having to do the USB swap on boot. Will try to write this up and chuck it on my github tomorrowe if I get time.

oppalla commented 3 years ago

Have you seen https://web.archive.org/web/20150511090759/http://synergy2.sourceforge.net/autostart.html ?

I'll be trying this right now! it's really annoying to have to use batteries on my keyboard and touchpad if I just use them to log in.

oppalla commented 3 years ago

Unfortunately, I followed the steps below and didn't make any difference on how Barrier starts. It just opens up after logging my user in.

1 - Opened a terminal window and become root: $ sudo su -

2 - Created a folder like this: # mkdir -p /Library/StartupItems/Barrier

3 - Created a file without extension in this folder with this text:

#!/bin/sh
. /etc/rc.common

run=(/usr/local/bin/barrierc -n $(hostname -s) -1 -f 192.168.2.2)

KeepAlive ()
{
    proc=${1##*/}

    while [ -x "$1" ]
    do
        if ! ps axco command | grep -q "^${proc}\$"
        then
           "$@"
        fi

        sleep 3
    done
}

StartService ()
{
    ConsoleMessage "Starting Barrier"
    KeepAlive "${run[@]}" &
}

StopService ()
{
    return 0
}

RestartService ()
{
    return 0
}

RunService "$1"

4 - Made the script executable with this command: # chmod 755 /Library/StartupItems/Barrier/Barrier 5 - Created a file named StartupParameters.plist under the same folder containing:

{
    Description      = "Barrier Client";
    Provides         = ("Barrier");
    Requires         = ("Network");
    OrderPreference  = "None";
}

6 - Executed the startup script from the terminal without any errors or advice with this command: # /Library/StartupItems/Barrier/Barrier start

7 - Turned off my iMac and my PC

8 - Turned on my iMac till it gets to log in screen, then turned on my PC

9 - Nothing happened at all, I must log through VNC or use the iMac native keyboard to log in.

Any idea on what I'm missing? Or this can't be used on High Sierra? Any help will be really appreciated! Something I noted, is that if I open terminal and go to/usr/local/bin/and give an lscommand, it don't show any barrierc folder. Maybe is this? Any idea on where should I point this path on macOS for it to work?

xrpdevs commented 3 years ago

I'm running Big Sur. Had a late start today so have yet to take a look at it properly.

Would suggest checking your syslog to see if there is a "Starting Barrier" message recorded, and doing a "ps aux | grep barrierc" (as root) via ssh to see if it's running or not.

xrpdevs commented 3 years ago

Oh and you want to replace /usr/local/bin/ with /Applications/Barrier.app/Contents/MacOS/ (or wherever your barrierc binary is stored)

oppalla commented 3 years ago

@xrpdevs thanks for troubleshooting this with me, I really appreciate your efforts.

I have before going to sleep set the /usr/local/bin/ with /Applications/Barrier.app/Contents/MacOS/Barrierc, but unfortunately it's not working yet.

I'm taking a look at the macOS Console right now, but I'm not sure about what should I search for.

I've put Barrier on the search box, surfed between the folders on the left, there are a few logs, anything much explanatory.

can you keep with me on this? I'm using barrier for a year more or less, and since then, I'm using a second keyboard just to log in to my mac, every day by the morning. it will improve a lot the usability, and maybe help users in further times. thanks!

xrpdevs commented 3 years ago

Yeah I'll have a go at getting it working later, I'm not really a Mac person per se, but extensive experience with *nix systems in general so hopefully be able to get to the bottom of this.

xrpdevs commented 3 years ago

So got the switching between root and user version of barrierc working, only problem is, that (at least on Big Sur) A) /Library/StartupItems is deprecated, and B) To run GUI apps pre-login requires privelege (see https://apple.stackexchange.com/questions/372933/execute-a-script-with-gui-access-before-login )

Appears the way to start barrierc pre-login is to use launchd, going to look into how to do that in combination with B)

Gist of what I've done so far: https://gist.github.com/xrpdevs/b53c9962dd72ffce2cdd6bd9d4d87f28

xrpdevs commented 3 years ago

The install instructions may or may not work for you as you are not using Big Sur. I have another VM running catalina but I expect it will behave much the same as BS. Got other stuff to do now but probably take another look tomorrow. I guess if I manage to get this working can always submit it as a PR.

oppalla commented 3 years ago

So got the switching between root and user version of barrierc working, only problem is, that (at least on Big Sur) A) /Library/StartupItems is deprecated, and B) To run GUI apps pre-login requires privelege (see https://apple.stackexchange.com/questions/372933/execute-a-script-with-gui-access-before-login )

Appears the way to start barrierc pre-login is to use launchd, going to look into how to do that in combination with B)

Gist of what I've done so far: https://gist.github.com/xrpdevs/b53c9962dd72ffce2cdd6bd9d4d87f28

I'm trying your instructions right now. Just have two questions:

1 - Is it necessary to CHMOD 755 the Barrier file?

2 - Am I supposed to create a launchd script? which will create the file /tmp/barrierc_user_running when logging in? how do I do it?

oppalla commented 3 years ago

Create a launchd script which creates the file /tmp/barrierc_user_running when you log in.

mate @xrpdevs, how do I create this launchd script?