Re: Service not run, although enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 7, 2023 at 11:49 AM Martin Stenzel
<m.stenzel@xxxxxxxxxxxxxxxx> wrote:
>
>
> Hi list,
> I searched the _whole_ www but did not find the answer.
>
>
>
> I use bestcrypt <Encrypt Files with BestCrypt Container Encryption | Jetico> to mount the home directory.
>
>
> This is my service file.
>
> --
> [Unit]
> Description=Mount Bestcrypt containers
> Wants=local-fs.target
> After=local-fs.target
>

These Wants and After are redundant, every standard service will be
ordered after local-fs.target unless it also has
DefaultDependencies=no.

> [Service]
> Type=oneshot
> RemainAfterExit=true
> ExecStart=/usr/local/sbin/bcmount
> ExecStop=/usr/local/sbin/bceject
>
> [Install]
> WantedBy=multi-user.target
> --
>
> This is the file to be run
>
> --
> #!/bin/sh
> /usr/bin/bctool mount /mnt/sdr2/2.jbc -t ext4 /mnt/el1-2_
>
> exit 0
> --
>
> If I run "bcmount" by hand (without systemd) it asks for a password, and this is very correct.
>
> If I want to start with "systemctl start bcmount" nothing happens, no error, no execution of the program "bcmount", but as you can see:
>
>
> # systemctl status bestcrypt-fs
> ● bestcrypt-fs.service - Mount Bestcrypt containers
>      Loaded: loaded (/etc/systemd/system/bestcrypt-fs.service; enabled; vendor preset: disabled)
>      Active: active (exited) (thawing) since Mon 2023-08-07 11:17:18 EEST; 20min ago
>     Process: 2645396 ExecStart=/usr/local/sbin/bcmount (code=exited, status=0/SUCCESS)
>    Main PID: 2645396 (code=exited, status=0/SUCCESS)
>
>
> How come that the via "ExecStart=" given bash script does not get run?

What makes you think so? As is clearly visible in the service status,
the ExecStart command *did* run. Whether it also did what you expected
is another question.

> This script does not contain any errors.
> The service file does not have any syntax errors either. Permissions to read/execute are verified!
>
> Do you have a clue?

If your program needs a password entered interactively, it cannot
request such a password using the "normal" way of reading from the
terminal. It would need to implement support for requesting the
password via password agents: https://systemd.io/PASSWORD_AGENTS/

Why your program returns success status when it could not obtain the
necessary password is the question to your program.

Internet most certainly has a lot of information about it. Like
https://unix.stackexchange.com/questions/391040/is-there-a-typical-way-to-pass-a-password-to-a-systemd-unit-file

> I even changed "oneshot" into "simple", striked "RemainAfterExit", etc.
>
> Is there any way I can see the whole process verbosely?
>
>
> Martin.
>
>
> --
> Martin Stenzel (马丁-斯坦泽尔)
> An der Drehscheibe 9
> 50733 Köln
> Deutschland
>
>
> -----BEGIN PGP PUBLIC KEY BLOCK-----
>
> mDMEZHjlmRYJKwYBBAHaRw8BAQdAEr/C08aStyKx+vztCxz4Nn8BHO2Lx0OXllsz
> BP+ZEZm0Pk1hcnRpbiBTdGVuemVsIChDb2xvZ25lLCBHZXJtYW55KSA8bS5zdGVu
> emVsQG1haWwueHktc3BhY2UuZGU+iJYEExYIAD4WIQQrzOhRsO0/8FaU5ykQoKMS
> ax9FuAUCZHjlmQIbAwUJC0c1AAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRAQ
> oKMSax9FuNswAPsEsMp2JdzzDkAw6VzByp2XUY921lFt9rVoaVcZmjV5awD/W57o
> a6c2qbD2p+AYkgKuffa2uZkX3mayvIxsfFnsWAW4OARkeOWZEgorBgEEAZdVAQUB
> AQdAFlq+E22Hk7Gj44CCN4LDr97Y41lUGzvqmpCDpSq0CEwDAQgHiH4EGBYIACYW
> IQQrzOhRsO0/8FaU5ykQoKMSax9FuAUCZHjlmQIbDAUJC0c1AAAKCRAQoKMSax9F
> uGHVAQDjAisQxn5ADKIRPsMfFpE847jFJGA2lRafU7C30gLzhwD8DcegQwz7/RLc
> yozIfQ6yIkz2cR3+NClIepnWV/ATQQw=
> =qQIl
> -----END PGP PUBLIC KEY BLOCK-----
>
> Fingerprint: 2BCC E851 B0ED 3FF0 5694  E729 10A0 A312 6B1F 45B8
>
>
> This message was checked by ESET Endpoint Antivirus for Linux.
>
> https://www.eset.com




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux