FIX: sudo_fix.sh not working on armbian

According to https://github.com/Arksine/moonraker/issues/241

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel 2021-12-04 15:44:09 +01:00 committed by Eric Callahan
parent 6852982406
commit f22e16d8cc
1 changed files with 18 additions and 13 deletions

View File

@ -53,12 +53,12 @@ Cmnd_Alias SHUTDOWN = /sbin/shutdown now, /sbin/shutdown -h now, /bin/systemctl
Cmnd_Alias APT = /usr/bin/apt-get Cmnd_Alias APT = /usr/bin/apt-get
Cmnd_Alias SYSTEMCTL = /bin/systemctl Cmnd_Alias SYSTEMCTL = /bin/systemctl
%GROUPNAME ALL=(ALL) NOPASSWD: REBOOT, SHUTDOWN, APT, SYSTEMCTL %GROUPNAME ALL=(ALL) NOPASSWD: REBOOT, SHUTDOWN, APT, SYSTEMCTL
#EOF #EOF
report_status "\e[1;32m...done\e[0m" report_status "\e[1;32m...done\e[0m"
} }
@ -70,17 +70,22 @@ update_env()
verify_syntax() verify_syntax()
{ {
report_status "\e[1;33mVerifying Syntax of ${SUDOERS_FILE}\e[0m\n" if [ -n "$(whereis -b visudo | awk '{print $2}')" ]; then
if [ $(LANG=C visudo -cf $SCRIPT_TEMP_PATH/$SUDOERS_FILE | grep -c "OK" ) -eq 1 ]; report_status "\e[1;33mVerifying Syntax of ${SUDOERS_FILE}\e[0m\n"
then
VERIFY_STATUS=0 if [ $(LANG=C sudo visudo -cf $SCRIPT_TEMP_PATH/$SUDOERS_FILE | grep -c "OK" ) -eq 1 ];
report_status "\e[1;32m$(LANG=C visudo -cf $SCRIPT_TEMP_PATH/$SUDOERS_FILE)\e[0m" then
else VERIFY_STATUS=0
report_status "\e[1;31mSyntax Error:\e[0m Check File: $SCRIPT_TEMP_PATH/$SUDOERS_FILE" report_status "\e[1;32m$(LANG=C sudo visudo -cf $SCRIPT_TEMP_PATH/$SUDOERS_FILE)\e[0m"
exit 1 else
report_status "\e[1;31mSyntax Error:\e[0m Check File: $SCRIPT_TEMP_PATH/$SUDOERS_FILE"
exit 1
fi
else
VERIFY_STATUS=0
report_status "\e[1;31mCommand 'visudo' not found. Skip verifying sudoers file.\e[0m"
fi fi
} }
install_sudoers_file() install_sudoers_file()
@ -148,7 +153,7 @@ if [ -e "$SUDOERS_DIR/$SUDOERS_FILE" ] && [ $(sudo cat /etc/gshadow | grep -c "$
check_update_sudoers_file check_update_sudoers_file
report_status "\e[1;32mEverything is setup, nothing to do...\e[0m\n" report_status "\e[1;32mEverything is setup, nothing to do...\e[0m\n"
exit 0 exit 0
else else
if [ -e "$SUDOERS_DIR/$SUDOERS_FILE" ]; if [ -e "$SUDOERS_DIR/$SUDOERS_FILE" ];
@ -181,4 +186,4 @@ fi
update_env update_env
clean_temp clean_temp
exit 0 exit 0