Please test these 2 scripts

Forum Forums antiX-development Development Please test these 2 scripts

  • This topic has 10 replies, 4 voices, and was last updated Sep 21-1:28 pm by olsztyn.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #67065
    Forum Admin
    anticapitalista

    On antiX-21, the ~/.desktop-session/startup file has this option

    ##Check for connectivity. If no network connection is detected, activate wi-fi networks, open connman and go straight to the wi-fi connections tab…
    network-check-antix &

    This simple script has been tested and seems to work well.

    There is another, more detailed script included by default on antiX-21 called network-readiness-state

    Unlike NCA, NRS provides on screen info while waiting for a network connection to be established. On my systems this period can vary considerably, even on separate boot-ups of the same machine. That was one reason for including the script start options, i.e. to cater for fine tuning.

    As far as I can tell, NCA works only in a GUI environment and is hard coded to start connman stuff. NRS reports in both GUI and non-GUI environments. That is to cater for non-GUI stuff I have am working on for antiX. NRS can also call an alternative network simply by adjusting the boot-up script start command.

    Can you try it out (add this network-readiness-state & to ~/.desktop-session/startup file and make sure to not use the other eg #network-check-antix &) and post thoughts, comments, preference in this thread.

    Thanks.

    Philosophers have interpreted the world in many ways; the point is to change it.

    antiX with runit - leaner and meaner.

    #67068
    Member
    Xecure
    Helpful
    Up
    0

    The script keeps running in the background even if I close the informational yad window until it does its 60 checks.

    It seems to properly detect when I am connected using ceni or connman.

    I tried to fake a mis-configured resolv.conf (removed the contents of the file) and the network check still says I am connected and OK, so the check seems to be only to the access point.
    not-ready-resolv
    Also, removing /etc/resolv.conf has the same results.

    I understand this script is informational only, and doesn’t provide a means to connect to any network, correct? It is just to check if the system is connected to the access point and not to the internet.

    • This reply was modified 1 month ago by Xecure.

    antiX Live system enthusiast.
    General Live Boot Parameters for antiX.

    #67089
    Forum Admin
    SamK
    Helpful
    Up
    0

    The purpose of the network-readiness-state (NRS) is to provide feedback about the LAN and optionally run a command such as starting a network manager. It is designed to run as part of the boot-up process.
    .
    .
    .
    To Test
    In ~/.desktop-session/startup
    Disable network-check-antix and replace it with the following command, then re-boot.

    # Report whether the local network is ready
    network-readiness-state &

    The script checks for:
    * NIC Name
    * Local IP Address
    * Network Gateway Address

    If those are found (i.e. the network is available) on the first pass, the script exits without reporting anything on screen.

    If those are not found (i.e. the network is not available) the script will by default:
    • Display a report on screen
    • Update the report every 0.5 seconds
    • Repeat the search 60 times
    Optionally all these can be set by appending switches to the command ref
    network-readiness-state --help

    When the search fails to find the network the script sets an exit code of 1. If wanted this can be used to trigger another program by simply appending it to the script command e.g.
    network-readiness-state ; [[ $? -ne 0 ]] && command-to-run

    It is done this way to give added flexibility, i.e. it can start any other command or network manager rather that automatically starting (hard-coding) one, which is not always the correct way to proceed. For example it has been noticed the time required to set up the network can vary considerably on the same kit and allowing extra time or another reboot resolves the matter, hence the script command switches.

    The script works in both X and non-X environments this caters for the different ways in which antiX can be started and run.

    #67095
    Member
    Xecure
    Helpful
    Up
    0

    To Test
    Disable network-check-antix and replace it with the following command, then re-boot.

    $ network-readiness-state --help
    
    network-readiness-state version 1.0

    If I have set the wireless configuration and reboot, the window doesn’t pop up (that is good).
    When I remove the wireless configuration and reboot, I see a window with a countdown from 60 to 1 telling me I have no connection (nothing else). When it reaches 1 it stays open.

    This current version only does this.

    If I close the window before the countdown ends, the process is still running in the background. That is what I reported. The expected behavior (for me) is for the checks to stop as soon as I close the window, but it is still running in the background. If this is the expected behavior, then ignore this report.

    antiX Live system enthusiast.
    General Live Boot Parameters for antiX.

    #67100
    Forum Admin
    SamK
    Helpful
    Up
    0

    In a terminal here the command network-readiness-state –help produces the following. Did you truncate your example for brevity? The command was suggested as a way to see the available switches which can fine tune the behaviour of NRS

    network-readiness-state version 1.0
    Search for a connected network.
    
    Usage: 
       network-readiness-state [Options]
    
    Options:
       --searches=   Maximum number of failed searches to conduct
       --delay=      Period in seconds between each search
       --report      Force showing of the feedback report
                     This bypasses the no feedback on first search
       --wait=       Period in seconds before automatically closing report
                     window following a successful search 
       --help        Show this output
    
    Summary:
       Search for an operational network interface and a reachable gateway.
       The script decides whether to run once or multiple times.
    
       When a connected network interface is detected on the first search
       the script immediately exits with no on-screen feedback.
       
       When the first search is unsuccessful, it is repeated every 0.5
       seconds for a maximum of 60 searches. If a connected network is
       detected during that period, the script immediately exits.  While the
       search continues, on-screen feedback is provided for each cycle.
       
       Exit code 0 is returned upon detecting a connected interface.
       Exit code 1 is returned upon not detecting a connected interface.
                   
    Configuration:
       None
      
    Environment:
       Works in both console and GUI (X) environments. 
      
    Requires:
       awk bash cat ip mkfifo rm sleep wmctrl yad

    If I have set the wireless configuration and reboot, the window doesn’t pop up (that is good).
    When I remove the wireless configuration and reboot, I see a window with a countdown from 60 to 1 telling me I have no connection (nothing else). When it reaches 1 it stays open.

    That is intended. It acts as a visual indicator to the user. That will be helpful in cases where a command to start a further script/prog is not appended to the NRS start command.

    Have you tried appending a command to start a network manager then force the network to fail as shown in the earlier post?

    If I close the window before the countdown ends, the process is still running in the background. That is what I reported. The expected behavior (for me) is for the checks to stop as soon as I close the window, but it is still running in the background. If this is the expected behavior, then ignore this report.

    That is expected behaviour. It is unclear what value will be obtained by closing the window while a network is not detected and the window is reporting that and updating the report every 0.5 seconds (default frequency). It is entirely possible the network will be detected after you close the window. To do that the check for an available network must continue until one is detected or the search cycle count is reached.

    #67111
    Member
    Xecure
    Helpful
    Up
    0

    n a terminal here the command network-readiness-state –help produces the following. Did you truncate your example for brevity?

    I truncated just to show the version, to make sure this is the correct version we should be testing.

    Have you tried appending a command to start a network manager then force the network to fail as shown in the earlier post?

    yes:
    network-readiness-state ; [[ $? -ne 0 ]] && cmst -d
    but the cmst -d command doesn’t run until the countdown ends. If closing the window would stop the countdown and return 1 as error state, then cmst would launch immediately, instead of me having to wait for the countdown to end. Also, nothing else loads until this startup command ends in ~/.desktop-session/startup )all command after the above will not run until this one ends).

    Could a – -command option be a better option to append the command instead of how it is now set?
    network-readiness-state --command="cmst -d" &
    This way, both the countdown and command can run at the same time (if return 1 inside the script) and the other startup commands can continue to run in parallel.

    • This reply was modified 1 month ago by Xecure.

    antiX Live system enthusiast.
    General Live Boot Parameters for antiX.

    #67132
    Forum Admin
    SamK
    Helpful
    Up
    0

    …nothing else loads until this startup command ends in ~/.desktop-session/startup )all command after the above will not run until this one ends).

    Good catch, I made an error. The command should be terminated by and ampersand (&). That will allow subsequent commands to run without waiting.

    …but the cmst -d command doesn’t run until the countdown ends. If closing the window would stop the countdown and return 1 as error state, then cmst would launch immediately, instead of me having to wait for the countdown to end.

    Again it is unclear why anyone will want to close the report window when an available network has not been found in the first few checks. Are you presuming that because the network is not found within a very few checks, running cmst will always be required? That is not the case. It has been observed the time it takes a given laptop to establish a network connection can vary markedly between each boot-up e.g. between 0 seconds and 20ish seconds have been seen on consecutive boot-ups. Often what is required is a longer period for the system to establish the connection to the network. Once the connection has been made, NRS can detect it.

    The NRS defaults of maximum 60 checks with a 0.5 second delay between each check was chosen to give a reasonable opportunity for a wide range of kit to set up a network connection. It is an arbitrary (best guess) set of defaults which are easy to modify.

    If you want to control the time allowed for a network to be detected use the NRS –searches switch.
    network-readiness-state --searches=10 --report ; [[ $? -ne 0 ]] && cmst -d &

    That will complete a maximum of 10 search cycles, using the default delay between searches of 0.5 seconds, so will take a maximum of 5 seconds before it goes on to run cmst (although that may be unnecessary). Of course if a network is detected before 5 seconds have elapsed, NRS will not conduct any further searches and will quit. The –report switch is included for convenience and may be omitted if you wish. Additionally note a trailing ampersand is included to address the item you mentioned.

    The intention behind the design of NRS is to cover a range of use cases:
    • run cmst,
    • run an alternative network manager,
    • run no network manager,
    • run in an X (GUI) environment,
    • run in a a non-X (text) environment,
    • allow it to run to suit user preferences via switches.
    The design tries to cater for all.

    • This reply was modified 1 month ago by SamK.
    • This reply was modified 1 month ago by SamK.
    #67145
    Member
    Xecure
    Helpful
    Up
    0

    Good catch, I made an error. The command should be terminated by and ampersand (&). That will allow subsequent commands to run without waiting.

    It still wont work. As I explained above, it will still stop the startup of other commands until the countdown is done, because the command after [[ $? -ne 0 ]] is waiting for the result of the countdown. Test it yourself if you don’t believe me. appending the command in an option instead would launch the program’s countdown without disrupting the startup commands.

    Again it is unclear why anyone will want to close the report window when an available network has not been found in the first few checks. Are you presuming that because the network is not found within a very few checks, running cmst will always be required?

    Imagine a new user launches the system and finds this window, be it during 30 seconds (60 iterations) or 5 seconds (10 iterations), informing them there is no connection. They will say “I know, I haven’t set up the wifi yet. How do I set up the wifi?” My first response (maybe only mine and not others) is to close the window, as it doesn’t give me any option to connect to the internet. But closing the window does nothing, and while exploring the system, suddenly (after the countdown which the user doesn’t know it is being performed in the background), a window pops up giving the option to connect to the wifi. “Why the heck did this not pop up immediately?”, the user would say. If closing the window would stop the countdown and immediately launch the appending program, then at least they would get immediate feedback for their clicking, and not think “gosh, the system is so slow the connection window didn’t appear until X seconds after booting. I am going back to Linux Mint, which is faster than this system”.
    This is what I imagine would be the user’s perspective.

    I think my perspective is clear, and this script needs other users’ feedback, more realistic than mine (which already knows how to connect to stuff in antiX).

    antiX Live system enthusiast.
    General Live Boot Parameters for antiX.

    #67166
    Forum Admin
    SamK
    Helpful
    Up
    0

    @Xecure
    It is not that I disbelieve you, just that I now figured out we we not using the same tests. You were using a basic command without switches and running cmst and I was using something different.

    When I use the same as you I can recreate the symptoms you describe. I’ll have a look at a different way of backgrounding the command. Thanks for sticking with it.

    #67592
    Member
    Xecure
    Helpful
    Up
    0

    SamK. Could you add an option to network-readiness-state for “–no-gui” (or something similar)?
    I would like to use this command without the window popping up. I find the window distracting.
    I really appreciate the existence of this script, but I find the GUI to be too distracting and confusing for users who don’t know what is going on.

    antiX Live system enthusiast.
    General Live Boot Parameters for antiX.

    #67605
    Member
    olsztyn
    Helpful
    Up
    0

    Per Xecure’s request I have used script:

    ‘$(network-readiness-state –searches=10; [[ $? -ne 0 ]] && network-check-antix) &’

    for CMST in session startup.

    Having rebooted repeatedly the fifth time CMST error occurred, preceded by Network readiness State window showing 10 lines of ‘Network interface not ready’ in sequence 10 to 1.
    This CMST error is erratic and can happen unpredictably roughly in one out of every five reboots, based on experience.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.