Giter Club home page Giter Club logo

dotgather's Introduction

dotGather

                         ___      ,----..                  ___      ,---,                        
      ,---,            ,--.'|_   /   /   \               ,--.'|_  ,--.' |                        
    ,---.'|   ,---.    |  | :,' |   :     :              |  | :,' |  |  :                __  ,-. 
    |   | :  '   ,'\   :  : ' : .   |  ;. /              :  : ' : :  :  :              ,' ,'/ /| 
    |   | | /   /   |.;__,'  /  .   ; /--`    ,--.--.  .;__,'  /  :  |  |,--.   ,---.  '  | |' | 
  ,--.__| |.   ; ,. :|  |   |   ;   | ;  __  /       \ |  |   |   |  :  '   |  /     \ |  |   ,' 
 /   ,'   |'   | |: ::__,'| :   |   : |.' .'.--.  .-. |:__,'| :   |  |   /' : /    /  |'  :  /   
.   '  /  |'   | .; :  '  : |__ .   | '_.' : \__\/: . .  '  : |__ '  :  | | |.    ' / ||  | '    
'   ; |:  ||   :    |  |  | '.'|'   ; : \  | ," .--.; |  |  | '.'||  |  ' | :'   ;   /|;  : |    
|   | '/  ' \   \  /   ;  :    ;'   | '/  .'/  /  ,.  |  ;  :    ;|  :  :_:,''   |  / ||  , ;    
|   :    :|  `----'    |  ,   / |   :    / ;  :   .'   \ |  ,   / |  | ,'    |   :    | ---'     
 \   \  /               ---`-'   \   \ .'  |  ,     .-./  ---`-'  `--''       \   \  /           
  `----'                          `---`     `--`---'                           `----'            

Collection and dispersal script for configuration files, allowing you to manage the configurations for multiple machines in the same git repo.

Warning: Use at your own risk, someone probably did this in a better way and has a more mature project. I rolled my own because you know software people shrug.

What it does:

  • Allows to manage the configurations for many machines in one git repo

  • Installs the script in a directory where gathered config files will be stored

  • On setup init the directory with a git repo

  • Create a subdir structure to store configuration files for the specific machine we are running on

    • The directory name is based on host by default (There is an option to override)
  • Create a file with user inputted paths for configs that we want to target for collection

  • Gather target config files, new incoming changes can then be managed with git

  • Disperse gathered configs to their target directories

    • To clone machines configuration to other machines or recover to previous state etc.
  • UNDO a disperse as long as target files have not changed since disperse

Installation

Starting from scratch

Download the dotgather.py file to anylocation on your desired machine.

Execute the script in install mode with python and pass in the desired dir path for your new dotfile repo:

python3 ./dotgather.py --install INSTALL_DIR_PATH

Adding a new machine to an existing dot repo

If you already made a repo for some machines and you want to add a new machine to that repo just clone the repo to the new machine. Add the QoL changes to your shell config if desired. Follow the normal machine setup process from there.

QoL

To be able to run the script command without chaning to the repo dir:

  • Add INSTALL_DIR_PATH to you system path
  • Along with to you .rc file
    • Specific rc file depends on you chosen shell, if you are using a weird one env. var. syntax might be different, but if you are you already knew this
export DOTGATHERHOME=WHAT_EVER_YOUR_CHOSEN_DOTFILE_REPO_DIR_PATH

Upgrade

Download a new version of dotgather.py file to anylocation on your desired machine.

Execute the script in install mode with python and pass in the desired dir path for your existing dotfile repo:

python3 ./dotgather.py --install INSTALL_DIR_PATH --upgragde

Usage

Setup dotfile management for a new machine

After installing run:

dg --setup

This will create the nessacry dir. structure and prompt you to input paths for the configs you want to target.

You can also just skip the prompted input and just edit the HOST_NAME_DIR/dotfilelist file in you favorite editor. And you better be using Vim key-bindings!

Gather

dg --gather

NOTE: Undos for the specific host/machine are removed on issuing a gather, it wouldn't make sense to have the undo and the currect source of truth for configuration to be the same. If you want to implement more complex workflows use commits and git wisely to do so.

Review the pulled in changes using git, if everything looks good, commit and push to your preferred repo hub for backup.

Disperse

dg --disperse

When cloning existing configs from another machnie to a new machine you will have to use the --force-path to select which sepecific set of configs from the multi machine repo you want to seed to the current machine.

Undo

dg --undo-disperse

As long as something hasn't edited the target configs files since you dispersed them, and the undo hasn't been cleaned up you can restore the state of the target files to what it was prior to dispersion.

NOTE: Undos for the specific host/machine are removed on issuing a gather, it wouldn't make sense to have the undo and the currect source of truth for configuration to be the same. If you want to implement more complex workflows use commits and git wisely to do so.

Manually clean last disperse undo files for current host/machine

dg --clean

In general you shouldn't have to manually remove the undo files, but you have the option should that become needed.

The --force-path option :feelsgood:

!!! Be very very careful with this one !!!

Aside from when you want to seed the config files from an exsiting machine to a new one you shouln'd really need to use the force path option.

Using force path can cause all kinds of state inconstencies with the script commands since their rulesets make certain assumptions. There are safeguards in the script to allow backup and prompt you when "funny" things are happaning, but in general you should really understand what steps a command takes and the full "state machine" if you are gonna use --force-path for anything other than seeding new machines with existing configs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.