You are not logged in.
Pages: 1
Hi.
I have a systemd service that runs three scripts at startup. The first script seems to be running fine. I assume the two others also are. But they are wrapper scripts that call some python scripts, which are somewhere in my home folder. One of the python scripts requires sudo previliges to run.
The two python scripts never run - can anybody tell me what to do?
systemd service:
[Unit]
Description=
[Service]
Type=oneshot
ExecStart=/usr/bin/AplNetStartup
ExecStart=/usr/bin/AplUsbStartup
ExecStart=/usr/bin/AplDongStartup
[Install]
WantedBy=multi-user.target
Some of the commands in the scripts needs to be run as sudo, som I have added to the /etc/sudoers:
muser ALL=NOPASSWD:/usr/sbin/rfkill
muser ALL=NOPASSWD:/usr/sbin/systemctl
muser ALL=NOPASSWD:/home/me/location/usbctrl.py
AplNetStartup:
#!/bin/sh
sleep 1s
sudo rfkill unblock all
sudo netctrl start wlan0
AplUsbStartup:
#!/bin/sh
cd /home/me/location/
sudo python usbctrl.py
AplDongStartup:
#!/bin/sh
cd /home/me/location/
python dong.py
Offline
Welcome to the Arch Linux forums!
I have a systemd service that runs three scripts at startup.
[...]
Some of the commands in the scripts needs to be run as sudo, som I have added to the /etc/sudoers:
I assume that it's a system-wide service, so you don't need sudo to execute those commands, given that they get executed as root anyway.
sudo rfkill unblock all
sudo netctrl start wlan0
Why do you do that in a script? I don't use netctl, but I'm almost 100% sure that the wiki article will tell you how to auto-startup the WiFi interface at startup, so scripting it seems rather unelegant.
I find it a little weird that you would need to soft-unblock your WiFi card, though. Are you sure it's necessary?
The two python scripts never run - can anybody tell me what to do?
I would put some `echo` commands in your wrapper script to see if they really aren't executed. Otherwise check journalctl for error messages related to the execution of the python scripts.
Last but not least, please enclose script content and console output in [ code ] tags
like thisIt's easier to read your posts.
Offline
Not a Sysadmin issue, moving to NC...
Offline
I assume that it's a system-wide service, so you don't need sudo to execute those commands, given that they get executed as root anyway. I did not know that. That simplifies the situation considerably.
Are you sure it's necessary? Right now I am not sure about anything. It looks like netctrl is doing what it is supposed to, and then sometime after this the wifi gets softblocked. I cannot figure out what is blocking it. This was the only way I could make it work. I agree that it is not particularly beautiful.
- The wrapper scripts ran but apparently the python scripts did not. Or maybe they did. I changed the systemd service file to
[Unit]
Description= ...
After=multi-user.target
[Service]
Type=forking
ExecStart=/usr/bin/AplStartup
RemainAfterExit=yesI have not been very clear in what I wanted to accomplish. When I do it like this all scripts are behaving properly -
Accept for one thing. I need one of the python scripts that is run from AplStartup to run as non-root. Is that possible like this or do I need another .service for that?
Last edited by JakobClausen (2015-12-15 22:17:21)
Offline
Pages: 1