diff options
author | johannst <stoelp@eit.uni-kl.de> | 2017-01-13 22:55:12 +0100 |
---|---|---|
committer | johannst <stoelp@eit.uni-kl.de> | 2017-01-13 22:55:12 +0100 |
commit | 3af9be1d595a3ba8eb38b83070e6ff7110a6ed4c (patch) | |
tree | eab1429d40d529fd8e9c986ef5b69c7fc8d51443 | |
parent | a7335876aabcd7457c225c2165e76793b282cd8b (diff) | |
download | dotfiles-3af9be1d595a3ba8eb38b83070e6ff7110a6ed4c.tar.gz dotfiles-3af9be1d595a3ba8eb38b83070e6ff7110a6ed4c.zip |
added installer framework and adapted README file
-rw-r--r-- | README.md | 32 | ||||
-rwxr-xr-x | install | 155 | ||||
-rw-r--r-- | install.config | 12 |
3 files changed, 192 insertions, 7 deletions
@@ -1,10 +1,28 @@ -# dotfiles -- README -# author: johannst +# dotfiles -Currently no installer available! +Installer framework only availabl in bash. -- **print_bash_color** - - display available colors +### Control installation +Installation of the config files is controlled with the `install.config` file. The format of a line in the file is as follows: +``` +[yYnN] - <config_tag> +``` +Where `yY` means to install the config file and `nN` means to skip installation for this config file. +Any line not matching the regex `^[yYnN][[:blank:]]?-` is ignored. -- **vim/install_vundle.sh**: - - install Vundle vim package manager + +The installation process is triggered by executing the `install` file. + +### Adapt installation of config files +The installation of a particular config file can be adapted by modifying the corresponding installer function. +Follow the `<config_tag>` in the `gToolsConfig` map (defined in `install`) to find the name of the installer function. The name is the third entry for the tag. + +### Adding additional config files + +First add an entry in the `gToolsConfig` map in the `install` file. Entries have the following format: +``` +"<config_tag>:<dep_binary>:<installer_function_name>" +``` +Then create and implement the installer function with the name provided in the newly created entry. + +Then create an entry in the `install.config` file with the tag that matches the tag provided in the `gToolsConfig`. @@ -0,0 +1,155 @@ +#!/bin/bash +# dotfiles -- install +# author: johannst + +gInstallConfigFile=install.config + +#"<config_tag>:<dep_binary>:<installer_fct_name>" +gToolsConfig=( +"bashrc:bash:bashrcInstaller" +"cgdb:cgdb:cgdbrcInstaller" +"conkyrc:conky:conkyrcInstaller" +"gitconfig:git:gitConfigInstaller" +"tmux.conf:tmux:tmuxConfigInstaller" +"vimrc:vim:vimConfigInstaller" +"Xresources:xterm:xtermConfigInstaller" +) + +#{{{ bashrcInstaller + +function bashrcInstaller() { + echo "bashInstaller called!" +} + +#}}} +#{{{ cgdbrcInstaller + +function cgdbrcInstaller() { + echo "cgdbrcInstaller called" +} + +#}}} +#{{{ conkyrcInstaller + +function conkyrcInstaller() { + echo "conkyrcInstaller called" +} + +#}}} +#{{{ gitConfigInstaller + +function gitConfigInstaller() { + echo "gitConfigInstaller called" +} + +#}}} +#{{{ tmuxConfigInstaller + +function tmuxConfigInstaller() { + echo "tmuxConfigInstaller called" +} + +#}}} +#{{{ vimConfigInstaller + +function vimConfigInstaller() { + echo "vimConfigInstaller called" +} + +#}}} +#{{{ xtermConfigInstaller + +function xtermConfigInstaller() { + echo "xtermConfigInstaller called" +} + +#}}} + +#{{{ Installer Main Loop + +function main() { + # parse gInstallConfigFile to see what should be installed + configToInstall=() + while read line; do + if [[ ! $line =~ ^[yYnN][[:blank:]]?- ]]; then + continue + fi + flag=$(echo $line | cut -d '-' -f 1 | sed 's/ //g') + if [[ $flag =~ ^[yY]$ ]]; then + config=$(echo $line | cut -d '-' -f 2 | sed 's/ //g') + configToInstall+=("$config") + fi + done < $gInstallConfigFile + + echo "[Info]: List of tags found to install:" + for conf in ${configToInstall[@]}; do + echo -e "\t$conf" + done + + for conf in ${configToInstall[@]}; do + installConfig $conf + done +} + +#}}} +#{{{ Installer Core + +installConfig() { + local config=$1 + local binary=$(getDepenentBinaryName $config) + isBinaryInstalled $binary + if [[ $? -eq 1 ]]; then + echo "[Warning]: Skipping $config... $config is not installed!" + return + fi + local installerFctPtr=$(getConfigInstallerFctPtr $config) + if [[ -z $installerFctPtr ]]; then + echo "[Warning]: Skipping $config... installer function pointer loopup error!" + return + fi + isInstallerDefined $installerFctPtr + if [[ $? -eq 1 ]]; then + echo "[Warning]: Skipping $config... $installerFctPtr not defined!" + return + fi + echo "[Info]: Intalling config for $binary using $installerFctPtr!" + $installerFctPtr +} + +getValue() { + local search_key=$1 + for k in ${gToolsConfig[@]}; do + local key=$(echo $k | cut -d ':' -f 1) + if [[ "$key" == "$search_key" ]]; then + local entry=$(echo $k | cut -d ':' -f 2,3) + echo ${entry} + break + fi + done +} + +getDepenentBinaryName() { + local result=$(echo $(getValue $1) | cut -d ':' -f 1) + echo $result +} + +getConfigInstallerFctPtr() { + local result=$(echo $(getValue $1) | cut -d ':' -f 2) + echo $result +} + +isBinaryInstalled() { + local binary=$1 + type $binary >/dev/null 2>&1 || { return 1; } + return 0 +} + +isInstallerDefined () { + local func=$1 + declare -F $func >/dev/null 2>&1 || { return 1; } + return 0 +} + +#}}} + +main diff --git a/install.config b/install.config new file mode 100644 index 0000000..8f01435 --- /dev/null +++ b/install.config @@ -0,0 +1,12 @@ +# dotfiles -- install.config +# author: johannst +# line format: [yYnN] - <config_tag> +# lines not starting with [yYnN] are ignored + +y - bashrc +y - cgdb +y - conkyrc +y - gitconfig +y - tmux.conf +y - vimrc +y - Xresources |