I want to unmount my Hard Drive (which is connected to my Raspberry Pi) with a simple shell_command through Home Assistant:
umount /dev/sda1
It works perfectly if I do it through terminal and it also works perfectly if I change to virtual enviroment in HASS with source /srv/hass/hass_venv/bin/activate and run same command there.
It doesn’t work through script (unmount), it doesn’t work through in single or double quotes, with eject or umount. There is no error in log, nothing happens.
Any help would be really appreciated, I don’t know what I am missing.
I forgot, I added the hass user to the sudousers file (that’s not the right now, but I can’t login right now to check). Otherwise sudo is asking for a password I think.
I tried to set umount commands on command_line switches as command_on and commands defenitely fail (with or without sudo). This time they are properly logged:
no it’s a sudo file that allows hass to use sudo without challenging for a password. Look at the man pages for sudo it should point you there. If not, I’ll be able to check my system in a couple of hours and can reply with the information.
Thank you @turboc for your help. I added hass to sudoers and now everything is working!
@rpitera Thank you for pointing me to github discussion. I agree that adding hass to sudoers is not the right way to solve the problem, I don’t know any other way to do it. Also, all future commands with sudo wil now work as well, I won’t have to deal with specific problems and permissions every time.
SmartValley,
For home use that is probably fine. But in the business world, using sudo like we have set it up allows normally unauthorized users to install applications that could impact everyone on the system, instead of just being limited to their account.
I think the best solution will be for someone with a lot more unix/linux and HA knowledge than me, to figure out how to let hass run apps in needs to run without having to use sudo, but also making it so that we can work in the system without having to go into the hass user to do everything. I don’t know how to do it, like it said, it will take someone with a lot more unix/linux and HA knowledge than me to pull it off.
I had to point you to that discussion or I wouldn’t be doing my job as a mod. As long as you understand the implications, then the evaluation of the risk is up to you - and BTW, not judging! I just wanted to make sure that I made you aware of it.
I originally did a similar thing with perms on my certificates until I could find a proper solution so I know where you’re coming from.