Reputation: 1
I am trying to update sudoers via script and passing the value of $HOSTNAME
and it's not working... Obviously missing something.
I am expecting:
%[email protected] ALL=(ALL:ALL) ALL
%[email protected] ALL=(ALL:ALL) ALL
Below are the many attempts and results:
sed -i "/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n""%"${HOSTNAME}"[email protected] ALL=(ALL:ALL) ALL" /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%[email protected] ALL=(ALL:ALL) ALL
sed -i "/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n%${HOSTNAME}[email protected] ALL=(ALL:ALL) ALL" /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%[email protected] ALL=(ALL:ALL) ALL
sed -i "/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n%"${HOSTNAME}"[email protected] ALL=(ALL:ALL) ALL" /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%[email protected] ALL=(ALL:ALL) ALL
sed -i "/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n%'${HOSTNAME}'[email protected] ALL=(ALL:ALL) ALL" /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%''[email protected] ALL=(ALL:ALL) ALL
sed -i "/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n%'$HOSTNAME'[email protected] ALL=(ALL:ALL) ALL" /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%''[email protected] ALL=(ALL:ALL) ALL
sed -i "/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n%"$HOSTNAME"[email protected] ALL=(ALL:ALL) ALL" /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%[email protected] ALL=(ALL:ALL) ALL
sed -i '/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n'"%{$HOSTNAME}"'[email protected] ALL=(ALL:ALL) ALL' /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%{}[email protected] ALL=(ALL:ALL) ALL
sed -i '/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n%'"$HOSTNAME"'[email protected] ALL=(ALL:ALL) ALL' /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%[email protected] ALL=(ALL:ALL) ALL
sed -i "/#My Customization.*/a%[email protected] ALL=(ALL:ALL) ALL\n%""${HOSTNAME}""[email protected] ALL=(ALL:ALL) ALL" /tmp/sudoers.bak1
%[email protected] ALL=(ALL:ALL) ALL
%[email protected] ALL=(ALL:ALL) ALL
Upvotes: 0
Views: 53