fix sudo capture
This commit is contained in:
9
sudo.sh
9
sudo.sh
@@ -6,6 +6,13 @@ SUDOERS_FILE="/etc/sudoers.d/hampack"
|
|||||||
USERNAME=$(whoami)
|
USERNAME=$(whoami)
|
||||||
|
|
||||||
echo "Setting up passwordless sudo for HamPack..."
|
echo "Setting up passwordless sudo for HamPack..."
|
||||||
|
echo "Please enter your sudo password once to continue:"
|
||||||
|
sudo -v
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: incorrect password or sudo not available."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
sudo tee "$SUDOERS_FILE" > /dev/null << EOF
|
sudo tee "$SUDOERS_FILE" > /dev/null << EOF
|
||||||
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/pacman, /usr/bin/cp, /usr/bin/systemctl, /usr/sbin/reboot, /usr/sbin/usermod
|
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/pacman, /usr/bin/cp, /usr/bin/systemctl, /usr/sbin/reboot, /usr/sbin/usermod
|
||||||
@@ -16,7 +23,7 @@ sudo visudo -c -f "$SUDOERS_FILE"
|
|||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Sudoers file created successfully for $USERNAME."
|
echo "Sudoers file created successfully for $USERNAME."
|
||||||
echo "You can now run install.sh without being prompted for a password."
|
echo "Passwordless sudo is now configured for the HamPack installer."
|
||||||
else
|
else
|
||||||
echo "Error: sudoers file is invalid, removing..."
|
echo "Error: sudoers file is invalid, removing..."
|
||||||
sudo rm -f "$SUDOERS_FILE"
|
sudo rm -f "$SUDOERS_FILE"
|
||||||
|
|||||||
Reference in New Issue
Block a user