1
0
Fork 0
mirror of synced 2024-11-22 16:25:34 -05:00

Add quickstart tutorial for advanced setup and allow individual configurations to be run as sudoer

Eric Carlson 2021-03-22 18:56:58 -06:00
parent 7c68030ac5
commit 14ea7c8bf8

@ -6,7 +6,7 @@ See [here](https://github.com/anishathalye/dotbot/pull/11#issuecomment-73082152)
## More advanced setup ## More advanced setup
If you want to install programs independently from a general configuration file, the following setup might be for you. If you want to install programs independently from a general configuration file, the following setup might be for you. An advanced quickstart can be found at the [ecarlson94/dotbot-template Wiki](https://github.com/ecarlson94/dotbot-template/wiki/Dotfiles-Repository).
### Configurations ### Configurations
Write a configuration file for each program and put them together in a directory: Write a configuration file for each program and put them together in a directory:
@ -50,22 +50,35 @@ DOTBOT_BIN="bin/dotbot"
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${BASE_DIR}" cd "${BASE_DIR}"
git submodule update --init --recursive --remote git submodule update --init --recursive --remote
while IFS= read -r config; do while IFS= read -r config; do
CONFIGS+=" ${config}" CONFIGS+=" ${config}"
done < "${META_DIR}/${PROFILES_DIR}/$1" done < "${META_DIR}/${PROFILES_DIR}/$1"
shift shift
echo ${CONFIGS}
for config in ${CONFIGS} ${@}; do for config in ${CONFIGS} ${@}; do
echo -e "\nConfigure $config" echo -e "\nConfigure $config"
configFile="$(mktemp)" ; echo -e "$(<"${BASE_DIR}/${META_DIR}/${BASE_CONFIG}${CONFIG_SUFFIX}")\n$(<"${BASE_DIR}/${META_DIR}/${CONFIG_DIR}/${config}${CONFIG_SUFFIX}")" > "$configFile" # create temporary file
"${BASE_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "$configFile" ; rm -f "$configFile" configFile="$(mktemp)"
suffix="-sudo"
echo -e "$(<"${BASE_DIR}/${META_DIR}/${BASE_CONFIG}${CONFIG_SUFFIX}")\n$(<"${BASE_DIR}/${META_DIR}/${CONFIG_DIR}/${config%"$suffix"}${CONFIG_SUFFIX}")" > "$configFile"
cmd=("${BASE_DIR}/${META_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "$configFile")
if [[ $config == *"sudo"* ]]; then
cmd=(sudo "${cmd[@]}")
fi
"${cmd[@]}"
rm -f "$configFile"
done done
cd "${BASE_DIR}"
``` ```
#### `install-standalone` #### `install-standalone`
@ -86,23 +99,42 @@ DOTBOT_BIN="bin/dotbot"
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${BASE_DIR}" cd "${BASE_DIR}"
git submodule update --init --recursive --remote git submodule update --init --recursive --remote
for config in ${@}; do for config in ${@}; do
configFile="$(mktemp)" ; echo -e "$(<"${BASE_DIR}/${META_DIR}/${BASE_CONFIG}${CONFIG_SUFFIX}")\n$(<"${BASE_DIR}/${META_DIR}/${CONFIG_DIR}/${config}${CONFIG_SUFFIX}")" > "$configFile" # create temporary file
"${BASE_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "$configFile" ; rm -f "$configFile" configFile="$(mktemp)"
suffix="-sudo"
echo -e "$(<"${BASE_DIR}/${META_DIR}/${BASE_CONFIG}${CONFIG_SUFFIX}")\n$(<"${BASE_DIR}/${META_DIR}/${CONFIG_DIR}/${config%"$suffix"}${CONFIG_SUFFIX}")" > "$configFile"
cmd=("${BASE_DIR}/${META_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "$configFile")
if [[ $config == *"sudo"* ]]; then
cmd=(sudo "${cmd[@]}")
fi
"${cmd[@]}"
rm -f "$configFile"
done done
cd "${BASE_DIR}"
``` ```
Now you should be able to install a profile with Now you should be able to install a profile with
``` ```bash
./install-profile <profile> [<configs...>] ./install-profile <profile> [<configs...>]
``` ```
and single configurations with and single configurations with
``` ```bash
./install-standalone <configs...> ./install-standalone <configs...>
``` ```
You can also invoke a single configuration as a sudoer by adding `-sudo` to the end of a configuration
```bash
./install-standalone some-config-sudo some-other-config
```
In the last example, the `some-config` config will be run with elevated privileges, but `some-other-config` will not.
The above prevent passing command-line arguments like `-v` and `-q` to the Dotbot invocation. If you want to use command-line options in conjunction with the above, you can add parsing of command-line options as described in [#87](https://github.com/anishathalye/dotbot/issues/87#issue-146431889). The above prevent passing command-line arguments like `-v` and `-q` to the Dotbot invocation. If you want to use command-line options in conjunction with the above, you can add parsing of command-line options as described in [#87](https://github.com/anishathalye/dotbot/issues/87#issue-146431889).