1
0
Fork 0
mirror of synced 2024-12-14 03:15:47 -05:00
tpm/scripts/install_plugins.sh
Ilya Terentyev f4d920362c Check write permissions to plugin folder
During plugin installation, check if required write permissions are in
place; if the sanity check fails, warn the user. This is a squash
4-in-1 commit.
2015-07-23 19:57:04 +03:00

65 lines
1.5 KiB
Bash
Executable file

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