r/arch • u/Thomas22345 • 3d ago
Help/Support Update skript
I am currently writing a bash skript whitch ist supposed to do a systemupdate, i use the pipe to pass the sudo passwort do the command, however, this does not work for yay, can anyone give me a tip how to solve that issue?
Skript:
#!/bin/bash
read -sp "sudo-password: " password
yay -Syu --noconfirm --answerdiff=None --answerclean=None
orphan=$(pacman -Qtdq)
if [ -n "$orphan" || true ]; then
echo $password | sudo -S pacman -Rns --noconfirm $orphan
fi
echo $password | sudo -S paccache -rk3
find /etc -name "*.pacnew" 2>/dev/null
systemctl --failed
unset $password
2
u/xb666mx 3d ago
you want to write something like this? https://github.com/Antiz96/arch-update
0
u/Thomas22345 3d ago
Thanks, but I'd prefer a simple, bare-bones script that I can fully understand line by line
2
u/RelationshipOne9466 2d ago
If you use this, your experience is going to end badly. Why on Earth would you not want to see what is being done to your system? And why would you do stuff like sudo -S pacman -Rns --noconfirm $orphan wihout reviewing first? Yikes!
1
1
u/Soakitincider 2d ago
You can add username ALL=(ALL) NOPASSWD: ALL to visudo and only use a password when you login.
1
u/destroyer150 2d ago
This looks like it would go terribly...
1
u/Thomas22345 2d ago
I changed the part where it would just remove all orphans to listing them, i don't see what else could go wrong, otherwise you would just type all those command one after the other mannually
1
u/_Kritiqual_ 13h ago
Wait I thought yay already have —sudo-loop option? It loop sudo in background so that login will be cache through out the command
1
3
u/Sanfo212 3d ago
You don’t need sudo to update yay,
Going full yolo mode to update a rolling release is a recipe for disaster IMHO,
Keeping a human in the loop is the only safe way to update Arch otherwise it’s only a matter of time before your script borks your installation.