Skip to content

Instantly share code, notes, and snippets.

@MitarashiDango
Last active November 8, 2018 14:57
Show Gist options
  • Save MitarashiDango/298d827756f5efe52bcbc424b755fc92 to your computer and use it in GitHub Desktop.
Save MitarashiDango/298d827756f5efe52bcbc424b755fc92 to your computer and use it in GitHub Desktop.
Elasticsearchのプラグインを一括更新するやつ
#!/bin/bash
ELASTICSEARCH_DIR=/usr/share/elasticsearch
cd $ELASTICSEARCH_DIR
systemctl stop elasticsearch
PLUGIN_LIST="$(bin/elasticsearch-plugin list -s)"
echo "Update required plugins."
echo "-------------------------------------"
echo "$PLUGIN_LIST" | while read PLUGIN_NAME
do
echo "$PLUGIN_NAME"
done
echo "-------------------------------------"
echo "[1] Uninstall plugins"
echo "$PLUGIN_LIST" | while read PLUGIN_NAME
do
echo "Update: $PLUGIN_NAME"
echo "Uninstalling..."
bin/elasticsearch-plugin remove $PLUGIN_NAME
if [[ $? -ne 0 ]]; then
echo "Aborted."
exit
fi
echo "Uninstalled."
done
echo "[2] Reinstall plugins"
echo "$PLUGIN_LIST" | while read PLUGIN_NAME
do
echo "Reinstalling..."
bin/elasticsearch-plugin install $PLUGIN_NAME
if [[ $? -ne 0 ]]; then
echo "Aborted."
exit
fi
echo "Installed."
done
systemctl start elasticsearch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment