Finding the best way to automate your work environment

I am working on virtual machines. I use virtual machines for testing purposes, and I often create virtual machines or switch virtual machines. The problem is that I need to recreate my working environment every time I create / switch VMs. My work environment includes files (.bashrc, .emacs, .emacs.d, .vimrc, .gitconfig, etc.). Since I need these files to create my own flexible linux environment. But his headache is constantly copying these files. Please suggest the best way to quickly recreate my env.

+4
source share
3 answers

You can create a bash script to do this. In my understanding, you know git. I suggest you create a couple of git repos (possibly on github) based on the classification of your env files. Here is an example of quickly recreating your env. In vm, split the path to git repos. And you can link the files to your repo files. e.g. .bashrc -> to / your / bashrc

#!/bin/bash
        declare -a repos=('repo1.git' 'repo2.git' 'repo3.git')

        err=0

        err_sts()
        {
        if [ 0 -ne $? ]; then
            err=$1
            echo above step failed exiting.. err code: $err
            exit $err              
        fi
        }

        gclone()
        {
        echo path=$1 
        echo repo=$2
        path=$1
        repo=$2
        echo "cd $hmdir"
        cd $hmdir
        echo "git clone $path/$repo"
        git clone $path/$repo
        }

        main()
        {
        echo enter the path to repos:
        read pth

        ls $pth
        err_sts 1

        #path where you want your repos 
        echo enter home dir for repos:
        read hmdir

    ls $hmdir
    err_sts 2

    err=3
    for ((i = 0; i < ${#repos[@]}; i++))
    do
    echo "ls $pth/${repos[$i]}"
    ls $pth/${repos[$i]}
    err_sts $(($err + $i))
    gclone $pth ${repos[$i]}
    done
    }

    main
+2
source

I suggest creating a github repository for your workspace. After that, in each new host, do:

cd ~
cd git clone [my repo URL]

... to download all of your files with an appropriate directory structure.

If this is too much for you, or if you have files outside your home folder, a tarball might be more appropriate:

cd /
tar czvf ~/my_env.tgz [path to each file]

Then on a new machine:

cd /
tar xzvf ~/my_env.tgz

, github , - .

NB: .., init.sh, .

+1

CloudShare, , , , " . , , /switch VM". . CloudShare - . , " " " " . , , . : http://cloudshare.com/overview-1

Hope this helps you.

0
source

All Articles