/sbin/wifi restart

why does below command works when it's not documented? I cannot find any reference to restart

wifi restart

root@repeater:~# wifi --help
Usage: /sbin/wifi [config|down|reload|status]
enables (default), disables or configures devices not yet configured.

I'm assuming it's likely due to a handful of reasons, with the main being the OpenWrt Wiki site relies on the community itself to create and add content.

  • I'm not that knowledgeable about what happens on the backend when
    wifi restart versus /etc/init.d/network restart or service network restart
    is utilized, so it could be restarting the network, versus just wifi, is preferred.

@jow, @tmomas, @richb-hanover, and/or @bobafetthotmail will be able to provide better information and guidance on this than I can.

Backward compatibility?

There's also undocumented reload_legacy-command:

# grep -C5 wifi /etc/init.d/network
reload_service() {
        ...
        /sbin/wifi reload_legacy
        ...
}

stop_service() {
        /sbin/wifi down
        ...
}

service_running() {
         ...
        /sbin/wifi reload_legacy
}
1 Like

I do not think that wifi restart actually works (in the current master).
It just prints the usage information, just like all other unknown strings.

root@router2:~# wifi relsafasfdas
Usage: /sbin/wifi [config|up|down|reload|status]
enables (default), disables or configures devices not yet configured.

root@router2:~# wifi restart
Usage: /sbin/wifi [config|up|down|reload|status]
enables (default), disables or configures devices not yet configured.

root@router2:~# which wifi
/sbin/wifi

the behaviour is quite clearly written in the actual "wifi" script.

3 Likes

I have no idea if this was a bug or intentional, but in the next major OpenWrt version (or in the development snapshot images) you won't find this behaviour anymore, as said by @hnyman .

The wifi tool (actually a script) did the "up" action on any unknown command for many years. "restart" is not a recognized command, it will do the same on wifi abcdefg.

If you see the last commit that modified that file, you see that this behaviour was fixed to be more sane and consistent, now it will print usage if there is an unknown command, and it will execute the "up" action if no command was specified.

3 Likes

Looking at the source code release branches, the old behaviour (any unknown argument is "up"), is still there in 18.06 and 17.01, so in the older releases "restart" still works like "up".

If wifi is already up when you run "wifi" with no parameters, the wifi system will be stopped and restarted.

This is what I'm seeing also. Does it reload the config before start?

Yes if you have changed the configuration it will start with the new configuration.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.