3

I've taken a look at every question regarding systemd here and cannot seem to find the answer, so I apologize if I'm somehow missing it.

I just want to run the following script at startup, but it seems it must be after systemd finishes because it is dependent upon the network and gui to be up. I'm trying to set up the mousepad to allow tap-clicking, and trying to run a connect.sh script which connects me to a VPN. The following script does everything it's supposed to do when I run it manually, but I cannot for the life of me figure out why it won't run at startup.

startup.sh:

#! /bin/sh
# /root/Scripts/startup.sh

synclient tapbutton1=1 clickfinger2=3 tapbutton2=3
sleep 2
sh /root/Scripts/connect.sh
sleep 10

contents of connect.sh:

#! /bin/sh
# /root/Scripts/connect.sh


echo "disabling wifi adapter..\n"
ifconfig wlan0 down
sleep 3
macchanger -r wlan0
echo "enabling wifi adapter..\n"
ifconfig wlan0 up
sleep 3
echo "connecting to VPN..\n"
nmcli con up id vpnconnection1
sleep 3
ifconfig
echo "finished\n"

/etc/systemd/system/mystartup.service:

[Unit]
After=network.target

[Service]
ExecStart=/root/Scripts/startup.sh

[Install]
WantedBy=default.target

I run systemctl enable mystartup.service and reboot, but the script clearly hasn't run since the changes have not taken effect.

What am I doing wrong?

EDIT: I updated the scripts to reflect the absolute paths to the script locations. ran systemctl and rebooted, but still not working.

For more clarification, I just want to run these two scripts at startup. Registering them as a service doesn't make sense to me, but everything I've researched has brought me here. That said, systemctl --state=failed doesn't show mystartup.service listed, and service mystartup.service status says Unit mystartup.service.service could not be found.

  • maybe change WantedBy=default.target to WantedBy=multi-user.target ? – tonioc Mar 15 '18 at 8:56
  • 2
    Tell us the error messages. Show us what the logs say about the service. Prove to us, with service status and log output edited into the question, that the service has not run. – JdeBP Mar 15 '18 at 8:59
  • Ok, the systemd log says it is definitely running, but getting Failed to connect to X Server and the connect.sh script runs but doesn't do what it's supposed to do, so this doesn't solve my problem. As I said above, the script needs to run at the very end of the systemd startup. I will open a new question, thank you. – nohupt Mar 15 '18 at 9:28
  • 3
    Debian or Kali-Linux ? – Kiwy Mar 15 '18 at 9:33
  • @Kiwy Kali is Debian. – nohupt Jun 19 '18 at 3:46
1

These don't really belong as systemd services...

Setting up the mousepad depends on X running and needs to be done for that session.

The proper way to set that up is to configure that as part of the X config.

See here for a way to configure that.

Regarding connecting to the VPN, you should probably configure that in NetworkManager, which controls your connections and knows when your network is up.

See here for a way to hook up a dispatcher script to NetworkManager that can bring the VPN up when the network is up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.