Re: [Utility Script] GIO mount samba share

Isn’t

After=network-online.target

needed here?

How can I mount more then 1 shares?

:thinking:

Everything can be improved … and yes the topic makes some assumptions on the initial network connection as it would be on a workstation.

When I wrote this it was intended to be an alternative to modify the fstab to temporary mount a samba share - which is both error prone and network sensitive.

The original idea was to run the script when you needed the share and run it again when you don’t.

gio-mount will likely fail if the network is not available which is also why I added the idea to extend the script with some network checking.

If you want to mount more than one named share - you can copy the script and the service - using e.g. the share-name as identifier for script and service.

1 Like

Here are the modifications that I made on the script:

I would add the License file which GPL Version does this Script relay on?

For some reason the service file isn’t found by systemd.
I have no solution for that until now.
I placed the script into autostart which is working so far.

1 Like

It is a user service

systemctl start --user service

GPL 3 or newer

$ systemctl daemon-reload --user
$ systemctl start --user smb-share
Failed to start smb-share.service: Unit smb-share.service not found.

~/.local/systemd/user

[Unit]
Description=GIO mount smb shares
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/home/%u/.local/bin/smb-share.sh
ExecStop=/home/%u/.local/bin/smb-share.sh -u
Restart=on-failure
RestartSec=30

[Install]
WantedBy=multi-user.target

You need to create the folder ~/.config/systemd/user/ - place service unit in the folder - then you can start/enable it


I can’t say - I have a couple of user services active - it works as expected

You did remember to name the service file with the .service extension?

17:54:22 ○ [fh@tiger] ~/.../systemd/user
 $ tree .
.
├── check-aur.service
├── check-aur.timer
├── default.target.wants
│   ├── modprobed-db.service -> /usr/lib/systemd/user/modprobed-db.service
│   └── syncthing.service -> /usr/lib/systemd/user/syncthing.service
├── protonvpn_reconnect.service
└── timers.target.wants
    └── check-aur.timer -> /home/fh/.config/systemd/user/check-aur.timer

okay, well than it has to be under ~/.config/systemd/user/ and not ~/.local/systemd/user/

I see the typo - my apologies …