Systemd cannot run my startup script

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












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 "finishedn"


/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.







share|improve this question






















  • maybe change WantedBy=default.target to WantedBy=multi-user.target ?
    – tonioc
    Mar 15 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 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 at 9:28







  • 3




    Debian or Kali-Linux ?
    – Kiwy
    Mar 15 at 9:33










  • @Kiwy Kali is Debian.
    – nohupt
    Jun 19 at 3:46














up vote
2
down vote

favorite












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 "finishedn"


/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.







share|improve this question






















  • maybe change WantedBy=default.target to WantedBy=multi-user.target ?
    – tonioc
    Mar 15 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 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 at 9:28







  • 3




    Debian or Kali-Linux ?
    – Kiwy
    Mar 15 at 9:33










  • @Kiwy Kali is Debian.
    – nohupt
    Jun 19 at 3:46












up vote
2
down vote

favorite









up vote
2
down vote

favorite











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 "finishedn"


/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.







share|improve this question














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 "finishedn"


/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.









share|improve this question













share|improve this question




share|improve this question








edited Jun 20 at 8:45









Kiwy

5,36743350




5,36743350










asked Mar 15 at 8:17









nohupt

112




112











  • maybe change WantedBy=default.target to WantedBy=multi-user.target ?
    – tonioc
    Mar 15 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 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 at 9:28







  • 3




    Debian or Kali-Linux ?
    – Kiwy
    Mar 15 at 9:33










  • @Kiwy Kali is Debian.
    – nohupt
    Jun 19 at 3:46
















  • maybe change WantedBy=default.target to WantedBy=multi-user.target ?
    – tonioc
    Mar 15 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 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 at 9:28







  • 3




    Debian or Kali-Linux ?
    – Kiwy
    Mar 15 at 9:33










  • @Kiwy Kali is Debian.
    – nohupt
    Jun 19 at 3:46















maybe change WantedBy=default.target to WantedBy=multi-user.target ?
– tonioc
Mar 15 at 8:56




maybe change WantedBy=default.target to WantedBy=multi-user.target ?
– tonioc
Mar 15 at 8:56




2




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 at 8:59




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 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 at 9:28





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 at 9:28





3




3




Debian or Kali-Linux ?
– Kiwy
Mar 15 at 9:33




Debian or Kali-Linux ?
– Kiwy
Mar 15 at 9:33












@Kiwy Kali is Debian.
– nohupt
Jun 19 at 3:46




@Kiwy Kali is Debian.
– nohupt
Jun 19 at 3:46










1 Answer
1






active

oldest

votes

















up vote
1
down vote













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.



I hope this helps!






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430343%2fsystemd-cannot-run-my-startup-script%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    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.



    I hope this helps!






    share|improve this answer
























      up vote
      1
      down vote













      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.



      I hope this helps!






      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        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.



        I hope this helps!






        share|improve this answer












        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.



        I hope this helps!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 7:42









        Filipe Brandenburger

        3,467621




        3,467621






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430343%2fsystemd-cannot-run-my-startup-script%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay