This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Upgraded to 22.04, login bash scripts don't work as expected

Tags: None
(comma "," separated)
dreaperxz
Registered Member
Posts
7
Karma
0
Hi,

So, I am having an issue with certain login scripts that I use since I upgraded to 22.04 on KDE Neon. For example this script that mounts my folders no longer works.

Code: Select all
#!/bin/bash
/usr/bin/sshfs mediaserver@mediaserver-pc.local:/media/mediaserver/MediaDrive/Downloads/ ~/sshdownloads/
/usr/bin/sshfs mediaserver@mediaserver-pc.local:/media/mediaserver/MediaDrive/Media/ ~/sshmedia/ -o allow_other -o ro


I did a test by adding via Autostart:

Code: Select all
konsole -e somescript.sh


Seems that for as long as the script is open, those mounts remain. But when I close it, the sshfs processes are killed off when closing the script. I have tried disown, and nohup with those commands, but there has been no change. Anyone have an idea? Maybe there is a way to keep those script open indefinitely?

EDIT:

Seems like as a temporary fix, using
Code: Select all
sleep infinity
at the end like so:

Code: Select all
#!/bin/bash
/usr/bin/sshfs mediaserver@mediaserver-pc.local:/media/mediaserver/MediaDrive/Downloads/ ~/sshdownloads/
/usr/bin/sshfs mediaserver@mediaserver-pc.local:/media/mediaserver/MediaDrive/Media/ ~/sshmedia/ -o allow_other -o ro
sleep infinity


is the only solution. But if there is a better solution, please share! Thanks!
alexsid
Registered Member
Posts
20
Karma
0
dreaperxz wrote:Hi,

So, I am having an issue with certain login scripts that I use since I upgraded to 22.04 on KDE Neon. For example this script that mounts my folders no longer works.

Code: Select all
#!/bin/bash
/usr/bin/sshfs mediaserver@mediaserver-pc.local:/media/mediaserver/MediaDrive/Downloads/ ~/sshdownloads/
/usr/bin/sshfs mediaserver@mediaserver-pc.local:/media/mediaserver/MediaDrive/Media/ ~/sshmedia/ -o allow_other -o ro


I did a test by adding via Autostart:

Code: Select all
konsole -e somescript.sh


Seems that for as long as the script is open, those mounts remain. But when I close it, the sshfs processes are killed off when closing the script. I have tried disown, and nohup with those commands, but there has been no change. Anyone have an idea? Maybe there is a way to keep those script open indefinitely?

EDIT:

Seems like as a temporary fix, using
Code: Select all
sleep infinity
at the end like so:

Code: Select all
#!/bin/bash
/usr/bin/sshfs mediaserver@mediaserver-pc.local:/media/mediaserver/MediaDrive/Downloads/ ~/sshdownloads/
/usr/bin/sshfs mediaserver@mediaserver-pc.local:/media/mediaserver/MediaDrive/Media/ ~/sshmedia/ -o allow_other -o ro
sleep infinity


is the only solution. But if there is a better solution, please share! Thanks!


I suspect this is due to https://blog.davidedmundson.co.uk/blog/ ... d-startup/

as I can see on my PC after upgrade to 22.04

1:10% systemctl --user status plasma-plasmashell.service

● plasma-plasmashell.service - KDE Plasma Workspace
Loaded: loaded (/usr/lib/systemd/user/plasma-plasmashell.service; disabled>
Active: active (running) since Tue 2022-10-25 12:27:06 ADT; 44min ago
Main PID: 10123 (plasmashell)
Tasks: 14 (limit: 38279)
Memory: 160.7M
CPU: 5.819s
CGroup: /user.slice/user-1001.slice/user@1001.service/session.slice/plasma>
├─10123 /usr/bin/plasmashell --no-respawn
├─45256 cat
└─45257 cat

It seems that disabling Plasma systemd startup helps, see https://www.reddit.com/r/archlinux/comm ... r_working/

Alex
dreaperxz
Registered Member
Posts
7
Karma
0
alexsid wrote:I suspect this is due to https://blog.davidedmundson.co.uk/blog/ ... d-startup/

as I can see on my PC after upgrade to 22.04

1:10% systemctl --user status plasma-plasmashell.service

● plasma-plasmashell.service - KDE Plasma Workspace
Loaded: loaded (/usr/lib/systemd/user/plasma-plasmashell.service; disabled>
Active: active (running) since Tue 2022-10-25 12:27:06 ADT; 44min ago
Main PID: 10123 (plasmashell)
Tasks: 14 (limit: 38279)
Memory: 160.7M
CPU: 5.819s
CGroup: /user.slice/user-1001.slice/user@1001.service/session.slice/plasma>
├─10123 /usr/bin/plasmashell --no-respawn
├─45256 cat
└─45257 cat

It seems that disabling Plasma systemd startup helps, see https://www.reddit.com/r/archlinux/comm ... r_working/

Alex


Seems like this worked:

Code: Select all
kwriteconfig5 --file startkderc --group General --key systemdBoot false


Thanks! Seems like there are some smart people on Reddit after all. ;)
sstaeglich
Registered Member
Posts
68
Karma
0
Probably it would be a better approach to migrate these scripts to systemd user units.
dreaperxz
Registered Member
Posts
7
Karma
0
sstaeglich wrote:Probably it would be a better approach to migrate these scripts to systemd user units.


Then why does KDE offer a section to add login scripts?
alexsid
Registered Member
Posts
20
Karma
0
dreaperxz wrote:
sstaeglich wrote:Probably it would be a better approach to migrate these scripts to systemd user units.


Then why does KDE offer a section to add login scripts?


The "one-shot" scripts work fine. That is, if a script does not spawn any child processes, it works without any problems. systemd-run and systemd-kill support many options to control the behavior of child processes, see e.g. https://man7.org/linux/man-pages/man5/s ... ice.5.html and https://man7.org/linux/man-pages/man5/s ... ill.5.html

In particular,

KillMode=
Specifies how processes of this unit shall be killed. One of
control-group, mixed, process, none.

If set to control-group, all remaining processes in the
control group of this unit will be killed on unit stop


So all commands specified in your script work, but as soon as the script is ended, all child processes are killed. That is:

    * if your script spawns a process using '&', this process will be killed when the main script exits

    * if your script contains a command that spawns another process (such as sshfs), these processes will be killed when the main script exits


It is unclear whether this behavior is intended or developers just did not expect anybody to write scripts that spawn more processes. It would probably make sense to add a way to control that in 'Advanced Options' section.

Alex


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]