You are not logged in.
I made this small Bash script to automate system upgrades.
#! /bin/bash
read -s -p "Superuser Authentication: " sudoPW
export HISTIGNORE='*sudo -S*'
(
echo 'Updating AUR Packages..'
paru -Sua
echo 'Updating AUR Done'
echo 'Updating Arch Packages..'
echo $sudoPW | sudo -S -k pacman -Syu
echo 'Updating Arch Packages Done'
) 2>&1 | tee -a ~/update$(date +"%Y-%m-%d_%T").log
shutdown
but for some reason the system always shutdowns before the actual update finishes. Why is that? And how can I prevent it?
Offline
I made this small Bash script to automate system upgrades.
That's a bad idea ...
read -s -p "Superuser Authentication: " sudoPW
And that's a far far worse idea! Use `sudo -v` that's what it's for.
Why is that?
You direct all the output to a log ... start there.
I'd guess paru at least is failing as it would need root access to install any built packages, but no password is provided to it.
Last edited by Trilby (2022-01-04 05:09:47)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Use `sudo -v` that's what it's for.
Doesn't 'sudo -v' only work for like a couple of minutes?
You direct all the output to a log ... start there.
The reason the log exists in the first place is because I saw that the system shut down before the update could finish so I needed to see what happened before the shutdown. It didn't really help, but I decided to keep it because generally a log seems useful.
I'd guess paru at least is failing as it would need root access to install any built packages, but no password is provided to it.
I don't automate Paru, Hence it is first.
Offline
Doesn't 'sudo -v' only work for like a couple of minutes?
You can actually control that but while I agree w/ Trilby that reading the password into a variable and echoing it around in an unattended process is … objectable, it's not your problem.
I don't automate Paru, Hence it is first.
I'm not sure what's that supposed to say but
"paru -Sua" will require root privileges so unless it elevates itself, you need to sudo it.
so I needed to see what happened before the shutdown. It didn't really help
Why not? You might want to share it since it'll gt others a hint about what's going on there.
A massive problem could be that "pacman -Syu" is typically going to require some stdin what may or not be provided by the context of your script and rather not in that subshell.
Offline
First I would like to apologize for a delayed response, I was caught up in a project and I kinda forgot about my thread as well as my struggle with making the script work. My bad.
Secondly, thank you for your interest in my script
I don't automate Paru, Hence it is first.
I'm not sure what's that supposed to say but
"paru -Sua" will require root privileges so unless it elevates itself, you need to sudo it.
Well I didn't find a way to automate paru approval over the few AURs I have so I still have to exit vim and say yes so I put it first to get done
so I needed to see what happened before the shutdown. It didn't really help
Why not? You might want to share it since it'll gt others a hint about what's going on there.
Well the log showed that at some random point while it was downloading packages it shutdown. This happened every time with different packages. So I don't quite get the problem...
Offline
What context is that script run and does
paru -Sua; sudo pacman -Syu && shutdown
in an interactive shell "work"?
Also, how does the log show that *it* shutdown?
Tried a leadign "set -x"? Is maybe something entirely different shutting down the system? (hence "context"…)
Offline