mysetup 0.1.0
A small package to auto install packages described in toml
Requires Python: >=3.6

# mysetup

cli-tool to setup installation of packages for linux based os

Template can be described for packages related to following things

- [apt](https://github.com/Rishang/mysetup#apt)           : Install Apt packages
- [apt_repo](https://github.com/Rishang/mysetup#apt_repo) : Add new Apt repo
- [yum](https://github.com/Rishang/mysetup#yum)           : Install Yum packages
- [yum_repo](https://github.com/Rishang/mysetup#yum_repo) : Add new Yum repo
- [pip](https://github.com/Rishang/mysetup#pip)           : install pip packages
- [snap](https://github.com/Rishang/mysetup#snap)         : Install snap store applications
- [go](https://github.com/Rishang/mysetup#go)             : Install Go lang based modules from github
- [github](https://github.com/Rishang/mysetup#github)     : clone github repos

## Installation

        pip install mysetup

## cli usage: `mysetup`

See [example.toml](https://github.com/Rishang/mysetup/blob/master/examples/example.toml) to see template example

- Help page

  `mysetup --help`

        Usage: mysetup.py [OPTIONS] COMMAND [ARGS]...

        Options:
        --help  Show this message and exit.

        Commands:

        get             Install template packages from [URL]
        install         Install template packages from [standard input].
        print-template  Print empty template, to build your own

Install packages from template using `get`, `mysetup get [URL]`:

- This will request to template file present on github and install packages defined in it.

        mysetup get https://raw.githubusercontent.com/Rishang/mysetup/master/examples/example.toml

- Or, If present template locally use `install` as `mysetup install` as below:

        mysetup install example.toml

## Generate starter template

### sudo password prompt

Disable  sudo password prompt for install package, export an enviornment variable called `SUDO_PASS`, script will initially check for this environment variable, if it exist it will use it's value directly as sudo password

        export SUDO_PASS=YOUR-SUDO-PASSWD

To create starter template for configuring run below command

`mysetup print-template > my.toml`

This will create empty starter template named `my.toml` as [This one](https://raw.githubusercontent.com/Rishang/mysetup/master/mysetup/src/template.toml)

`cat my.toml`

From here you can edit this existing file to create your own installation setup configuration template

## Making Temmplates

The `mysetup` initially get configuration file which is written in [toml](https://toml.io/en/) and analyse the content after converting the standard input given to is in form of json

See [example.toml](https://github.com/Rishang/mysetup/blob/master/examples/example.toml) to see template example.

following are valid input fields for create template toml file

### [apt]

list of apt packages to install will be defined as follow

**valid arguments**:

- **packages**: List of Apt packages to install.
- **flags**: List of extra flags to apt install eg: `["--fix-missing"]`

Example:

        [apt]

        packages = ["curl","wget"]
        flags = ["--fix-missing"]

### [apt_repo]

add new repo, below is example of adding and installing sublime-text editor repo lines with `#` are comments in toml

- **add_key**: add GPG key of the repo
- **add_repo**: repo url as argument to add-apt-repository

- **packages**: List of Apt packages to install.
- **is_there**: Check if this file or directory exists.
- **flags**: List of extra flags to apt install eg: `["--fix-missing"]`

Example:

    [apt_repo]

        [apt_repo.sublime_text]

        is_there = "/usr/bin/subl"

        add_key = "https://download.sublimetext.com/sublimehq-pub.gpg"
        add_repo = "deb https://download.sublimetext.com/ apt/stable/"

        packages = ["sublime-text"]
        flags = ["--fix-missing"]

### [yum]

list of yum packages to install will be defined as follow

**valid arguments**:

- **packages**: List of Yum packages to install.
- **flags**: List of extra flags to yum install eg: `["--refresh"]`.

Example:

        [yum]

        packages = ["wget" ,"curl"]
        flags = ["--refresh"]

### [yum_repo]

Extra repo adds new repo, below is example of adding and installing docker editor repo lines with `#` are comments in toml

**valid arguments**:

- **is_there**: Check if this file or directory exist
- **add_repo**: Add new repo url to yum repolist
- **packages**: List of yum packages to install
- **flags**: extra flags to yum install eg: `["--refresh"]`

Example:

    [yum_repo]

        [yum_repo.docker]

        is_there = "/usr/bin/docker"

        add_repo = "https://download.docker.com/linux/centos/docker-ce.repo"
        
        packages = ["docker-ce" ,"docker-ce-cli","containerd.io"]
        flags = ["--downloadonly"] 

### [snap]

list of snap apps to install

**valid arguments**:

- **packages**: list of snap apps to install
- **flags**: extra flags to snap install eg: `["--stable"]`

Example:

        [snap]

        packages = ["code","spotify"]

        flags = ["--stable"]

### [pip]

list of pip packages to install

**valid arguments**:

- **packages**: list of pip packages to install
- **flags**: extra flags to pip install eg `["--verbose"]`
- **update**: `true || false`, update if any of packages already exist

Example:

        [pip]
        
        packages = ["pandas","bs4","requests","lxml"]
        flags = ["--verbose"]
        
        update = true

### [go]

Install go lang based tools and modules

**valid arguments**:

- **packages**: list of cli tool of go modules to install
- **GO111MODULE_packages**: for install packages based on: GO111MODULE=on
- **flags** extra flags for go get eg: `["-v"]`

Example:

        [go]

        packages = [
            "github.com/tomnomnom/gf"
        ]
        GO111MODULE_packages = [
            "github.com/projectdiscovery/nuclei/v2/cmd/nuclei"
        ]
        flags = ["-v","-u"]

### [github]

clone list of github repos to a certain directory

**valid arguments**:

- **clone** : list of repos to clone
- **flags** : extra flags for git clone eg: `["--origin"]`
- **path**: path where you want to store cloned repos to _dir_name

Example:

        [github]

        clone = ["https://github.com/tomnomnom/gf.git"]
        flags = ["--depth=1"]

        path = "{HOME}/dir_name"

- The `{HOME}` will identify linux environment variable `HOME` and clone repos at `~/tools`

  path = "{HOME}/dir_name"

### [command]

List of commands to run

**valid arguments**:

- **commands**: list of shell commands to run

Example:

        [command]

            commands = [
                "pwd",
                "cat /etc/os-release"
            ]