JWWeatherman / yeticold

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

refactor: Consolidate init scripts into 1 & modernize #74

Closed ghost closed 3 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.

Changed unattended-upgrade to sudo apt upgrade so it spits out status updates.

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.

ghost commented 4 years ago

This is to be committed along with https://github.com/JWWeatherman/yetihosted/pull/7

zimbtc commented 4 years ago

While this is an improvement, why wrap shell commands in python? Wouldn't a shell script be more straight forward? Seems convoluted especially considering you are having a user execute from the command line.

ghost commented 4 years ago

@zimbtc you aren't wrong. This was just a direct upgrade to what was there. Also I hadn't thought about it nor am I skilled in bash scripts but it wouldn't be hard to upgrade this to that in the next version. Thank you

willweatherman commented 3 years ago

This was added into Yeti 2 Thank you.