fixed sudo permission for some commands
This commit is contained in:
parent
08d9f78a35
commit
59ff04775c
2
.github/wiki/script-auto-config-linux.sh
vendored
2
.github/wiki/script-auto-config-linux.sh
vendored
@ -32,7 +32,7 @@ fi
|
|||||||
# Configure sudoers
|
# Configure sudoers
|
||||||
print_colored "$COLOR_BLUE" "Configuring sudoers..."
|
print_colored "$COLOR_BLUE" "Configuring sudoers..."
|
||||||
echo -e "\n# Allow your user to execute specific commands without a password (for EasyComputerManager/HA)" | sudo tee -a /etc/sudoers > /dev/null
|
echo -e "\n# Allow your user to execute specific commands without a password (for EasyComputerManager/HA)" | sudo tee -a /etc/sudoers > /dev/null
|
||||||
echo "$USER_BEHIND_SUDO ALL=(ALL) NOPASSWD: /sbin/shutdown, /sbin/init, /usr/sbin/pm-suspend, /usr/sbin/grub-reboot, /usr/sbin/grub2-reboot, /usr/bin/cat /etc/grub2.cfg, /usr/bin/cat /etc/grub.cfg" | sudo tee -a /etc/sudoers > /dev/null
|
echo "$USER_BEHIND_SUDO ALL=(ALL) NOPASSWD: /sbin/shutdown, /sbin/init, /usr/sbin/pm-suspend, /usr/sbin/grub-reboot, /usr/sbin/grub2-reboot, /usr/bin/cat /etc/grub2.cfg, /usr/bin/cat /etc/grub.cfg, /usr/bin/systemctl poweroff, /usr/bin/systemctl reboot, /usr/bin/systemctl suspend" | sudo tee -a /etc/sudoers > /dev/null
|
||||||
print_colored "$COLOR_GREEN" "Sudoers file configured successfully."
|
print_colored "$COLOR_GREEN" "Sudoers file configured successfully."
|
||||||
|
|
||||||
# Firewall Configuration
|
# Firewall Configuration
|
||||||
|
@ -223,6 +223,9 @@ class Computer:
|
|||||||
return command_result
|
return command_result
|
||||||
else:
|
else:
|
||||||
LOGGER.debug(f"Command failed (raise: {raise_on_error}) : {command}")
|
LOGGER.debug(f"Command failed (raise: {raise_on_error}) : {command}")
|
||||||
|
# LOGGER.debug(f"Output: {command_result.output}")
|
||||||
|
# LOGGER.debug(f"Error: {command_result.error}")
|
||||||
|
|
||||||
if raise_on_error:
|
if raise_on_error:
|
||||||
raise ValueError(f"Command failed: {command}")
|
raise ValueError(f"Command failed: {command}")
|
||||||
|
|
||||||
|
@ -27,23 +27,23 @@ ACTIONS = {
|
|||||||
},
|
},
|
||||||
"shutdown": {
|
"shutdown": {
|
||||||
"windows": ["shutdown /s /t 0", "wmic os where Primary=TRUE call Shutdown"],
|
"windows": ["shutdown /s /t 0", "wmic os where Primary=TRUE call Shutdown"],
|
||||||
"linux": ["sudo shutdown -h now", "sudo init 0", "systemctl poweroff"]
|
"linux": ["sudo /sbin/shutdown -h now", "sudo /sbin/init 0", "sudo /usr/bin/systemctl poweroff"]
|
||||||
},
|
},
|
||||||
"restart": {
|
"restart": {
|
||||||
"windows": ["shutdown /r /t 0", "wmic os where Primary=TRUE call Reboot"],
|
"windows": ["shutdown /r /t 0", "wmic os where Primary=TRUE call Reboot"],
|
||||||
"linux": ["sudo shutdown -r now", "sudo init 6", "systemctl reboot"]
|
"linux": ["sudo /sbin/shutdown -r now", "sudo /sbin/init 6", "sudo /usr/bin/systemctl reboot"]
|
||||||
},
|
},
|
||||||
"sleep": {
|
"sleep": {
|
||||||
"windows": ["shutdown /h /t 0", "rundll32.exe powrprof.dll,SetSuspendState Sleep"],
|
"windows": ["shutdown /h /t 0", "rundll32.exe powrprof.dll,SetSuspendState Sleep"],
|
||||||
"linux": ["systemctl suspend", "sudo pm-suspend"]
|
"linux": ["sudo /usr/bin/systemctl suspend", "sudo /usr/sbin/pm-suspend"]
|
||||||
},
|
},
|
||||||
"get_windows_entry_grub": {
|
"get_windows_entry_grub": {
|
||||||
"linux": ["sudo cat /etc/grub2.cfg | awk -F \"'\" '/windows/ {print $2}'",
|
"linux": ["sudo /usr/bin/cat /etc/grub2.cfg | awk -F \"'\" '/windows/ {print $2}'",
|
||||||
"sudo cat /etc/grub.cfg | awk -F \"'\" '/windows/ {print $2}'"]
|
"sudo /usr/bin/cat /etc/grub.cfg | awk -F \"'\" '/windows/ {print $2}'"]
|
||||||
},
|
},
|
||||||
"set_grub_entry": {
|
"set_grub_entry": {
|
||||||
"linux": {
|
"linux": {
|
||||||
"commands": ["sudo grub-reboot %grub-entry%", "sudo grub2-reboot %grub-entry%"],
|
"commands": ["sudo /usr/sbin/grub-reboot %grub-entry%", "sudo /usr/sbin/grub2-reboot %grub-entry%"],
|
||||||
"params": ["grub-entry"],
|
"params": ["grub-entry"],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user