Page 1 of 3

Disabling anydesk autostart on sysvinit

Posted: Thu Dec 03, 2020 10:24 am
by andyprough
Problem: anydesk [remote desktop software] always autostarts with the system. This is highly undesirable in some cases (although it is desirable in others).

Dilemma: Instructions are widely available online on how to disable anydesk autostart on systemd distros and on Mac and Windows machines, but not for sysvinit. The systemd instructions do not work on sysvinit, nor do the Mac or Windows instructions.

Solution: The only solution I've been able to figure out that works is to delete the "S03anydesk" file from runlevels 2 through 5:
/etc/rc2.d/S03anydesk
/etc/rc3.d/S03anydesk
/etc/rc4.d/S03anydesk
/etc/rc5.d/S03anydesk

UPDATE - per advice from @dolphin_oracle, here is the best solution:
1. Edit /etc/init.d/anydesk with editor of choice to remove runlevels from the headers for the Default-Start line. Change from:

Code: Select all

### BEGIN INIT INFO
# Provides:          anydesk
# Required-Start:    $dbus udev networking
# Required-Stop:     $dbus udev networking
# Should-Start:      $syslog
# Should-Stop:       $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: AnyDesk global service
# Description:       AnyDesk global service 
### END INIT INFO
Change to the following, deleting runlevels 2, 3, 4 and 5 from Default-Start:

Code: Select all

### BEGIN INIT INFO
# Provides:          anydesk
# Required-Start:    $dbus udev networking
# Required-Stop:     $dbus udev networking
# Should-Start:      $syslog
# Should-Stop:       $syslog
# Default-Start:     
# Default-Stop:      0 1 6
# Short-Description: AnyDesk global service
# Description:       AnyDesk global service 
### END INIT INFO
2. Save, close the editor, and run the following commands:

Code: Select all

sudo update-rc.d anydesk remove
sudo update-rc.d anydesk defaults
This removes the instructions for the anydesk service to be started with runlevels 2,3,4,5. After this change and rebooting, anydesk no longer autostarts, but the anydesk service still starts and runs fine when manually starting from the XFCE menu.

Issue: [UPDATE - Issue resolved, no longer a concern] Not sure if this will cause any damage to the system, as I'm not very knowledgeable about sysvinit runlevel scripts. I may be doing something wildly wrong here, but just wanted to start the conversation. Please jump in and tell me if this is incorrect procedure or likely to cause damage to the system.

Re: Disabling anydesk autostart on sysvinit

Posted: Thu Dec 03, 2020 6:49 pm
by JayM
Can't you run

Code: Select all

sudo sysv-rc-conf
and disable the anydesk service without removing those files?

Re: Disabling anydesk autostart on sysvinit

Posted: Thu Dec 03, 2020 7:03 pm
by dolphin_oracle

Code: Select all

sudo update-rc.d anydesk remove
will work.

Re: Disabling anydesk autostart on sysvinit

Posted: Thu Dec 03, 2020 7:49 pm
by andyprough
dolphin_oracle wrote: Thu Dec 03, 2020 7:03 pm

Code: Select all

sudo update-rc.d anydesk remove
will work.
Looks like you're removing anydesk scripts from all runlevels? I think I still need to leave the halt scripts in runlevels 0, 1, and 6. But maybe I'm wrong.

Re: Disabling anydesk autostart on sysvinit

Posted: Thu Dec 03, 2020 7:56 pm
by andyprough
JayM wrote: Thu Dec 03, 2020 6:49 pm Can't you run

Code: Select all

sudo sysv-rc-conf
and disable the anydesk service without removing those files?
I thought about that and looked at it, but was wondering if I might somehow ruin anydesk's functionality if I remove the service altogether. As I said though, this is an area where I don't have much experience. Right now it is working exactly as needed with those above changes. I'm just wondering if I'm doing anything harmful to the system by deleting the scripts.

Re: Disabling anydesk autostart on sysvinit

Posted: Thu Dec 03, 2020 8:11 pm
by JayM
basically you don't want it to always run as a service but only start on demand when the user tells it to, correct? You could stop (but not uninstall or delete the files for) its service then start it on demand with a command-line sitch to start its service, then stop the service when you're through with another command-line switch. These could be done through shell scripts or launchers. See https://support.anydesk.com/Command_Line_Interface

So,

Code: Select all

anydesk --service
to start the service and

Code: Select all

anydesk --stop-service
to stop it again.

Re: Disabling anydesk autostart on sysvinit

Posted: Thu Dec 03, 2020 8:51 pm
by dolphin_oracle
I suppose you could change the headers in the script to match whatever runlevels you want, then

Code: Select all

sudo update-rc.d anydesk remove
sudo update-rc.d anydesk defaults
which defaults would be whatever runlevels you choose.

Re: Disabling anydesk autostart on sysvinit

Posted: Thu Dec 03, 2020 9:49 pm
by andyprough
dolphin_oracle wrote: Thu Dec 03, 2020 8:51 pm I suppose you could change the headers in the script to match whatever runlevels you want, then

Code: Select all

sudo update-rc.d anydesk remove
sudo update-rc.d anydesk defaults
which defaults would be whatever runlevels you choose.
Oh that is perfect! You are right, when I delete runlevels from the script header and run the update-rc.d commands, it removes the startup scripts and retains the halt scripts in the appropriate runlevels. And now there should be no confusion for the init system because of a mismatch between headers and placement of scripts. Excellent, thank you.

Re: Disabling anydesk autostart on sysvinit

Posted: Tue Sep 14, 2021 1:07 am
by kevtardis
Greetings!

This is just what I'm looking for, but I'm unclear as to what needs to be done.

Do I just create an executable script that runs on startup containing the two update-rc.d commands?

Or am I supposed to make the edits to /etc/init.d/anydesk listed in the first post, and then create an executable script that runs on startup containing the two update-rc.d commands?

Or something else? Please excuse my confusion, but I'd hate to make things worse by making some bad assumptions. Thanks.

Re: Disabling anydesk autostart on sysvinit

Posted: Tue Sep 14, 2021 5:11 am
by fehlix
The solution to disable "autostart" of anydesk as system service and autostart on user level was given here:
viewtopic.php?p=577730#p577730
as:
AnyDesk service:

Code: Select all

sudo update-rc.d anydesk remove
Autostart:

Code: Select all

printf "[Desktop Entry]\nHidden=true\n" > ~/.config/autostart/anydesk_global_tray.desktop
There is no need to have an init-script for shutdown/reboot runlevels left enabled, if system level service have not been started in the first place.