Itai-Nelken/Pi-Assistant

Static IP

slashtechno opened this issue · 17 comments

Please make a tool that sets a static IP for the Raspberry Pi. That would be so useful because I believe there are no scripts that I have heard of that set a static IP.

I'll try, thanks a lot for the suggestion!

@Itai-Nelken I have made a Python script that should work.
Check it out!
https://github.com/slashtechno/PiStaticIP

@slashtechno thanks a lot, do you mind if I rewrite it as a bash script (of course I'll add you to the credits)?

@Itai-Nelken Can the bash script pull from my repo, run it, then delete the file?
That way it pulls the latest script.

@Itai-Nelken Can the bash script pull from my repo, run it, then delete the file?
That way it pulls the latest script.

I prefer it to be a bash script, and I want all the scripts to be on my main repo, but if you really want I suppose I could add it that way at least temporarily.

@Itai-Nelken I am planning to update this some more so yes, I would really like it to pull from my repo.

Can the Bash script look something like this?

#!/bin/bash
wget https://raw.githubusercontent.com/slashtechno/PiStaticIP/main/staticIP
python3 staticIP
rm staticIP

I don't know, your script is good and I didn't completly test it yet but I'm pretty sure it will work.
but
as I said I want all the code to be on my main repo and pull any needed files (not scripts) from my Pi-Assistant-files repo.
so this is what I think I'll do:
I'll wait for you to finish your script, translate it to bash and add you to the credits, and then add the feature.
is that ok with you? you can take as much time as you need to finish the script, I also have a lot of work I want to do for v1.5.0 (see https://github.com/Itai-Nelken/Pi-Assistant/projects/2) and it will take some time.
---------------------------------------------------------------------------------------
I also might add a "community scripts" category that can pull the script from your repo.
=================================================================

personally I prefer the first option also because "community scripts" only might be added, and even if I do add it it might be in another year maybe and also because I still prefer to keep all the scripts bash.
---------------------------------------------------------------------------------------

what do you prefer?

what do you prefer?

I would like this to be added to the community scripts.

it might be in another year maybe and also because I still prefer to keep all the scripts bash.

Can the bash script

  1. Pull my script
  2. Run script with Python3
  3. Delete my script
    ?
    That way the the bash script is the only thing that needs to be added.

Can the bash script

  1. Pull my script
  2. Run script with Python3
  3. Delete my script
    ?
    That way the the bash script is the only thing that needs to be added.

I'm not so sure, as I said I want all scripts to be from my main repo meaning that theoretically all scripts can be run offline (though most of them won't work offline).


you know what? I'll think a bit more about it and meawhile you can finish adding stuff to your script and I will probably add 'Community scripts' if I find a few more scripts that can go there.

anyway here are some suggestions for your script:

  • check if script is being run as root automatically (in bash, check if $UID = 0).
  • read the IP address automatically instead of asking the user to type it in.

also here is another concern I have: if Pi-Assistant pulls the script from your repo, the script will ask to press enter if you are not running as root, Pi-Assistant obviously won't run the script as root, so for the script to be "eligible" it needs to check if its being run as root without having the user interact at all unless the script is being run as root.

I'll be really happy to add your script to 'Community scripts' if I find a few more scripts that can go there and once you add the 2 suggestions I suggested above.


I hope you understand my concerns.

Okay, thank you, I think I should

  1. Add (in python) os.system("sudo su pi")
  2. run hostname -I and get result, convert it to string.

Getting router IP may be a problem however...

@slashtechno hows your progress on the script?
I decided to add the 'Community scripts' category, so I have no problem pulling the script from your repo as long as its downloaded while installing Pi-Assistant and will get updated when Pi-Assistant updates if I approve a new version of your script.

@Itai-Nelken I can get it to work without the sudo prompt but I can not get router IP and such without user input

That is it as long as you add instructions on how to get the router ip

@Itai-Nelken I already have instructions built into the program. The program displays the the device's LAN IP as well as the router IP. The user just needs to type it in.

great! I will add it once I come round to adding all the things here: https://github.com/Itai-Nelken/Pi-Assistant/projects/2

Thanks @Itai-Nelken. Just so you know there is a chance that I change the name of the repo. If I do I will create a new issue.

I'm closing this issue as I have moved on to other things and don't have the time or interest to keep working on Pi-Assistant.