Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in line 54 #59

Open
geru-github opened this issue Feb 12, 2024 · 10 comments
Open

Error in line 54 #59

geru-github opened this issue Feb 12, 2024 · 10 comments

Comments

@geru-github
Copy link

geru-github commented Feb 12, 2024

File mmdvmhost.service

The shell variable
ipvar
should be protected with double quotes.
In my case this variable was empty and the comparison was syntactically wrong and the script failed.

MW0MWZ pushed a commit that referenced this issue Feb 12, 2024
@MW0MWZ
Copy link
Collaborator

MW0MWZ commented Feb 12, 2024

please review the commit above.

@geru-github
Copy link
Author

Okay so far, but I've seen two other potential problems.
The assigned initial value of
ipVar
in line 24 is different from the assignment in line 56. I don't see why.
And the comparison in line 54 with " " (one space) is wrong. An empty string is returned by
hostname -I
if no address is assigned.

Sorry, should have seen it earlier...

@MW0MWZ
Copy link
Collaborator

MW0MWZ commented Feb 13, 2024

line 24 of what file? this is used a few times, can you give me the file so that I can follow along too.

@geru-github
Copy link
Author

mmdvmhost.service

@MW0MWZ
Copy link
Collaborator

MW0MWZ commented Feb 13, 2024

${ipVar} is the same as $ipVar, nothing wrong with that bit.
Line 56 isn't a test, it's re-setting the variable, so those two are OK.

I'll double check the output for hostname with and without network.

@geru-github
Copy link
Author

File mmdvmhost.service:
The first remark above refers to line24

ipVar=`hostname -I | cut -d' ' -f1`

line 56 is

ipVar=`hostname -I`

why the cut? Empty is empty for line 54

until [ "${ipVar}" != " " ]; do`

or actually it is not because
the right hand operand is a non-empty string containing one space character.

So the comparison is always true because either "" != " " (empty string is not equal one space character)
or "1.2.3.4" != " "

@geru-github
Copy link
Author

I checked it, In my linux/pi-star version
ifconfig wlan0 down
echo -n $(hostname -I)|hd
returns nothing.
vvv=$(hostname -I)
echo ${#vvv}
returns zero

@geru-github
Copy link
Author

geru-github commented Feb 13, 2024

I checked on my pi-star version the

  • consequences of "" in the until expression
  • and the removal of the cut command

It works for both cases, local AP mode and Wifi connected to AP.

I haven't checked the timeout value of the mmdvmhost systemd service config which should be way higher than the automatic AP-mode switch timeout.

There might be now conflict potential here because the until loop was always left.

@MW0MWZ
Copy link
Collaborator

MW0MWZ commented Feb 13, 2024

This is a solution to an OLD problem, and the concept of "wait for an IP" might not matter so much any more.
I might not make changes today, but I'll look at what can be done with this. MMDVMHost should not care for example if the local AP is running or not, and maybe a better solution is to have systemd wait until the network target is reached before starting the radio related services. if there is no working network - it should not matter if MMDVMHost is running or not.

@geru-github
Copy link
Author

You're right, it's not urgent and putting everything in systemd's hands is a good idea. Very flexible that piece.

Nevertheless I tested another non-standard case with the changes above made to mmdvmhost.service script (cut removed, empty string comparison):

  • Extern AP is off
  • Booting Pi-star
  • waiting for Pi-star AP coming up
    -> two ip addresses returned by hostname -I
    -> that was probably the reason for the cut in the old days
  • Pi-star AP (50.1) is up and running
  • now switching on the external AP
  • after a while the external AP is connected, but the local AP (50.1) is still there.
  • Display is not updated accordingly
  • now it gets erratic. External AP connection is coming constantly on and off and on....

Another reason to change the systemd config...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants