2014-05-18 18:35:55 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
source "$CURRENT_DIR/shared_functions.sh"
|
|
|
|
|
2015-07-29 17:36:49 -04:00
|
|
|
TMUX_ECHO_FLAG="$1"
|
|
|
|
|
|
|
|
# True if invoked as tmux mapping or tmux command,
|
|
|
|
# false if invoked via command line wrapper from `bin/` directory.
|
|
|
|
use_tmux_echo() {
|
|
|
|
[ "$TMUX_ECHO_FLAG" == "--tmux-echo" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
if use_tmux_echo; then
|
|
|
|
# use tmux specific echo-ing
|
|
|
|
echo_ok() {
|
|
|
|
echo_message "$*"
|
|
|
|
}
|
|
|
|
|
|
|
|
echo_err() {
|
|
|
|
echo_message "$*"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
echo_ok() {
|
|
|
|
echo "$*"
|
|
|
|
}
|
|
|
|
|
|
|
|
echo_err() {
|
|
|
|
fail_helper "$*"
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2014-05-18 18:35:55 -04:00
|
|
|
clone() {
|
2015-07-29 17:36:49 -04:00
|
|
|
local plugin="$1"
|
|
|
|
cd "$SHARED_TPM_PATH" &&
|
2015-07-31 17:23:57 -04:00
|
|
|
GIT_TERMINAL_PROMPT=0 git clone --recursive "$plugin" >/dev/null 2>&1
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# tries cloning:
|
|
|
|
# 1. plugin name directly - works if it's a valid git url
|
|
|
|
# 2. expands the plugin name to point to a github repo and tries cloning again
|
|
|
|
clone_plugin() {
|
2015-07-29 17:36:49 -04:00
|
|
|
local plugin="$1"
|
2014-05-24 17:15:13 -04:00
|
|
|
clone "$plugin" ||
|
2014-11-21 17:53:45 -05:00
|
|
|
clone "https://git::@github.com/$plugin"
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
|
2015-07-29 17:36:49 -04:00
|
|
|
# clone plugin and produce output
|
2014-08-05 12:15:07 -04:00
|
|
|
install_plugin() {
|
2014-08-05 14:50:47 -04:00
|
|
|
local plugin="$1"
|
|
|
|
local plugin_name="$(shared_plugin_name "$plugin")"
|
|
|
|
|
2014-08-05 12:45:59 -04:00
|
|
|
if plugin_already_installed "$plugin"; then
|
2015-07-29 17:36:49 -04:00
|
|
|
echo_ok "Already installed \"$plugin_name\""
|
2014-05-24 17:15:13 -04:00
|
|
|
else
|
2015-07-29 17:36:49 -04:00
|
|
|
echo_ok "Installing \"$plugin_name\""
|
2014-05-24 17:15:13 -04:00
|
|
|
clone_plugin "$plugin" &&
|
2015-07-29 17:36:49 -04:00
|
|
|
echo_ok " \"$plugin_name\" download success" ||
|
|
|
|
echo_err " \"$plugin_name\" download fail"
|
2014-05-24 17:15:13 -04:00
|
|
|
fi
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
|
2014-08-05 12:15:07 -04:00
|
|
|
install_plugins() {
|
2014-05-24 17:15:13 -04:00
|
|
|
local plugins=$(shared_get_tpm_plugins_list)
|
|
|
|
for plugin in $plugins; do
|
2014-08-05 12:15:07 -04:00
|
|
|
install_plugin "$plugin"
|
2014-05-24 17:15:13 -04:00
|
|
|
done
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
|
2015-07-22 13:13:01 -04:00
|
|
|
verify_tpm_path_permissions() {
|
|
|
|
# check the write permission flag for all users to ensure
|
|
|
|
# that we have proper access
|
|
|
|
[ -w $SHARED_TPM_PATH ] || echo_message "$SHARED_TPM_PATH does not seem to be writable!"
|
|
|
|
}
|
|
|
|
|
2014-05-18 18:35:55 -04:00
|
|
|
main() {
|
2014-05-24 17:15:13 -04:00
|
|
|
shared_set_tpm_path_constant
|
|
|
|
ensure_tpm_path_exists
|
2015-07-22 13:13:01 -04:00
|
|
|
verify_tpm_path_permissions
|
2014-08-05 12:15:07 -04:00
|
|
|
install_plugins
|
2015-07-29 17:36:49 -04:00
|
|
|
exit_value_helper
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
main
|