[SOLVED] How to set python scripts


AinzOolGown

Recommended Posts

Hi everyone !

 

My ISP do not offer static IP, so regularly i need to update my Gandi DNS with the new IP.

 

To automate this task, i found a promising script here :

https://github.com/Danamir/dyn-gandi

 

It work on my Windows VM i used for testing it but unRAID seems to handle this differently

(of course i enabled Nerd Tools's Python/pip/setuptools)

 

But i can't get it to work :/
Maybe there is some magic ?

 

Followed some posts saying to use "user scripts" but this script contains multiple files and i don't know how to bring them together

Also, i need to CRON this too ^^

 

Can any kind soul lend me an hand, please ? :)

 

Thanks in advance !

Edited by AinzOolGown
Solved
Link to comment

First you will want to make sure your source is saved somewhere on the array. You will want to use the optional Virtual environment setup steps as well. Rather than cron you will want to use a user script to call the program. Create a new user script and add something like this as the content

/mnt/user/<Some-User-Share>/<dyn-gandi-path>/.env/bin/dyn_gandi --log /var/log/dyn-gandi.log

Use schedule functionality of the user script plugin to run the script on the desired schedule. 

 

I typically recommend running python scripts within a docker container rather than directly on unRAID. The process for using a user script is the same but python and your source are built into a docker container and the user script is used to launch the container on a schedule.

Link to comment

Thanks Primeval :)

 

4 minutes ago, primeval_god said:

I typically recommend running python scripts within a docker container rather than directly on unRAID. The process for using a user script is the same but python and your source are built into a docker container and the user script is used to launch the container on a schedule.

Could you recommand me a good one please ? :)
(Searched on Apps, but no luck apparently)

Edited by AinzOolGown
Link to comment
On 9/28/2021 at 7:36 PM, AinzOolGown said:

Thanks Primeval :)

 

Could you recommand me a good one please ? :)
(Searched on Apps, but no luck apparently)

Oh, maybe you wanted to say "install python within whatever docker container you have" more than "set a python only docker container that you can broke all you want without having to worry about the main purpose of the said container" ? 😁

 

EDIT:

All up and working ^^

Asked a dev friend for the docker's part and after some tries, have a python docker scheduled with user script !

 

Thank you very much :)

 

EDIT2:

For other newbs like me, if you want a python docker :

I'll take as exemple the python script i wanted to use (dyn-gandi), so download it and don't forget to copy config.ini-dist to config.ini, then add your Gandi info and save.

 

1- You need to add a file named "Dockerfile" in the folder with similar content :

FROM python:3.9.7-alpine3.14
WORKDIR /app
COPY . /app
RUN python setup.py develop
CMD ["python", "dyn_gandi.py"]

 

2- Move this folder (dyn-gandi-1.***) somewhere in unRAID (i personnaly placed it in /mnt/user/appdata, with other dockers)

 

3- cd into this folder

 

4- type this command :

docker build -t dyn-gandi .

(this will build the docker's image)

 

5- When the process is over, type :

docker run dyn-gandi

(this will build the docker's container, based on the image)

If all this runned well, you should see a line with your current IP

 

6- In unRAID's docker tab, you should see 2 more lines, the python alpine one and a new docker. Mine looks like this :

docker.thumb.PNG.4288feedf4851e5e4953738422fc53f4.PNG

(copy the container's ID, here d224bb535b10)

 

7- Install "User Script" plugin if you don't already have it (use the Apps tab and search function)

 

8- Go in the plugins tab, User Script

 

9- "Add new script" button and paste this:

#!/bin/bash
docker start d224bb535b10

Don't forget to replace d224bb535b10 by your container's ID :)

And "save change" button

You can set a description and a name for this script too if you want

Set a schedule that please you

Click on Apply

 

10- done ! ;)

Edited by AinzOolGown
Tuto
Link to comment
  • AinzOolGown changed the title to [SOLVED] How to set python scripts
1 hour ago, primeval_god said:

Yeah sorry I was slow on the response here, what you did is exactly what i was recommending, the official python base image (which you used) was what i was thinking.

 

No problem, don't worry ;)
Glad i've made the right choice, that was just guessing and asking for help ^^

 

Thank you nonetheless Primeval :)

Link to comment

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.