mirror of
https://github.com/vhaudiquet/mymachine.git
synced 2025-12-19 20:46:08 +00:00
No sudoers edit if not needed
This commit is contained in:
14
mymachine.sh
14
mymachine.sh
@@ -95,11 +95,13 @@ source ${script_dir}/distribution/${ID}/initial_config.sh
|
|||||||
# Change directory to user home
|
# Change directory to user home
|
||||||
cd /home/${USERNAME}/
|
cd /home/${USERNAME}/
|
||||||
|
|
||||||
# Authorize members of group ${WHEEL_GROUP} to sudo, without password
|
# Authorize members of group ${WHEEL_GROUP} to sudo, without password (if needed)
|
||||||
echo "%${WHEEL_GROUP} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
|
if ! [[ "$(tail -n 1 /etc/sudoers)" = "%${WHEEL_GROUP} ALL=(ALL:ALL) NOPASSWD: ALL" ]]; then
|
||||||
if [ $? -ne 0 ]; then
|
echo "%${WHEEL_GROUP} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||||
echo "Failed to edit /etc/sudoers"
|
if [ $? -ne 0 ]; then
|
||||||
return 1 2>/dev/null || exit 1
|
echo -e "${BRed}Failed to edit /etc/sudoers. Terminating.${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
@@ -209,4 +211,4 @@ if [ "$MICROCODE_INSTALLED" == "false" ]; then
|
|||||||
fi
|
fi
|
||||||
echo "To use WireGuard, don't forget to add this client on VPN server (your private key is under ~/.wireguard/privatekey)"
|
echo "To use WireGuard, don't forget to add this client on VPN server (your private key is under ~/.wireguard/privatekey)"
|
||||||
echo "To use GitHub, you need to use 'gh auth login' to connect to GitHub"
|
echo "To use GitHub, you need to use 'gh auth login' to connect to GitHub"
|
||||||
echo -e "${BNC}Goodbye !${NC}"
|
echo -e "${BNC}Goodbye ! Make sure to ${BGreen}reboot${BNC} to apply all changes !${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user