-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install bash scripts improvements #413
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
install.sh
Outdated
@@ -1,36 +1,41 @@ | |||
#!/bin/bash | |||
# Check if the script is running as root | |||
[ "$EUID" -eq 0 ] || exec sudo bash "$0" "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I'm pretty sure the os detection and the wget really don't benefit from being run as root.
- Also, some bsd machines dont have sudo by default.
It might make more sense to just wrap the sudo
around autorestic install
... and maybe only after checking there is a sudo
in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I made some changes to handle elevation to root with sudo or su, and only commands that need to write to /usr/local/bin are executed as root.
[ "$EUID" -eq 0 ] || exec sudo bash "$0" "$@" | ||
# Initialize the elevated variable to ensure we can run commands as root | ||
if [ "$EUID" -eq 0 ]; then | ||
elevated="bash -c" # No need for sudo or su if running as root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elevated=""
Setting it to the empty string means it just goes away - setting it to bash means a whole new shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested it? thanks
install.sh
Outdated
bzip2 -cd "${TMP_FILE}.bz2" > "${OUT_FILE}" | ||
chmod +x ${OUT_FILE} | ||
rm "${TMP_FILE}.bz2" | ||
$elevated "bzip2 -cd ${TMP_FILE}.bz2 > ${OUT_FILE}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your redirect (>
)won't happen as root
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested it? thanks
Hello, while installing autorestic (thank you for the amazing projects) i took the liberty to do some changes to the installation script. If it's ran as no root user it will leverage the sudo command to run it in elevated mode, the if statement changed with case and other minors changes. I hope it can be of use.
Thanks