tpm/scripts/install_plugins.sh

66 lines
1.5 KiB
Bash
Raw Normal View History

2014-05-18 22:35:55 +00:00
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/shared_functions.sh"
clone() {
2014-05-24 21:15:13 +00:00
local plugin=$1
cd $SHARED_TPM_PATH &&
2015-02-08 14:38:55 +00:00
GIT_TERMINAL_PROMPT=0 git clone --recursive $plugin
2014-05-18 22:35:55 +00: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() {
2014-05-24 21:15:13 +00:00
local plugin=$1
clone "$plugin" ||
clone "https://git::@github.com/$plugin"
2014-05-18 22:35:55 +00:00
}
# pull new changes or clone plugin
2014-08-05 16:15:07 +00:00
install_plugin() {
2014-08-05 18:50:47 +00:00
local plugin="$1"
local plugin_name="$(shared_plugin_name "$plugin")"
if plugin_already_installed "$plugin"; then
# plugin is already installed
2014-08-05 18:50:47 +00:00
echo_message "Already installed \"$plugin_name\""
2014-05-24 21:15:13 +00:00
else
# plugin wasn't cloned so far - clone it
2014-08-05 18:50:47 +00:00
echo_message "Installing \"$plugin_name\""
2014-05-24 21:15:13 +00:00
clone_plugin "$plugin" &&
2014-08-05 18:50:47 +00:00
echo_message " \"$plugin_name\" download success" ||
echo_message " \"$plugin_name\" download fail"
2014-05-24 21:15:13 +00:00
fi
2014-05-18 22:35:55 +00:00
}
2014-08-05 16:15:07 +00:00
install_plugins() {
2014-05-24 21:15:13 +00:00
local plugins=$(shared_get_tpm_plugins_list)
for plugin in $plugins; do
2014-08-05 16:15:07 +00:00
install_plugin "$plugin"
2014-05-24 21:15:13 +00:00
done
2014-05-18 22:35:55 +00:00
}
ensure_tpm_path_exists() {
2014-05-24 21:15:13 +00:00
mkdir -p $SHARED_TPM_PATH
}
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 22:35:55 +00:00
main() {
2014-05-24 21:15:13 +00:00
reload_tmux_environment
shared_set_tpm_path_constant
ensure_tpm_path_exists
verify_tpm_path_permissions
2014-08-05 16:15:07 +00:00
install_plugins
2014-05-24 21:15:13 +00:00
reload_tmux_environment
end_message
2014-05-18 22:35:55 +00:00
}
main