-1

Hi I was just wondering if this script looks ok I run it after I login thanks.

#!/bin/bash
echo "hi, starting wifi, nft and desktop"
sudo ls
sudo systemctl start wpaStart.service 
sudo nft -f ~/config/nftLocal
startxfce4

edit:

I wanted the script to start my wifi and add nft rules because those things (weren't) working.

I tried running wpa_supplicant but it didn't start properly. wpaStart is this:

cat usr/bin/wpaStart
#!/bin/bash
wpa_supplicant -B -i wlp1s0f0u9 -c /etc/wpa_supplicant/wpa_supplicant.conf

Also thanks for the nftables advice I'll try it. I'm not sure my Nft configuration file was working properly as I have a small network for my lan card. It was maybe overwriting the file. (/etc/systemd/network/20-wired.network)

sudo ls is because I'm just "prepping" sudo so that you enter the password properly. echo is "being friendly".

edit 2:

I tried enabling wpaStart.service and got the same error as before after restarting.

Nov 25 20:59:32 archlinux2 systemd[1]: wpaStart.service: Main process exited, code=exited, status=255/EXCEPTION

I'll keep this script for now and might also try a cron job.

Also my sshd service fails in the log(just like wifi). So I may try it in a cron job.

I still have to re-try the nft solutions.

Also I now use

exec startxfce4
5
  • 1
    Please edit your question and explain what you want the script to do. Running sudo ls seems pointless, as does the echo. Who will be running this? How? How do you give the password? Is the script running interactively? Commented Nov 20 at 9:51
  • 5
    that doesn't seem very sensible, especially since it does sudos that you shouldn't: it starts services that should almost certainly be activated in a different way, running a program on a user-owned directory but as root user (leading to fun ownerships and exploitability effects). And, starting nft after your network comes up is another really bad idea. This all screams "your system has useful session management built, in, but somehow you're trying to use it as if you only had desktop linuxes of the year 1995, and it's biting you". Commented Nov 20 at 11:46
  • 3
    If you're looking for a Code Review, then there's a site for that. But if you post there, you'll need to be clear about the script's purpose; it would also be helpful to mention what testing you have done. Commented Nov 20 at 15:02
  • thanks I'll try those ideas Commented Nov 24 at 20:29
  • As others said, running things as root from the user's startup script is a security flaw. You should use your system's equivalent of daemons/services for that. Some systems permit running services as user, those that don't can make use of cron(8). Also, why sudo ls? That would be justified only if the user's $HOME (or current directory where the script is executed) wasn't executable by the user and the user's group, which if true would pose bigger issues. Otherwise, it is unnecessary, just use ls (still, why?). Commented 18 hours ago

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.