JWWeatherman / yeticold

https://yeticold.com
Other
67 stars 24 forks source link

refactor: Consolidate init scripts into 1 & modernize #73

Closed ghost closed 4 years ago

ghost commented 4 years ago

NOTE: This will require slight modification to the commands given at cold.yeticold.com, disc.yeticold.com, warm.yeticold.com, etc... (all of them).

The command would be: py ~/yeticold/initialize.py MODE where MODE is one of the following: YetiColdPrimary YetiColdSecondaryCreate YetiColdSecondaryRecover YetiHot YetiWarm BitcoinCoreOfflinePrimary BitcoinCoreOfflineSecondary

Instead of having many files for different paths with substantially the same code, all the common code was combined into a single script. The differences were added as switches based on an input argument to the script.

Changed apt-get to apt because apt is suited better for end users and has a nice graphical progress bar.

Error handling for the arguments was included. Where certain commands could result in errors printed to the terminal, the stderr output was passed to /dev/null to keep the terminal free from worrisome errors that mean nothing to the user.

The system bash calls were also modernized with the latest recommended practice as of Py3.5. This means using subprocess.run wherever possible. Part of the proper use of this is to the returncode for success or failure, and to explicitly check (or not check) for errors in the execution of the command. In this case, all are false. This is referenced in: https://github.com/PyCQA/pylint/issues/2848

Also included are pauses in script execution to allow time for the flask webserver to fully load before loading the first html page. This removes the need for the user to manually reload the webpage (this comes across as a broken user experience).

Finally, originally the many scripts all had the snap install network-manager. This was unnecessary and undesirable for a couple reasons:

  1. Only the 2nd machine in YetiCold needs to have the network disabled.
  2. In Ubuntu 18 and 20, network-manager is already installed. There is no need to install it with SNAP and doing so silently disables the network and leaves the user wondering what's wrong. They would need to reboot in order for the network to work so the installation can continue.

In the future, this practice should be reconsidered for a different approach, even if manual with specific directions and warnings.