I won’t be able to answer, but here is some information which will probably help.
The init scripts already run as root. You wouldn’t use sudo unless you want a non-root user to execute something…and then you wouldn’t use a “-s” shell.
By far the best way to deal with this, if placing it at the end of “/etc/rc.local” does not do the job, would be to learn about the systemd method of creating services, where one service depends upon another and the final service only runs after the prerequisites are in place. In your case a prerequisite might be networking is up.
There are a number of interesting files related to this in “/etc/systemd/”. Some of those files are simply symbolic links to the default systemd files in “/lib/systemd/”. Others are copies of the default files, with simple edits. Placing a file here with the same name as an existing “/lib/systemd/” file overrides the original, but deleting that file reverts back to the original. When a system has multiple boot options, then usually a symbolic link is placed somewhere in this location to the choice, but all choices still exist in “/lib/systemd/”…the pick is via the symbolic link.
A service is what you might want to create, with a dependency on another service. A good example is that “multi-user.target” is a text mode boot target, “graphical.target” is a graphical boot mode, and depending on which is configured, then either the “/etc/systemd/multi-user.target.wants/” or the “/etc/systemd/graphical.target.wants/” content will be consulted…requesting the target results in fulfilling the dependencies first. Note that NetworkManager.service is a symbolic link to these, and that multi-user.target (text mode boot) will result in the NetworkManager being up prior to start (or as a side effect of start).
The syntax of the files is simple, and lots of examples there. Once you learn this, if rc.local can’t handle the task, but systemd will actually simplify more complicated boot requirements.
Note that the “systemctl” command is the interface for command line interaction with systemd. For example, to see the status of NetworkManager:
systemctl status NetworkManager