{"id":162,"date":"2019-10-25T23:20:09","date_gmt":"2019-10-25T23:20:09","guid":{"rendered":"http:\/\/snehpatel.com\/?p=162"},"modified":"2019-10-25T23:20:09","modified_gmt":"2019-10-25T23:20:09","slug":"shell-script-for-elk-installation","status":"publish","type":"post","link":"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/","title":{"rendered":"Shell Script for ELK installation"},"content":{"rendered":"\n\t\t\t\t\n<ul class=\"wp-block-list\"><li>This script is only tested in centos. Tweak the script as you like.<\/li><li>Please change the version link with a new one.<\/li><li>Logstash:- <a href=\"https:\/\/www.elastic.co\/downloads\/logstash\">Link<\/a><\/li><li>Elasticsearch:- <a href=\"https:\/\/www.elastic.co\/downloads\/elasticsearch\">Link<\/a><\/li><li>Kibana:- <a href=\"https:\/\/www.elastic.co\/downloads\/kibana\">Link<\/a><\/li><li>Credit: <a href=\"https:\/\/gist.github.com\/kydouglas\/1f68d69e856fd6d7dc223f8e1f5ae3b3\">https:\/\/gist.github.com\/kydouglas\/1f68d69e856fd6d7dc223f8e1f5ae3b3<\/a><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# Checking whether user has enough permission to run this script\nsudo -n true\nif [ $? -ne 0 ]\n    then\n        echo \"This script requires user to have passwordless sudo access\"\n        exit\nfi\n\ndependency_check_deb() {\njava -version\nif [ $? -ne 0 ]\n    then\n        # Installing Java 7 if it's not installed\n        sudo apt-get install openjdk-7-jre-headless -y\n    # Checking if java installed is less than version 7. If yes, installing Java 7. As logstash &amp; Elasticsearch require Java 7 or later.\n    elif [ \"`java -version 2> \/tmp\/version &amp;&amp; awk '\/version\/ { gsub(\/\"\/, \"\", $NF); print ( $NF &lt; 1.7 ) ? \"YES\" : \"NO\" }' \/tmp\/version`\" == \"YES\" ]\n        then\n            sudo apt-get install openjdk-7-jre-headless -y\nfi\n}\n\ndependency_check_rpm() {\n    java -version\n    if [ $? -ne 0 ]\n        then\n            #Installing Java 7 if it's not installed\n            sudo yum install jre-1.7.0-openjdk -y\n        # Checking if java installed is less than version 7. If yes, installing Java 7. As logstash &amp; Elasticsearch require Java 7 or later.\n        elif [ \"`java -version 2> \/tmp\/version &amp;&amp; awk '\/version\/ { gsub(\/\"\/, \"\", $NF); print ( $NF &lt; 1.7 ) ? \"YES\" : \"NO\" }' \/tmp\/version`\" == \"YES\" ]\n            then\n                sudo yum install jre-1.7.0-openjdk -y\n    fi\n}\n\ndebian_elk() {\n    # resynchronize the package index files from their sources.\n    sudo apt-get update\n    # Downloading debian package of logstash\n    sudo wget --directory-prefix=\/opt\/ https:\/\/artifacts.elastic.co\/downloads\/logstash\/logstash-7.4.1.deb\n    # Install logstash debian package\n    sudo dpkg -i \/opt\/logstash*.deb\n    # Downloading debian package of elasticsearch\n    sudo wget --directory-prefix=\/opt\/ https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-7.4.1-amd64.deb\n    # Install debian package of elasticsearch\n    sudo dpkg -i \/opt\/elasticsearch*.deb\n    # Download kibana tarball in \/opt\n    sudo wget --directory-prefix=\/opt\/ https:\/\/artifacts.elastic.co\/downloads\/kibana\/kibana-7.4.1-amd64.deb\n    # Extracting kibana tarball\n    sudo dpkg -i \/opt\/kibana*.deb\n    # Starting The Services\n    sudo service logstash start\n    sudo service elasticsearch start\n    sudo service kibana start\n}\n\nrpm_elk() {\n    #Installing wget.\n    sudo yum install wget -y\n    # Downloading rpm package of logstash\n    sudo wget --directory-prefix=\/opt\/ https:\/\/artifacts.elastic.co\/downloads\/logstash\/logstash-7.4.1.rpm\n    # Install logstash rpm package\n    sudo rpm -ivh \/opt\/logstash*.rpm\n    # Downloading rpm package of elasticsearch\n    sudo wget --directory-prefix=\/opt\/ https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-7.4.1-x86_64.rpm\n    # Install rpm package of elasticsearch\n    sudo rpm -ivh \/opt\/elasticsearch*.rpm\n    # Download kibana tarball in \/opt\n    sudo wget --directory-prefix=\/opt\/ https:\/\/artifacts.elastic.co\/downloads\/kibana\/kibana-7.4.1-x86_64.rpm\n    # Extracting kibana tarball\n    sudo rpm -ivh \/opt\/kibana*.rpm\n    # Starting The Services\n    sudo systemctl enable logstash\n    sudo systemctl start logstash\n    sudo systemctl enable elasticsearch\n    sudo systemctl start elasticsearch\n    sudo systemctl enable kibana\n    sudo systemctl start kibana\n}\n\n# Installing ELK Stack\nif [ \"$(grep -Ei 'debian|buntu|mint' \/etc\/*release)\" ]\n    then\n        echo \" It's a Debian based system\"\n        dependency_check_deb\n        debian_elk\nelif [ \"$(grep -Ei 'fedora|redhat|centos' \/etc\/*release)\" ]\n    then\n        echo \"It's a RedHat based system.\"\n        dependency_check_rpm\n        rpm_elk\nelse\n    echo \"This script doesn't support ELK installation on this OS.\"\nfi\n<\/code><\/pre>\n\t\t","protected":false},"excerpt":{"rendered":"<p>This script is only tested in centos. Tweak the script as you like. Please change the version link with a new one. Logstash:- Link Elasticsearch:- Link Kibana:- Link Credit: https:\/\/gist.github.com\/kydouglas\/1f68d69e856fd6d7dc223f8e1f5ae3b3<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[14,17,3,9],"tags":[28,51],"class_list":["post-162","post","type-post","status-publish","format-standard","hentry","category-elk","category-linux","category-logging","category-systme","tag-elk","tag-system"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Shell Script for ELK installation - Sneh Patel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Shell Script for ELK installation - Sneh Patel\" \/>\n<meta property=\"og:description\" content=\"This script is only tested in centos. Tweak the script as you like. Please change the version link with a new one. Logstash:- Link Elasticsearch:- Link Kibana:- Link Credit: https:\/\/gist.github.com\/kydouglas\/1f68d69e856fd6d7dc223f8e1f5ae3b3\" \/>\n<meta property=\"og:url\" content=\"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/\" \/>\n<meta property=\"og:site_name\" content=\"Sneh Patel\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-25T23:20:09+00:00\" \/>\n<meta name=\"author\" content=\"Sneh Patel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sneh Patel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/snehpatel.com\\\/index.php\\\/2019\\\/10\\\/25\\\/shell-script-for-elk-installation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/snehpatel.com\\\/index.php\\\/2019\\\/10\\\/25\\\/shell-script-for-elk-installation\\\/\"},\"author\":{\"name\":\"Sneh Patel\",\"@id\":\"https:\\\/\\\/snehpatel.com\\\/#\\\/schema\\\/person\\\/a39105bc63f7e11a0e07b12a4c3dda73\"},\"headline\":\"Shell Script for ELK installation\",\"datePublished\":\"2019-10-25T23:20:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/snehpatel.com\\\/index.php\\\/2019\\\/10\\\/25\\\/shell-script-for-elk-installation\\\/\"},\"wordCount\":53,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/snehpatel.com\\\/#\\\/schema\\\/person\\\/a39105bc63f7e11a0e07b12a4c3dda73\"},\"keywords\":[\"ELK\",\"System\"],\"articleSection\":[\"ELK\",\"Linux\",\"Logging\",\"System\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/snehpatel.com\\\/index.php\\\/2019\\\/10\\\/25\\\/shell-script-for-elk-installation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/snehpatel.com\\\/index.php\\\/2019\\\/10\\\/25\\\/shell-script-for-elk-installation\\\/\",\"url\":\"https:\\\/\\\/snehpatel.com\\\/index.php\\\/2019\\\/10\\\/25\\\/shell-script-for-elk-installation\\\/\",\"name\":\"Shell Script for ELK installation - Sneh Patel\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/snehpatel.com\\\/#website\"},\"datePublished\":\"2019-10-25T23:20:09+00:00\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/snehpatel.com\\\/index.php\\\/2019\\\/10\\\/25\\\/shell-script-for-elk-installation\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/snehpatel.com\\\/#website\",\"url\":\"https:\\\/\\\/snehpatel.com\\\/\",\"name\":\"Sneh Patel\",\"description\":\"Cyber Security Blog\",\"publisher\":{\"@id\":\"https:\\\/\\\/snehpatel.com\\\/#\\\/schema\\\/person\\\/a39105bc63f7e11a0e07b12a4c3dda73\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/snehpatel.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/snehpatel.com\\\/#\\\/schema\\\/person\\\/a39105bc63f7e11a0e07b12a4c3dda73\",\"name\":\"Sneh Patel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/snehpatel.com\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/cropped-Slide4-1.jpg?fit=672%2C222&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/snehpatel.com\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/cropped-Slide4-1.jpg?fit=672%2C222&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/snehpatel.com\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/cropped-Slide4-1.jpg?fit=672%2C222&ssl=1\",\"width\":672,\"height\":222,\"caption\":\"Sneh Patel\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/snehpatel.com\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/cropped-Slide4-1.jpg?fit=672%2C222&ssl=1\"},\"sameAs\":[\"http:\\\/\\\/snehpatel.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Shell Script for ELK installation - Sneh Patel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/","og_locale":"en_US","og_type":"article","og_title":"Shell Script for ELK installation - Sneh Patel","og_description":"This script is only tested in centos. Tweak the script as you like. Please change the version link with a new one. Logstash:- Link Elasticsearch:- Link Kibana:- Link Credit: https:\/\/gist.github.com\/kydouglas\/1f68d69e856fd6d7dc223f8e1f5ae3b3","og_url":"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/","og_site_name":"Sneh Patel","article_published_time":"2019-10-25T23:20:09+00:00","author":"Sneh Patel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sneh Patel","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/#article","isPartOf":{"@id":"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/"},"author":{"name":"Sneh Patel","@id":"https:\/\/snehpatel.com\/#\/schema\/person\/a39105bc63f7e11a0e07b12a4c3dda73"},"headline":"Shell Script for ELK installation","datePublished":"2019-10-25T23:20:09+00:00","mainEntityOfPage":{"@id":"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/"},"wordCount":53,"commentCount":0,"publisher":{"@id":"https:\/\/snehpatel.com\/#\/schema\/person\/a39105bc63f7e11a0e07b12a4c3dda73"},"keywords":["ELK","System"],"articleSection":["ELK","Linux","Logging","System"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/","url":"https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/","name":"Shell Script for ELK installation - Sneh Patel","isPartOf":{"@id":"https:\/\/snehpatel.com\/#website"},"datePublished":"2019-10-25T23:20:09+00:00","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/snehpatel.com\/index.php\/2019\/10\/25\/shell-script-for-elk-installation\/"]}]},{"@type":"WebSite","@id":"https:\/\/snehpatel.com\/#website","url":"https:\/\/snehpatel.com\/","name":"Sneh Patel","description":"Cyber Security Blog","publisher":{"@id":"https:\/\/snehpatel.com\/#\/schema\/person\/a39105bc63f7e11a0e07b12a4c3dda73"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/snehpatel.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/snehpatel.com\/#\/schema\/person\/a39105bc63f7e11a0e07b12a4c3dda73","name":"Sneh Patel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/snehpatel.com\/wp-content\/uploads\/2020\/09\/cropped-Slide4-1.jpg?fit=672%2C222&ssl=1","url":"https:\/\/i0.wp.com\/snehpatel.com\/wp-content\/uploads\/2020\/09\/cropped-Slide4-1.jpg?fit=672%2C222&ssl=1","contentUrl":"https:\/\/i0.wp.com\/snehpatel.com\/wp-content\/uploads\/2020\/09\/cropped-Slide4-1.jpg?fit=672%2C222&ssl=1","width":672,"height":222,"caption":"Sneh Patel"},"logo":{"@id":"https:\/\/i0.wp.com\/snehpatel.com\/wp-content\/uploads\/2020\/09\/cropped-Slide4-1.jpg?fit=672%2C222&ssl=1"},"sameAs":["http:\/\/snehpatel.com"]}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/posts\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":0,"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"wp:attachment":[{"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/snehpatel.com\/index.php\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}