Add a more advanced setup for using profiles
parent
d4da86bcfd
commit
8eddafa00a
1 changed files with 112 additions and 0 deletions
|
@ -1,7 +1,119 @@
|
||||||
## How can I have different groups of tasks for different hosts with different configurations?
|
## How can I have different groups of tasks for different hosts with different configurations?
|
||||||
|
|
||||||
|
### Simple setup
|
||||||
|
|
||||||
See [here](https://github.com/anishathalye/dotbot/pull/11#issuecomment-73082152) for information on using machine-specific configs.
|
See [here](https://github.com/anishathalye/dotbot/pull/11#issuecomment-73082152) for information on using machine-specific configs.
|
||||||
|
|
||||||
|
### More advanced setup
|
||||||
|
|
||||||
|
If you want to install programs independently from a general configuration file, the following setup might be for you.
|
||||||
|
|
||||||
|
#### Configurations
|
||||||
|
Write a configuration file for each program and put them together in a directory:
|
||||||
|
```
|
||||||
|
meta/configs/
|
||||||
|
├── bash.yaml
|
||||||
|
├── git.yaml
|
||||||
|
├── i3.yaml
|
||||||
|
└── ...
|
||||||
|
```
|
||||||
|
Then add a basic configuration file (i.e. for cleaning up) at `meta/base.yaml`.
|
||||||
|
|
||||||
|
#### Profiles
|
||||||
|
Then summarize these configurations in profiles:
|
||||||
|
```
|
||||||
|
meta/profiles/
|
||||||
|
├── server
|
||||||
|
├── workstation
|
||||||
|
└── ...
|
||||||
|
```
|
||||||
|
In a profile you specify the configurations you want to install (one per line, without `.yaml`).
|
||||||
|
|
||||||
|
#### New `install` scripts
|
||||||
|
Then replace the `install` script with the following ones:
|
||||||
|
|
||||||
|
##### `install-profile`
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BASE_CONFIG="base"
|
||||||
|
CONFIG_SUFFIX=".yaml"
|
||||||
|
|
||||||
|
META_DIR="meta"
|
||||||
|
CONFIG_DIR="configs"
|
||||||
|
PROFILES_DIR="profiles"
|
||||||
|
|
||||||
|
DOTBOT_DIR="dotbot"
|
||||||
|
DOTBOT_BIN="bin/dotbot"
|
||||||
|
|
||||||
|
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
|
||||||
|
cd "${BASE_DIR}"
|
||||||
|
git submodule update --init --recursive "${DOTBOT_DIR}"
|
||||||
|
|
||||||
|
|
||||||
|
while IFS= read -r config; do
|
||||||
|
CONFIGS+=" ${config}"
|
||||||
|
done < "${META_DIR}/${PROFILES_DIR}/$1"
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
|
||||||
|
"${BASE_DIR}/${META_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "${META_DIR}/${BASE_CONFIG}${CONFIG_SUFFIX}"
|
||||||
|
|
||||||
|
for config in ${CONFIGS} ${@}; do
|
||||||
|
echo -e "\nConfigure $config"
|
||||||
|
"${BASE_DIR}/${META_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "${META_DIR}/${CONFIG_DIR}/${config}${CONFIG_SUFFIX}"
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
##### `install-standalone`
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BASE_CONFIG="base"
|
||||||
|
CONFIG_SUFFIX=".yaml"
|
||||||
|
|
||||||
|
META_DIR="meta"
|
||||||
|
CONFIG_DIR="configs"
|
||||||
|
PROFILES_DIR="profiles"
|
||||||
|
|
||||||
|
DOTBOT_DIR="dotbot"
|
||||||
|
DOTBOT_BIN="bin/dotbot"
|
||||||
|
|
||||||
|
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
|
||||||
|
cd "${BASE_DIR}"
|
||||||
|
git submodule update --init --recursive "${DOTBOT_DIR}"
|
||||||
|
|
||||||
|
|
||||||
|
"${BASE_DIR}/${META_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "${META_DIR}/${BASE_CONFIG}${CONFIG_SUFFIX}"
|
||||||
|
|
||||||
|
for config in ${@}; do
|
||||||
|
"${BASE_DIR}/${META_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "${META_DIR}/${CONFIG_DIR}/${config}${CONFIG_SUFFIX}"
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you should be able to install a profile with
|
||||||
|
```
|
||||||
|
./install-profile <profile> [<configs...>]
|
||||||
|
```
|
||||||
|
and single configurations with
|
||||||
|
```
|
||||||
|
./install-standalone <configs...>
|
||||||
|
```
|
||||||
|
|
||||||
|
If you have any open questions or something is unclear, you can try to take a look at a dotfile repository that uses this setup:
|
||||||
|
* [vbrandl/dotfiles](https://github.com/vbrandl/dotfiles)
|
||||||
|
* [vsund/dotfiles](https://github.com/vsund/dotfiles)
|
||||||
|
|
||||||
|
|
||||||
## Automatically install or update dotfiles when ssh'ing into a remote machine (or: let my dotfiles follow me)
|
## Automatically install or update dotfiles when ssh'ing into a remote machine (or: let my dotfiles follow me)
|
||||||
|
|
||||||
Original inspiration: http://klaig.blogspot.co.at/2013/04/make-your-dotfiles-follow-you.html
|
Original inspiration: http://klaig.blogspot.co.at/2013/04/make-your-dotfiles-follow-you.html
|
||||||
|
|
Loading…
Reference in a new issue