coder
Posts: 8
Joined: Wed Mar 28, 2018 12:26 am

Getting systemd to run a bash script on startup (attempt shown)

Tue Aug 07, 2018 2:17 am

Hi,

I have Toshiba ultrabook that has a faulty drifting track mouse and I can disable the trackmouse manually with a .bashrc command. However, I would like to have systemd to do it automatically on startup. Does anyone know what I have done wrong below:

I made a file /usr/local/bin/disableproblem.sh and did sudo chmod 744 /usr/local/bin/disableproblem.sh

Code: Select all

#!/bin/bash

xinput --disable 'AlpsPS/2 ALPS DualPoint Stick'
(yes, I have installed xinput and the above command does the job perfectly in .bashrc with alias)


I made a file /etc/systemd/system/disableproblem.service and did sudo chmod 664 /etc/systemd/system/disableproblem.service

Code: Select all

[Unit]
Description=DISABLEPROBLEM

[Service]
ExecStart=/usr/local/bin/disableproblem.sh

[Install]
WantedBy=default.target
I also tried:
[Install]
WantedBy=multi-user.target

I then did

sudo systemctl daemon-reload
sudo systemctl enable disableproblem.service

And restarted the computer.

Anyone see what I have done wrong? I don't know what WantedBy in the systemd script above really means?

Thank you.
Last edited by coder on Thu Aug 09, 2018 10:11 am, edited 2 times in total.

clauded
Posts: 54
Joined: Thu Jan 05, 2017 10:49 pm

Re: Getting systemd to run a bash script on startup (attempt shown)

Tue Aug 07, 2018 2:16 pm

1. chmod 755 your file
2. missing ending quote?

coder
Posts: 8
Joined: Wed Mar 28, 2018 12:26 am

Re: Getting systemd to run a bash script on startup (attempt shown)

Thu Aug 09, 2018 10:14 am

Thanks

Thanks for pointing it out, but the missing end quote was only in this forum post.

I have now tried sudo chmod 755 /usr/local/bin/disableproblem.sh as you recommended, but unfortunately it still did not make this work so far, but it may be a missing piece of the puzzle.
Last edited by coder on Fri Aug 10, 2018 3:15 am, edited 2 times in total.

User avatar
ycrawler
Posts: 136
Joined: Thu Aug 10, 2017 8:23 pm

Re: Getting systemd to run a bash script on startup (attempt shown)

Thu Aug 09, 2018 2:02 pm

i have a startup script that works, but dont ask me why cos ive found out you never can tell

anyway mine looks like

Code: Select all

[Unit]
Description=Run Script at Startup

[Service]
Type=oneshot
ExecStart=/opt/sds/startup.sh

[Install]
WantedBy=multi-user.target

coder
Posts: 8
Joined: Wed Mar 28, 2018 12:26 am

Re: Getting systemd to run a bash script on startup (attempt shown)

Fri Aug 10, 2018 9:24 pm

Thanks. The thing I saw different in yours was Type=oneshot which I added. The bash script for my one still isn't being run. What did you chmod your bash script? Also did you chmod 664 your systemd script?

Code: Select all

[Service]
Type=oneshot

Code: Select all

[Install]
WantedBy=multi-user.target
multi-user I had already changed to, but it is good to know this is the correct setting on a working script.

Return to “Other Questions”