Jump to content
DZMM

Linux Newbie: How Do I Use Sudo to run this file?

19 posts in this topic Last Reply

Recommended Posts

I've tried and I've tried to run this file, but I can't get it to work:

 

https://home-assistant.io/docs/ecosystem/hass-configurator/

Quote

 

Copy configurator.py to your Home Assistant configuration directory (e.g /home/homeassistant/.homeassistant)

Make it executable: sudo chmod 755 configurator.py

(Optional) Set the GIT variable in configurator.py to True if GitPython is installed on your system. This is required if you want to make use of the Git integration.

Execute it: sudo ./configurator.py

To terminate the process do the usual CTRL+C, maybe once or twice

 

 

When I try to do this I get:

 

root@Highlander:/mnt/user/appdata/home-assistant# sudo chmod 755 configurator.py                       
root@Highlander:/mnt/user/appdata/home-assistant# sudo ./configurator.py
sudo: unable to execute ./configurator.py: No such file or directory

What am I doing wrong?  Thanks

Share this post


Link to post

That script is requiring python3 (first line, #!/usr/bin/python3).  Not installed on unRAID by default and need to use the Nerd Pack to get it.  This part of a plugin or Docker?

Share this post


Link to post

I'm trying to do this within putty.

 

Thanks for the python3 heads up.  I've just added this via need tools but it still doesn't work

Share this post


Link to post

Sudo doesn't apply with Unraid, you're already logged in as root so no need to escalate privileges with sudo.

Share this post


Link to post
On 9/30/2017 at 8:48 AM, CHBMB said:

Sudo doesn't apply with Unraid, you're already logged in as root so no need to escalate privileges with sudo.

hmm still can't get it to work.  I'm parking for now

Share this post


Link to post

In your post above you have appdata in the directory path.  Is your HomeAssistant in a docker container?

 

If so you need to be at a bash prompt in the docker container when you type in your commands and the sudo may or may not be needed there.  So enter the following to get to a bash prompt in your container:

"docker exec -it <docker name> /bin/bash"

Edited by BobPhoenix

Share this post


Link to post
11 hours ago, BobPhoenix said:

In your post above you have appdata in the directory path.  Is your HomeAssistant in a docker container?

 

If so you need to be at a bash prompt in the docker container when you type in your commands and the sudo may or may not be needed there.  So enter the following to get to a bash prompt in your container:

"docker exec -it <docker name> /bin/bash"

Not sure if I'm doing this right:

 

root@Highlander:~# docker exec -it home-assistant /bin/bash ‘configurator.py’
/bin/bash: ‘configurator.py’: No such file or directory
root@Highlander:~# docker exec -it home-assistant /bin/bash -c 'configurator.py'
/bin/bash: configurator.py: command not found
root@Highlander:~# docker exec -it home-assistant /bin/bash  'configurator.py'
/bin/bash: configurator.py: No such file or directory
root@Highlander:~# docker exec -it home-assistant /bin/bash
root@Highlander:/usr/src/app# sudo configurator.py
bash: sudo: command not found
root@Highlander:/usr/src/app# configurator.py
bash: configurator.py: command not found
root@Highlander:/usr/src/app# ./configurator.py
bash: ./configurator.py: No such file or directory
root@Highlander:/usr/src/app#

 

Share this post


Link to post

You first get into the docker with the "docker exec -it home-assistant /bin/bash".  Then go looking with ls command and find your configurator.py command file.  Then copy it to the correct location by looking for the path they want you to put it in.  Then setup permissions correctly.

 

SO:

root@Highlander:~# docker exec -it home-assistant /bin/bash  <-- has colored prompt for me

root@Highlander:~# <find your py file here> <-- has all WHITE prompt if in putty after connecting above (let you know if you connected correctly)

root@Highlander:~# <find your path to copy to here> <-- has all WHITE prompt blah blah blah

root@Highlander:~# cp <your py file> <path>  <-- has all WHITE prompt blah blah blah

root@Highlander:~# <set file permissions here> <-- has all WHITE prompt blah blah blah

root@Highlander:~# exit <-- has all WHITE prompt until you type exit and press enter

root@Highlander:~# <--now back to color prompt

 

If you can't find your py file it means it isn't inside your docker file space you might need to download it inside the docker or use Docker GUI in unraid to map a path to where the file IS.  Then copy it.  To download I believe you can use WGET.

Edited by BobPhoenix

Share this post


Link to post

I don't think it's in the docker container - the configurator.py file is in the appdata folder.

 

I've just tried the following and it still doesn't work:

 

root@Highlander:/mnt/user/appdata/home-assistant# python ./configurator.py
  File "./configurator.py", line 1
    !/usr/bin/python
    ^
SyntaxError: invalid syntax

 

Share this post


Link to post
18 minutes ago, DZMM said:

I don't think it's in the docker container - the configurator.py file is in the appdata folder.

 

I've just tried the following and it still doesn't work:

 


root@Highlander:/mnt/user/appdata/home-assistant# python ./configurator.py
  File "./configurator.py", line 1
    !/usr/bin/python
    ^
SyntaxError: invalid syntax

 

Are you sure you're not missing the # as the first character in the script?

Share this post


Link to post
17 minutes ago, DZMM said:

I don't think it's in the docker container - the configurator.py file is in the appdata folder.

 

I've just tried the following and it still doesn't work:

 


root@Highlander:/mnt/user/appdata/home-assistant# python ./configurator.py
  File "./configurator.py", line 1
    !/usr/bin/python
    ^
SyntaxError: invalid syntax

 

 

Let's rewind this a bit.  Can you explain what you are trying to accomplish?  This script, is it part of a Docker?  If so which one?  Explain what you are trying to accomplish and the forum will be able to better help you.  What I have seen so far is you are trying to run a python script 'in the open' on unRAID.  This is bad.

Share this post


Link to post

 

6 minutes ago, unevent said:

 

Let's rewind this a bit.  Can you explain what you are trying to accomplish?  This script, is it part of a Docker?  If so which one?  Explain what you are trying to accomplish and the forum will be able to better help you.  What I have seen so far is you are trying to run a python script 'in the open' on unRAID.  This is bad.

What I'm trying to achieve is in my original post - I've copied a file configurator.py to my appdata folder which is supposed to add new functionality to the home-assistant docker.  If running it is a bad idea, I'll leave it alone. 

 

Using Unraid is my only real experience of running Linux (I've worked in the internet space for nearly 20 years, but I run products & P&Ls and don't code at all for a living)  so this is all new to me.

 

 

configurator.py

Share this post


Link to post
32 minutes ago, DZMM said:

 

What I'm trying to achieve is in my original post - I've copied a file configurator.py to my appdata folder which is supposed to add new functionality to the home-assistant docker.  If running it is a bad idea, I'll leave it alone. 

 

Using Unraid is my only real experience of running Linux (I've worked in the internet space for nearly 20 years, but I run products & P&Ls and don't code at all for a living)  so this is all new to me.

 

 

configurator.py

 

Reading up on this script it seems it provides a web-based interface to the configuration.  Will need to know what Docker you are using to determine if you can use this script.

 

 

Share this post


Link to post

You will need to be in the Docker container to execute this script.  Copy the 'configurator.py' script to your appdata config directory for the home assistant Docker.  Before moving forward, you need to use a Linux text editor to edit the script and configure for your environment.  Using 'mc' Midnight Commander on unRAID via Telnet/SSH is one way.  Telnet/SSH to unRAID and issue the command below replacing 'container_name' with the name of the container as seen on the Docker tab in unRAID GUI:

docker exec -ti container_name /bin/bash

Assuming your folder map for config is '/config', verify the existence of the configurator.py script in the config folder:

ls /config/conf*.py

After verifying/locating the file, make the script executable:

chmod +x /config/configurator.py

Execute the script:

cd /config
./configurator.py

Follow the instructions from the Hass.io site.

Share this post


Link to post

I think you should have been getting the .py file into the docker itself (not the place where configuration.yaml exists in the appdata location) by going into the console relevant to the HA docker image, then pulling the file in there with a wget, but as far as executing it, I'm stuck there.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.