├── .gitignore ├── LICENSE ├── README.md ├── bin ├── beautify-ascii-files.bash ├── tidy-ascii-files.bash └── validate-bash.bash ├── cookbooks ├── akamai-cli │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── ansible │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── ant │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── aws-cli │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── chef-infra-client │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── chrony │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── clean-up │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ ├── install-delete-old-logs.bash │ │ └── install.bash │ └── templates │ │ └── delete-old-logs.bash ├── consul │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── cqlsh │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── cqlsh.sh.profile ├── datadog-agent │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── docker │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── ec2-ami-tools │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── ec2-ami-tools.sh.profile ├── ec2-api-tools │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── ec2-api-tools.sh.profile ├── elastic-search │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── elastic-search.service.systemd ├── essential │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── foodcritic │ └── recipes │ │ └── install.bash ├── go │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── go.sh.profile ├── gocd │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ ├── install-agent.bash │ │ ├── install-server-and-agent.bash │ │ └── install-server.bash │ └── templates │ │ ├── gocd-agent.service.systemd │ │ └── gocd-server.service.systemd ├── groovy │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── groovy.sh.profile ├── haproxy │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── jdk │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── jdk.sh.profile ├── jenkins │ ├── attributes │ │ ├── master.bash │ │ └── slave.bash │ ├── libraries │ │ └── app.bash │ ├── recipes │ │ ├── install-master-plugins.bash │ │ ├── install-master.bash │ │ ├── install-slave.bash │ │ ├── refresh-master-update-center.bash │ │ ├── safe-restart-master.bash │ │ ├── update-master-plugins.bash │ │ └── upgrade-master.bash │ └── templates │ │ ├── jenkins.cron │ │ └── jenkins.sh.profile ├── jq │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── kibana │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ ├── kibana.service.systemd │ │ └── kibana.sh.profile ├── logrotate │ ├── files │ │ ├── logrotate.conf.apt │ │ └── logrotate.conf.rpm │ └── recipes │ │ └── install.bash ├── maven │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── mongodb │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ ├── mongodb.service.systemd │ │ └── mongodb.sh.profile ├── mount-hd │ ├── attributes │ │ └── default.bash │ └── recipes │ │ ├── extend.bash │ │ └── install.bash ├── mysql │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ ├── my.cnf.conf │ │ └── mysql.sh.profile ├── nginx │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ ├── nginx.list.apt │ │ └── nginx.repo ├── node │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── node.sh.profile ├── nomad │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── packer │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── pm2 │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ ├── pm2.logrotate │ │ └── pm2.sh.profile ├── ps1 │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── python │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── python.sh.profile ├── redis │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ ├── redis.conf.conf │ │ ├── redis.service.systemd │ │ └── redis.sh.profile ├── ruby │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── selenium-server │ ├── attributes │ │ ├── hub.bash │ │ └── node.bash │ ├── libraries │ │ └── app.bash │ ├── recipes │ │ ├── install-hub.bash │ │ └── install-node.bash │ └── templates │ │ ├── selenium-server-hub.json.conf │ │ ├── selenium-server-hub.service.systemd │ │ ├── selenium-server-node.json.conf │ │ └── selenium-server-node.service.systemd ├── shell-check │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── cabal.sh.profile ├── splunkforwarder │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ ├── splunk.service.systemd │ │ └── splunk.sh.profile ├── ssh │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── terraform │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── test-ssl │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── test-ssl.sh.profile ├── tmp-reaper │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── tmp-watch │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── tomcat │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── tomcat.service.systemd ├── tweaks │ ├── attributes │ │ └── hugepage.bash │ ├── recipes │ │ ├── disable-hugepage.bash │ │ ├── disable-icmp-timestamp.bash │ │ ├── disable-tcp-timestamp.bash │ │ └── install.bash │ └── templates │ │ └── hugepage.service.systemd ├── ufw │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── ulimit │ ├── files │ │ └── limits.conf │ └── recipes │ │ └── install.bash ├── vault │ ├── attributes │ │ └── default.bash │ └── recipes │ │ └── install.bash ├── vbox-guest-additions │ ├── attributes │ │ └── default.bash │ ├── files │ │ └── vbox-guest-additions.service.systemd │ └── recipes │ │ └── install.bash ├── vim │ ├── files │ │ └── vimrc.local.conf │ └── recipes │ │ └── install.bash ├── vmware-tools │ └── recipes │ │ └── install.bash ├── wildfly │ ├── attributes │ │ └── default.bash │ ├── recipes │ │ └── install.bash │ └── templates │ │ └── wildfly.service.systemd └── zdm-util │ ├── attributes │ └── default.bash │ └── recipes │ └── install.bash ├── libraries ├── aws.bash ├── git.bash └── util.bash ├── roles ├── essential.bash ├── nam │ ├── libraries │ │ └── app.bash │ └── roles │ │ ├── virtual-machine-server.bash │ │ └── vmware-desktop.bash ├── test-cookbooks.bash └── work │ ├── jenkins │ ├── jenkins.bash │ └── templates │ │ └── jenkins-ci.service.systemd │ └── zdm │ ├── jumphost.bash │ └── zdm-proxy.bash └── tools ├── check-system-clock.bash ├── clean-up-jenkins-jobs.bash ├── clean-up.bash ├── clone-all-git-repositories.bash ├── delete-old-logs.bash ├── flush-firewall.bash ├── import-certificates.bash ├── install-build-essential.bash ├── reset-logs.bash ├── run-remote-command.bash ├── start-http-server.bash └── upgrade.bash /.gitignore: -------------------------------------------------------------------------------- 1 | # File 2 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Nam Nguyen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # linux-cookbooks 2 | 3 | | COOKBOOK | AMAZON-LINUX 2 | CENTOS 7 | REDHAT 7 | UBUNTU 18 | 4 | | --------------------- | ------------------ | ------------------ | ------------------ | ------------------ | 5 | | akamai-cli | | :white_check_mark: | | :white_check_mark: | 6 | | ant | | :white_check_mark: | | :white_check_mark: | 7 | | aws-cli | | :white_check_mark: | | :white_check_mark: | 8 | | chef-infra-client | | :white_check_mark: | | :white_check_mark: | 9 | | chrony | | :white_check_mark: | | :white_check_mark: | 10 | | clean-up | | :white_check_mark: | | :white_check_mark: | 11 | | consul | | :white_check_mark: | | :white_check_mark: | 12 | | datadog-agent | | :white_check_mark: | | :white_check_mark: | 13 | | docker | | | | | 14 | | ec2-ami-tools | | | | | 15 | | ec2-api-tools | | | | | 16 | | elastic-search | | | | | 17 | | essential | | :white_check_mark: | | :white_check_mark: | 18 | | foodcritic | | | | | 19 | | gocd | | | | | 20 | | go | | | | | 21 | | groovy | | | | | 22 | | haproxy | | | | | 23 | | jdk | | :white_check_mark: | | :white_check_mark: | 24 | | jenkins | | | | | 25 | | jq | | :white_check_mark: | | :white_check_mark: | 26 | | kibana | | | | | 27 | | logrotate | | | | | 28 | | maven | | :white_check_mark: | | :white_check_mark: | 29 | | mongodb | | | | | 30 | | mount-hd | | | | | 31 | | mysql | | | | | 32 | | nginx | | | | | 33 | | node | | | | | 34 | | nomad | | :white_check_mark: | | :white_check_mark: | 35 | | packer | | :white_check_mark: | | :white_check_mark: | 36 | | pm2 | | | | | 37 | | ps1 | | | | | 38 | | python | | | | | 39 | | redis | | | | | 40 | | ruby | | :white_check_mark: | | :white_check_mark: | 41 | | selenium-server | | | | | 42 | | shell-check | | | | | 43 | | splunkforwarder | | | | | 44 | | ssh | | :white_check_mark: | | :white_check_mark: | 45 | | terraform | | :white_check_mark: | | :white_check_mark: | 46 | | test-ssl | | | | | 47 | | tmp-reaper | | | | | 48 | | tmp-watch | | | | | 49 | | tomcat | | | | | 50 | | tweaks | | | | | 51 | | ufw | | | | | 52 | | ulimit | | :white_check_mark: | | :white_check_mark: | 53 | | vault | | :white_check_mark: | | :white_check_mark: | 54 | | vbox-guest-additions | | | | | 55 | | vim | | :white_check_mark: | | :white_check_mark: | 56 | | vmware-tools | | :white_check_mark: | | :white_check_mark: | 57 | | wildfly | | | | | -------------------------------------------------------------------------------- /bin/beautify-ascii-files.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function removeNewlineAtEndOfFile() 4 | { 5 | local -r repositoryFolderPath="${1}" 6 | 7 | find "${repositoryFolderPath}" \ 8 | -type f \ 9 | \( \ 10 | -name 'authorized_keys' -o \ 11 | -name '*.bash' -o \ 12 | -name '*.conf' -o \ 13 | -name 'known_hosts' -o \ 14 | -name 'LICENSE' -o \ 15 | -name '*.md' -o \ 16 | -name '*.profile' \ 17 | \) \ 18 | \( \ 19 | -not -path "${repositoryFolderPath}/.git/*" \ 20 | \) \ 21 | -print \ 22 | -exec bash -c -e ' 23 | for file 24 | do 25 | printf '%s' "$(< "${file}")" > "${file}" 26 | done' bash '{}' \; 27 | } 28 | 29 | function main() 30 | { 31 | local -r repositoryFolderPath="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 32 | 33 | removeNewlineAtEndOfFile "${repositoryFolderPath}" 34 | } 35 | 36 | main "${@}" -------------------------------------------------------------------------------- /bin/tidy-ascii-files.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | "$(dirname "${BASH_SOURCE[0]}")/beautify-ascii-files.bash" 6 | "$(dirname "${BASH_SOURCE[0]}")/validate-bash.bash" 7 | } 8 | 9 | main "${@}" -------------------------------------------------------------------------------- /bin/validate-bash.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | local -r projectPath="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 6 | 7 | source "${projectPath}/libraries/util.bash" 8 | 9 | local -r command='shellcheck' 10 | 11 | checkExistCommand "${command}" "command '${command}' not found. Run '${projectPath}/cookbooks/shell-check/recipes/install.bash' to install" 12 | 13 | find "${projectPath}" \ 14 | -type f \ 15 | -name '*.bash' \ 16 | -exec "${command}" -e 'SC1090' -s bash '{}' \; \ 17 | -print 18 | } 19 | 20 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/akamai-cli/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export AKAMAI_CLI_DOWNLOAD_URL='https://github.com/akamai/cli/releases/download/v2.0.0/akamai-v2.0.0-linuxamd64' 4 | 5 | export AKAMAI_CLI_INSTALL_FOLDER_PATH='/opt/akamai-cli' -------------------------------------------------------------------------------- /cookbooks/akamai-cli/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | installPortableBinary \ 9 | 'AKAMAI-CLI' \ 10 | "${AKAMAI_CLI_DOWNLOAD_URL}" \ 11 | "${AKAMAI_CLI_INSTALL_FOLDER_PATH}" \ 12 | 'akamai' \ 13 | '--version' \ 14 | 'false' 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/ansible/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export ANSIBLE_VERSION_AMAZON_LINUX='ansible2=2.8' 4 | 5 | export ANSIBLE_PYTHON_VERSION='python3.8' -------------------------------------------------------------------------------- /cookbooks/ansible/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | header 'INSTALLING ANSIBLE' 9 | 10 | checkRequireLinuxSystem 11 | checkRequireRootUser 12 | 13 | if [[ "$(isAmazonLinuxDistributor)" = 'true' ]] 14 | then 15 | amazon-linux-extras install -y "${ANSIBLE_PYTHON_VERSION}" 16 | amazon-linux-extras install -y "${ANSIBLE_VERSION_AMAZON_LINUX}" 17 | ansible --version 18 | elif [[ "$(isUbuntuDistributor)" = 'true' ]] 19 | then 20 | installPackages 'software-properties-common' 21 | add-apt-repository --yes --update ppa:ansible/ansible 22 | installPackages 'ansible' 23 | ansible --version 24 | else 25 | fatal 'FATAL : only support Amazon-Linux, or Ubuntu OS' 26 | fi 27 | } 28 | 29 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/ant/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export ANT_DOWNLOAD_URL='http://www-us.apache.org/dist/ant/binaries/apache-ant-1.10.7-bin.tar.gz' 4 | 5 | export ANT_INSTALL_FOLDER_PATH='/opt/ant' -------------------------------------------------------------------------------- /cookbooks/ant/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function main() 12 | { 13 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 14 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 15 | 16 | installDependencies 17 | installPortableBinary \ 18 | 'ANT' \ 19 | "${ANT_DOWNLOAD_URL}" \ 20 | "${ANT_INSTALL_FOLDER_PATH}" \ 21 | 'bin/ant' \ 22 | '-version' \ 23 | 'true' 24 | } 25 | 26 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/aws-cli/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export AWS_CLI_DOWNLOAD_URL='https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip' 4 | 5 | export AWS_CLI_INSTALL_FOLDER_PATH='/opt/aws-cli' -------------------------------------------------------------------------------- /cookbooks/aws-cli/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | local -r tempFolder="$(getTemporaryFolder)" 8 | 9 | initializeFolder "${AWS_CLI_INSTALL_FOLDER_PATH}" 10 | unzipRemoteFile "${AWS_CLI_DOWNLOAD_URL}" "${tempFolder}" 11 | "${tempFolder}/aws/install" \ 12 | --bin-dir '/usr/bin' \ 13 | --install-dir "${AWS_CLI_INSTALL_FOLDER_PATH}" \ 14 | --update 15 | rm -f -r "${tempFolder}" 16 | chown -R "$(whoami):$(whoami)" "${AWS_CLI_INSTALL_FOLDER_PATH}" 17 | displayVersion "$('/usr/bin/aws' --version 2>&1)" 18 | 19 | umask '0077' 20 | } 21 | 22 | function main() 23 | { 24 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 25 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 26 | 27 | header 'INSTALLING AWS-CLI' 28 | 29 | checkRequireLinuxSystem 30 | checkRequireRootUser 31 | 32 | install 33 | installCleanUp 34 | } 35 | 36 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/chef-infra-client/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export CHEF_INFRA_CLIENT_DOWNLOAD_URL='https://www.chef.io/chef/install.sh' 4 | 5 | export CHEF_INFRA_CLIENT_INSTALL_FOLDER_PATH='/opt/chef' -------------------------------------------------------------------------------- /cookbooks/chef-infra-client/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | installPortableBinary \ 9 | 'CHEF-INFRA-CLIENT' \ 10 | "${CHEF_INFRA_CLIENT_DOWNLOAD_URL}" \ 11 | "${CHEF_INFRA_CLIENT_INSTALL_FOLDER_PATH}" \ 12 | 'bin/chef-apply, bin/chef-client, bin/chef-shell, bin/chef-solo, bin/knife, bin/ohai' \ 13 | '-v' \ 14 | 'true' 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/chrony/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | if [[ "$(isAmazonLinuxDistributor)" = 'true' || "$(isCentOSDistributor)" = 'true' || "$(isRedHatDistributor)" = 'true' ]] 8 | then 9 | setenforce 0 || true 10 | fi 11 | 12 | timedatectl set-timezone "${CHRONY_TIME_ZONE}" 13 | 14 | if [[ "$(isAmazonLinuxDistributor)" = 'true' || "$(isCentOSDistributor)" = 'true' || "$(isRedHatDistributor)" = 'true' ]] 15 | then 16 | setenforce 1 || true 17 | fi 18 | 19 | installPackages 'chrony' 20 | mkdir -p '/var/log/chrony' 21 | chmod 755 '/var/log/chrony' 22 | 23 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 24 | then 25 | chown -R '_chrony:_chrony' '/var/log/chrony' 26 | restartService 'chrony' 27 | else 28 | chown -R 'chrony:chrony' '/var/log/chrony' 29 | restartService 'chronyd' 30 | fi 31 | 32 | header 'DISPLAYING CURRENT DATE TIME' 33 | info "$(date)" 34 | 35 | umask '0077' 36 | } 37 | 38 | function main() 39 | { 40 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 41 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 42 | 43 | header 'INSTALLING CHRONY' 44 | 45 | checkRequireLinuxSystem 46 | checkRequireRootUser 47 | 48 | install 49 | installCleanUp 50 | } 51 | 52 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/clean-up/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export CLEAN_UP_OLD_LOG_FOLDER_PATHS=( 4 | '/var/log' 5 | ) -------------------------------------------------------------------------------- /cookbooks/clean-up/recipes/install-delete-old-logs.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | createFileFromTemplate \ 8 | "$(dirname "${BASH_SOURCE[0]}")/../templates/delete-old-logs.bash" \ 9 | '/etc/cron.hourly/delete-old-logs' \ 10 | '__LOG_FOLDER_PATHS__' "$(arrayToParameters "${CLEAN_UP_OLD_LOG_FOLDER_PATHS[@]}")" 11 | 12 | chmod 755 '/etc/cron.hourly/delete-old-logs' 13 | cat '/etc/cron.hourly/delete-old-logs' 14 | echo 15 | 16 | umask '0077' 17 | } 18 | 19 | function main() 20 | { 21 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 22 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 23 | 24 | header 'INSTALLING DELETE-OLD-LOGS' 25 | 26 | checkRequireLinuxSystem 27 | checkRequireRootUser 28 | 29 | install 30 | installCleanUp 31 | } 32 | 33 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/clean-up/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | "$(dirname "${BASH_SOURCE[0]}")/install-delete-old-logs.bash" 6 | } 7 | 8 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/clean-up/templates/delete-old-logs.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | local logFolderPaths=("${@}") 6 | 7 | # Default Log Folder Path 8 | 9 | if [[ "${#logFolderPaths[@]}" -lt '1' ]] 10 | then 11 | logFolderPaths+=('/var/log') 12 | fi 13 | 14 | # Walk Each Log Folder Path 15 | 16 | local i=0 17 | 18 | for ((i = 0; i < ${#logFolderPaths[@]}; i = i + 1)) 19 | do 20 | if [[ "${logFolderPaths[i]}" = '' || ! -d "${logFolderPaths[i]}" ]] 21 | then 22 | echo -e "\033[1;31mERROR: folder '${logFolderPaths[i]}' not found\033[0m" 1>&2 23 | else 24 | find \ 25 | -L \ 26 | "${logFolderPaths[i]}" \ 27 | -type f \ 28 | \( \ 29 | -regex '.*-[0-9]+' -o \ 30 | -regex '.*\.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\.log' -o \ 31 | -regex '.*\.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\.txt' -o \ 32 | -regex '.*\.[0-9]+' -o \ 33 | -regex '.*\.[0-9]+\.log' -o \ 34 | -regex '.*\.gz' -o \ 35 | -regex '.*\.log\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' -o \ 36 | -regex '.*\.old' -o \ 37 | -regex '.*\.xz' \ 38 | \) \ 39 | -delete \ 40 | -print 41 | fi 42 | done 43 | } 44 | 45 | main __LOG_FOLDER_PATHS__ -------------------------------------------------------------------------------- /cookbooks/consul/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export CONSUL_DOWNLOAD_URL='https://releases.hashicorp.com/consul/1.6.1/consul_1.6.1_linux_amd64.zip' 4 | 5 | export CONSUL_INSTALL_FOLDER_PATH='/opt/consul' -------------------------------------------------------------------------------- /cookbooks/consul/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | installPortableBinary \ 9 | 'CONSUL' \ 10 | "${CONSUL_DOWNLOAD_URL}" \ 11 | "${CONSUL_INSTALL_FOLDER_PATH}" \ 12 | 'consul' \ 13 | 'version' \ 14 | 'true' 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/cqlsh/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export CQLSH_DOWNLOAD_URL='https://downloads.datastax.com/enterprise/cqlsh-6.9.tar.gz' 4 | 5 | export CQLSH_INSTALL_FOLDER_PATH='/opt/cqlsh' 6 | 7 | export CQLSH_PYTHON_VERSION='python3.8' -------------------------------------------------------------------------------- /cookbooks/cqlsh/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installPython() 4 | { 5 | if [[ "$(isAmazonLinuxDistributor)" = 'true' ]] 6 | then 7 | umask '0022' 8 | amazon-linux-extras install -y "${CQLSH_PYTHON_VERSION}" 9 | createFileFromTemplate \ 10 | "$(dirname "${BASH_SOURCE[0]}")/../templates/cqlsh.sh.profile" \ 11 | '/etc/profile.d/cqlsh.sh' \ 12 | '__PYTHON_INTERPRETER_FILE_PATH__' \ 13 | "/usr/bin/${CQLSH_PYTHON_VERSION}" 14 | umask '0077' 15 | elif [[ "$(isUbuntuDistributor)" = 'true' ]] 16 | then 17 | umask '0022' 18 | add-apt-repository --yes --update 'ppa:deadsnakes/ppa' 19 | apt-get update -m 20 | installPackages "${CQLSH_PYTHON_VERSION}" 21 | createFileFromTemplate \ 22 | "$(dirname "${BASH_SOURCE[0]}")/../templates/cqlsh.sh.profile" \ 23 | '/etc/profile.d/cqlsh.sh' \ 24 | '__PYTHON_INTERPRETER_FILE_PATH__' \ 25 | "/usr/bin/${CQLSH_PYTHON_VERSION}" 26 | umask '0077' 27 | else 28 | fatal 'FATAL : only support Amazon-Linux, or Ubuntu OS' 29 | fi 30 | } 31 | 32 | function installCQLSH() 33 | { 34 | umask '0022' 35 | initializeFolder "${CQLSH_INSTALL_FOLDER_PATH}" 36 | unzipRemoteFile "${CQLSH_DOWNLOAD_URL}" "${CQLSH_INSTALL_FOLDER_PATH}" 37 | rm -f '/usr/bin/cqlsh' 38 | ln -f -s "${CQLSH_INSTALL_FOLDER_PATH}/bin/cqlsh" '/usr/bin/cqlsh' 39 | source '/etc/profile.d/cqlsh.sh' 40 | '/usr/bin/cqlsh' --version 41 | umask '0077' 42 | } 43 | 44 | function main() 45 | { 46 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 47 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 48 | 49 | header 'INSTALLING CQLSH' 50 | 51 | checkRequireLinuxSystem 52 | checkRequireRootUser 53 | 54 | installPython 55 | installCQLSH 56 | } 57 | 58 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/cqlsh/templates/cqlsh.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export CQLSH_PYTHON='__PYTHON_INTERPRETER_FILE_PATH__' -------------------------------------------------------------------------------- /cookbooks/datadog-agent/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export DATADOG_AGENT_DOWNLOAD_URL='https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh' 4 | 5 | export DATADOG_AGENT_API_KEY='00000000000000000000000000000000' -------------------------------------------------------------------------------- /cookbooks/datadog-agent/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | export DD_API_KEY="${DATADOG_AGENT_API_KEY}" 8 | curl -s -L "${DATADOG_AGENT_DOWNLOAD_URL}" --retry 12 --retry-delay 5 | bash -e 9 | restartService 'datadog-agent' 10 | rm -f "$(pwd)/ddagent-install.log" 11 | displayVersion "$('/usr/bin/datadog-agent' version)" 12 | 13 | umask '0077' 14 | } 15 | 16 | function main() 17 | { 18 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 19 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 20 | 21 | header 'INSTALLING DATADOG-AGENT' 22 | 23 | checkRequireLinuxSystem 24 | checkRequireRootUser 25 | 26 | install 27 | installCleanUp 28 | } 29 | 30 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/docker/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export DOCKER_DOWNLOAD_URL='https://get.docker.com' -------------------------------------------------------------------------------- /cookbooks/docker/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | if [[ "$(isAmazonLinuxDistributor)" = 'true' ]] 8 | then 9 | amazon-linux-extras install -y 'docker' 10 | startService 'docker' 11 | elif [[ "$(isUbuntuDistributor)" = 'true' ]] 12 | then 13 | checkExistURL "${DOCKER_DOWNLOAD_URL}" 14 | curl -L "${DOCKER_DOWNLOAD_URL}" --retry 12 --retry-delay 5 | bash -e 15 | startService 'docker' 16 | else 17 | fatal 'FATAL : only support Amazon-Linux, or Ubuntu OS' 18 | fi 19 | 20 | umask '0077' 21 | } 22 | 23 | function main() 24 | { 25 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 26 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 27 | 28 | header 'INSTALLING DOCKER' 29 | 30 | checkRequireLinuxSystem 31 | checkRequireRootUser 32 | 33 | install 34 | installCleanUp 35 | } 36 | 37 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/ec2-ami-tools/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | source "$(dirname "${BASH_SOURCE[0]}")/../../ruby/attributes/default.bash" 4 | 5 | export EC2_AMI_TOOLS_DOWNLOAD_URL='http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip' 6 | 7 | export EC2_AMI_TOOLS_INSTALL_FOLDER_PATH='/opt/ec2-ami-tools' 8 | export EC2_AMI_TOOLS_RUBY_INSTALL_FOLDER_PATH="${RUBY_INSTALL_FOLDER_PATH}" -------------------------------------------------------------------------------- /cookbooks/ec2-ami-tools/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'ruby')" = 'false' || ! -d "${EC2_AMI_TOOLS_RUBY_INSTALL_FOLDER_PATH}" ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../ruby/recipes/install.bash" "${EC2_AMI_TOOLS_RUBY_INSTALL_FOLDER_PATH}" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | # Clean Up 16 | 17 | initializeFolder "${EC2_AMI_TOOLS_INSTALL_FOLDER_PATH}" 18 | 19 | # Install 20 | 21 | unzipRemoteFile "${EC2_AMI_TOOLS_DOWNLOAD_URL}" "${EC2_AMI_TOOLS_INSTALL_FOLDER_PATH}" 22 | 23 | local -r unzipFolder="$( 24 | find "${EC2_AMI_TOOLS_INSTALL_FOLDER_PATH}" \ 25 | -maxdepth 1 \ 26 | -xtype d \ 27 | 2> '/dev/null' | 28 | tail -1 29 | )" 30 | 31 | if [[ "$(isEmptyString "${unzipFolder}")" = 'true' || "$(trimString "$(wc -l <<< "${unzipFolder}")")" != '1' ]] 32 | then 33 | fatal 'FATAL : multiple unzip folder names found' 34 | fi 35 | 36 | if [[ "$(ls -A "${unzipFolder}")" = '' ]] 37 | then 38 | fatal "FATAL : folder '${unzipFolder}' empty" 39 | fi 40 | 41 | # Move Folder 42 | 43 | moveFolderContent "${unzipFolder}" "${EC2_AMI_TOOLS_INSTALL_FOLDER_PATH}" 44 | symlinkUsrBin "${EC2_AMI_TOOLS_INSTALL_FOLDER_PATH}/bin" 45 | rm -f -r "${unzipFolder}" 46 | 47 | # Config Profile 48 | 49 | createFileFromTemplate \ 50 | "$(dirname "${BASH_SOURCE[0]}")/../templates/ec2-ami-tools.sh.profile" \ 51 | '/etc/profile.d/ec2-ami-tools.sh' \ 52 | '__INSTALL_FOLDER_PATH__' \ 53 | "${EC2_AMI_TOOLS_INSTALL_FOLDER_PATH}" 54 | 55 | # Display Version 56 | 57 | displayVersion "$(ec2-ami-tools-version)" 58 | 59 | umask '0077' 60 | } 61 | 62 | function main() 63 | { 64 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 65 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 66 | 67 | header 'INSTALLING EC2-AMI-TOOLS' 68 | 69 | checkRequireLinuxSystem 70 | checkRequireRootUser 71 | 72 | installDependencies 73 | install 74 | installCleanUp 75 | } 76 | 77 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/ec2-ami-tools/templates/ec2-ami-tools.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/ec2-api-tools/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export EC2_API_TOOLS_DOWNLOAD_URL='http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip' 4 | 5 | export EC2_API_TOOLS_INSTALL_FOLDER_PATH='/opt/ec2-api-tools' -------------------------------------------------------------------------------- /cookbooks/ec2-api-tools/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | initializeFolder "${EC2_API_TOOLS_INSTALL_FOLDER_PATH}" 16 | 17 | unzipRemoteFile "${EC2_API_TOOLS_DOWNLOAD_URL}" "${EC2_API_TOOLS_INSTALL_FOLDER_PATH}" 18 | 19 | local -r unzipFolder="$( 20 | find "${EC2_API_TOOLS_INSTALL_FOLDER_PATH}" \ 21 | -maxdepth 1 \ 22 | -xtype d \ 23 | 2> '/dev/null' | 24 | tail -1 25 | )" 26 | 27 | if [[ "$(isEmptyString "${unzipFolder}")" = 'true' || "$(trimString "$(wc -l <<< "${unzipFolder}")")" != '1' ]] 28 | then 29 | fatal 'FATAL : multiple unzip folder names found' 30 | fi 31 | 32 | if [[ "$(ls -A "${unzipFolder}")" = '' ]] 33 | then 34 | fatal "FATAL : folder '${unzipFolder}' empty" 35 | fi 36 | 37 | moveFolderContent "${unzipFolder}" "${EC2_API_TOOLS_INSTALL_FOLDER_PATH}" 38 | rm -f -r "${unzipFolder}" 39 | 40 | createFileFromTemplate \ 41 | "$(dirname "${BASH_SOURCE[0]}")/../templates/ec2-api-tools.sh.profile" \ 42 | '/etc/profile.d/ec2-api-tools.sh' \ 43 | '__INSTALL_FOLDER_PATH__' \ 44 | "${EC2_API_TOOLS_INSTALL_FOLDER_PATH}" 45 | 46 | umask '0077' 47 | } 48 | 49 | function main() 50 | { 51 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 52 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 53 | 54 | header 'INSTALLING EC2-API-TOOLS' 55 | 56 | checkRequireLinuxSystem 57 | checkRequireRootUser 58 | 59 | installDependencies 60 | install 61 | installCleanUp 62 | } 63 | 64 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/ec2-api-tools/templates/ec2-api-tools.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export EC2_HOME='__INSTALL_FOLDER_PATH__' 4 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/elastic-search/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export ELASTIC_SEARCH_DOWNLOAD_URL='https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-linux-x86_64.tar.gz' 4 | 5 | export ELASTIC_SEARCH_INSTALL_FOLDER_PATH='/opt/elastic-search' 6 | 7 | export ELASTIC_SEARCH_SERVICE_NAME='elastic-search' 8 | 9 | export ELASTIC_SEARCH_USER_NAME='elastic' 10 | export ELASTIC_SEARCH_GROUP_NAME='elastic' -------------------------------------------------------------------------------- /cookbooks/elastic-search/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | initializeFolder "${ELASTIC_SEARCH_INSTALL_FOLDER_PATH}" 16 | unzipRemoteFile "${ELASTIC_SEARCH_DOWNLOAD_URL}" "${ELASTIC_SEARCH_INSTALL_FOLDER_PATH}" 17 | 18 | createInitFileFromTemplate \ 19 | "${ELASTIC_SEARCH_SERVICE_NAME}" \ 20 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 21 | '__INSTALL_FOLDER_PATH__' "${ELASTIC_SEARCH_INSTALL_FOLDER_PATH}" \ 22 | '__USER_NAME__' "${ELASTIC_SEARCH_USER_NAME}" \ 23 | '__GROUP_NAME__' "${ELASTIC_SEARCH_GROUP_NAME}" 24 | 25 | addUser "${ELASTIC_SEARCH_USER_NAME}" "${ELASTIC_SEARCH_GROUP_NAME}" 'false' 'true' 'false' 26 | chown -R "${ELASTIC_SEARCH_USER_NAME}:${ELASTIC_SEARCH_GROUP_NAME}" "${ELASTIC_SEARCH_INSTALL_FOLDER_PATH}" 27 | startService "${ELASTIC_SEARCH_SERVICE_NAME}" 28 | 29 | displayOpenPorts '10' 30 | displayVersion "$(elasticsearch --version)" 31 | 32 | umask '0077' 33 | } 34 | 35 | function main() 36 | { 37 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 38 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 39 | 40 | header 'INSTALLING ELASTIC SEARCH' 41 | 42 | checkRequireLinuxSystem 43 | checkRequireRootUser 44 | checkRequirePorts '9200' '9300' 45 | 46 | installDependencies 47 | install 48 | installCleanUp 49 | } 50 | 51 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/elastic-search/templates/elastic-search.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Elastic-Search Server 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | ExecStartPre=/bin/bash -c -e '\ 35 | find \'__INSTALL_FOLDER_PATH__/logs\' -mindepth 1 -delete \ 36 | ' 37 | ExecStart='__INSTALL_FOLDER_PATH__/bin/elasticsearch' -------------------------------------------------------------------------------- /cookbooks/essential/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export APT_ESSENTIAL_PACKAGES=( 4 | 'ack' 5 | 'auditd' 6 | 'bzip2' 7 | 'curl' 8 | 'dialog' 9 | 'gawk' 10 | 'git' 11 | 'glances' 12 | 'hping3' 13 | 'htop' 14 | 'iptables' 15 | 'libfontconfig' 16 | 'libxml2-utils' 17 | 'logrotate' 18 | 'lsb-release' 19 | 'lsof' 20 | 'mtr-tiny' 21 | 'ncdu' 22 | 'net-tools' 23 | 'netcat' 24 | 'nmap' 25 | 'parallel' 26 | 'rsync' 27 | 'software-properties-common' 28 | 'tmux' 29 | 'tree' 30 | 'unzip' 31 | 'wget' 32 | ) 33 | 34 | export RPM_ESSENTIAL_PACKAGES=( 35 | # Requirement 36 | 'epel-release' 37 | # Packages 38 | 'ack' 39 | 'audit' 40 | 'bzip2' 41 | 'curl' 42 | 'dialog' 43 | 'fontconfig' 44 | 'gawk' 45 | 'git' 46 | 'glances' 47 | 'hping3' 48 | 'htop' 49 | 'iptables' 50 | 'libxml2' 51 | 'logrotate' 52 | 'lsof' 53 | 'mtr' 54 | 'nc' 55 | 'ncdu' 56 | 'nmap' 57 | 'parallel' 58 | 'rsync' 59 | 'tmux' 60 | 'tree' 61 | 'unzip' 62 | 'wget' 63 | ) -------------------------------------------------------------------------------- /cookbooks/essential/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | runUpgrade 6 | } 7 | 8 | function install() 9 | { 10 | umask '0022' 11 | 12 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 13 | then 14 | installPackages "${APT_ESSENTIAL_PACKAGES[@]}" 15 | else 16 | installPackages "${RPM_ESSENTIAL_PACKAGES[@]}" 17 | fi 18 | 19 | umask '0077' 20 | } 21 | 22 | function main() 23 | { 24 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 25 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 26 | 27 | header 'INSTALLING ESSENTIAL PACKAGES' 28 | 29 | checkRequireLinuxSystem 30 | checkRequireRootUser 31 | 32 | installDependencies 33 | install 34 | installCleanUp 35 | } 36 | 37 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/foodcritic/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'ruby')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../ruby/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | gem install foodcritic 16 | 17 | if [[ -f "${RUBY_INSTALL_FOLDER_PATH}/bin/foodcritic" ]] 18 | then 19 | symlinkListUsrBin "${RUBY_INSTALL_FOLDER_PATH}/bin/foodcritic" 20 | fi 21 | 22 | displayVersion "$(foodcritic --version)" 23 | 24 | umask '0077' 25 | } 26 | 27 | function main() 28 | { 29 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 30 | source "$(dirname "${BASH_SOURCE[0]}")/../../ruby/attributes/default.bash" 31 | 32 | header 'INSTALLING FOODCRITIC' 33 | 34 | checkRequireLinuxSystem 35 | checkRequireRootUser 36 | 37 | installDependencies 38 | install 39 | installCleanUp 40 | } 41 | 42 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/go/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export GO_DOWNLOAD_URL='https://go.dev/dl/go1.20.2.linux-amd64.tar.gz' 4 | 5 | export GO_INSTALL_FOLDER_PATH='/opt/go' -------------------------------------------------------------------------------- /cookbooks/go/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | initializeFolder "${GO_INSTALL_FOLDER_PATH}" 8 | unzipRemoteFile "${GO_DOWNLOAD_URL}" "${GO_INSTALL_FOLDER_PATH}" 9 | chown -R "$(whoami):$(whoami)" "${GO_INSTALL_FOLDER_PATH}" 10 | symlinkUsrBin "${GO_INSTALL_FOLDER_PATH}/bin" 11 | ln -f -s "${GO_INSTALL_FOLDER_PATH}" '/usr/local/go' 12 | 13 | createFileFromTemplate \ 14 | "$(dirname "${BASH_SOURCE[0]}")/../templates/go.sh.profile" \ 15 | '/etc/profile.d/go.sh' \ 16 | '__INSTALL_FOLDER_PATH__' "${GO_INSTALL_FOLDER_PATH}" 17 | 18 | export GOROOT="${GO_INSTALL_FOLDER_PATH}" 19 | displayVersion "$(go version)" 20 | 21 | umask '0077' 22 | } 23 | 24 | function main() 25 | { 26 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 27 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 28 | 29 | header 'INSTALLING GO' 30 | 31 | checkRequireLinuxSystem 32 | checkRequireRootUser 33 | 34 | install 35 | installCleanUp 36 | } 37 | 38 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/go/templates/go.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export GOROOT='__INSTALL_FOLDER_PATH__' 4 | export PATH="${GOROOT}/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/gocd/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export GOCD_AGENT_DOWNLOAD_URL='https://download.gocd.org/binaries/19.10.0-10357/generic/go-agent-19.10.0-10357.zip' 4 | export GOCD_SERVER_DOWNLOAD_URL='https://download.gocd.org/binaries/19.10.0-10357/generic/go-server-19.10.0-10357.zip' 5 | 6 | export GOCD_AGENT_INSTALL_FOLDER_PATH='/opt/gocd/agents/agent' 7 | export GOCD_SERVER_INSTALL_FOLDER_PATH='/opt/gocd/server' 8 | 9 | export GOCD_AGENT_SERVICE_NAME='gocd-agent' 10 | export GOCD_SERVER_SERVICE_NAME='gocd-server' 11 | 12 | export GOCD_GROUP_NAME='go' 13 | export GOCD_USER_NAME='go' -------------------------------------------------------------------------------- /cookbooks/gocd/recipes/install-agent.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | local serverHostname="${1}" 14 | 15 | umask '0022' 16 | 17 | # Clean Up 18 | 19 | initializeFolder "${GOCD_AGENT_INSTALL_FOLDER_PATH}" 20 | 21 | # Install 22 | 23 | unzipRemoteFile "${GOCD_AGENT_DOWNLOAD_URL}" "${GOCD_AGENT_INSTALL_FOLDER_PATH}" 24 | 25 | local -r unzipFolder="$( 26 | find "${GOCD_AGENT_INSTALL_FOLDER_PATH}" \ 27 | -maxdepth 1 \ 28 | -xtype d \ 29 | 2> '/dev/null' | 30 | tail -1 31 | )" 32 | 33 | if [[ "$(isEmptyString "${unzipFolder}")" = 'true' || "$(trimString "$(wc -l <<< "${unzipFolder}")")" != '1' ]] 34 | then 35 | fatal 'FATAL : multiple unzip folder names found' 36 | fi 37 | 38 | if [[ "$(ls -A "${unzipFolder}")" = '' ]] 39 | then 40 | fatal "FATAL : folder '${unzipFolder}' empty" 41 | fi 42 | 43 | # Move Folder 44 | 45 | moveFolderContent "${unzipFolder}" "${GOCD_AGENT_INSTALL_FOLDER_PATH}" 46 | 47 | # Finalize 48 | 49 | addUser "${GOCD_USER_NAME}" "${GOCD_GROUP_NAME}" 'true' 'false' 'true' 50 | chown -R "${GOCD_USER_NAME}:${GOCD_GROUP_NAME}" "${GOCD_AGENT_INSTALL_FOLDER_PATH}" 51 | rm -f -r "${unzipFolder}" 52 | 53 | # Config Init 54 | 55 | if [[ "$(isEmptyString "${serverHostname}")" = 'true' ]] 56 | then 57 | serverHostname='127.0.0.1' 58 | fi 59 | 60 | createInitFileFromTemplate \ 61 | "${GOCD_AGENT_SERVICE_NAME}" \ 62 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 63 | '__AGENT_INSTALL_FOLDER_PATH__' "${GOCD_AGENT_INSTALL_FOLDER_PATH}" \ 64 | '__SERVER_HOSTNAME__' "${serverHostname}" \ 65 | '__GO_HOME_FOLDER__' "$(getUserHomeFolder "${GOCD_USER_NAME}")" \ 66 | '__USER_NAME__' "${GOCD_USER_NAME}" \ 67 | '__GROUP_NAME__' "${GOCD_GROUP_NAME}" 68 | 69 | # Start 70 | 71 | startService "${GOCD_AGENT_SERVICE_NAME}" 72 | 73 | umask '0077' 74 | } 75 | 76 | function main() 77 | { 78 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 79 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 80 | 81 | header 'INSTALLING GOCD AGENT' 82 | 83 | checkRequireLinuxSystem 84 | checkRequireRootUser 85 | 86 | installDependencies 87 | install "${@}" 88 | installCleanUp 89 | } 90 | 91 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/gocd/recipes/install-server-and-agent.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | "$(dirname "${BASH_SOURCE[0]}")/install-server.bash" 8 | "$(dirname "${BASH_SOURCE[0]}")/install-agent.bash" 9 | 10 | umask '0077' 11 | } 12 | 13 | function main() 14 | { 15 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 16 | 17 | checkRequireLinuxSystem 18 | checkRequireRootUser 19 | 20 | install 21 | installCleanUp 22 | } 23 | 24 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/gocd/recipes/install-server.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | # Clean Up 16 | 17 | initializeFolder "${GOCD_SERVER_INSTALL_FOLDER_PATH}" 18 | 19 | # Install 20 | 21 | unzipRemoteFile "${GOCD_SERVER_DOWNLOAD_URL}" "${GOCD_SERVER_INSTALL_FOLDER_PATH}" 22 | 23 | local -r unzipFolder="$( 24 | find "${GOCD_SERVER_INSTALL_FOLDER_PATH}" \ 25 | -maxdepth 1 \ 26 | -xtype d \ 27 | 2> '/dev/null' | 28 | tail -1 29 | )" 30 | 31 | if [[ "$(isEmptyString "${unzipFolder}")" = 'true' || "$(trimString "$(wc -l <<< "${unzipFolder}")")" != '1' ]] 32 | then 33 | fatal 'FATAL : multiple unzip folder names found' 34 | fi 35 | 36 | if [[ "$(ls -A "${unzipFolder}")" = '' ]] 37 | then 38 | fatal "FATAL : folder '${unzipFolder}' empty" 39 | fi 40 | 41 | # Move Folder 42 | 43 | moveFolderContent "${unzipFolder}" "${GOCD_SERVER_INSTALL_FOLDER_PATH}" 44 | 45 | # Finalize 46 | 47 | addUser "${GOCD_USER_NAME}" "${GOCD_GROUP_NAME}" 'true' 'false' 'true' 48 | chown -R "${GOCD_USER_NAME}:${GOCD_GROUP_NAME}" "${GOCD_SERVER_INSTALL_FOLDER_PATH}" 49 | rm -f -r "${unzipFolder}" 50 | 51 | # Config Init 52 | 53 | createInitFileFromTemplate \ 54 | "${GOCD_SERVER_SERVICE_NAME}" \ 55 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 56 | '__SERVER_INSTALL_FOLDER_PATH__' "${GOCD_SERVER_INSTALL_FOLDER_PATH}" \ 57 | '__GO_HOME_FOLDER__' "$(getUserHomeFolder "${GOCD_USER_NAME}")" \ 58 | '__USER_NAME__' "${GOCD_USER_NAME}" \ 59 | '__GROUP_NAME__' "${GOCD_GROUP_NAME}" 60 | 61 | # Start 62 | 63 | startService "${GOCD_SERVER_SERVICE_NAME}" 64 | 65 | # Display Open Ports 66 | 67 | displayOpenPorts '45' 68 | 69 | umask '0077' 70 | } 71 | 72 | function main() 73 | { 74 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 75 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 76 | 77 | header 'INSTALLING GOCD SERVER' 78 | 79 | checkRequireLinuxSystem 80 | checkRequireRootUser 81 | checkRequirePorts '8153' '8154' 82 | 83 | installDependencies 84 | install 85 | installCleanUp 86 | } 87 | 88 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/gocd/templates/gocd-agent.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=GoCD Agent 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | Environment='HOME=__GO_HOME_FOLDER__' 35 | 36 | WorkingDirectory=__AGENT_INSTALL_FOLDER_PATH__ 37 | 38 | ExecStart=/bin/bash -c -e 'java -jar 'agent-bootstrapper.jar' '__SERVER_HOSTNAME__'' -------------------------------------------------------------------------------- /cookbooks/gocd/templates/gocd-server.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=GoCD Server 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | Environment='HOME=__GO_HOME_FOLDER__' 35 | 36 | WorkingDirectory=__SERVER_INSTALL_FOLDER_PATH__ 37 | 38 | ExecStart=/bin/bash -c -e 'java -jar 'go.jar'' -------------------------------------------------------------------------------- /cookbooks/groovy/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export GROOVY_DOWNLOAD_URL='https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.5.8.zip' 4 | 5 | export GROOVY_INSTALL_FOLDER_PATH='/opt/groovy' -------------------------------------------------------------------------------- /cookbooks/groovy/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | # Clean Up 16 | 17 | initializeFolder "${GROOVY_INSTALL_FOLDER_PATH}" 18 | 19 | # Install 20 | 21 | unzipRemoteFile "${GROOVY_DOWNLOAD_URL}" "${GROOVY_INSTALL_FOLDER_PATH}" 22 | 23 | local -r unzipFolder="$( 24 | find "${GROOVY_INSTALL_FOLDER_PATH}" \ 25 | -maxdepth 1 \ 26 | -xtype d \ 27 | 2> '/dev/null' | 28 | tail -1 29 | )" 30 | 31 | if [[ "$(isEmptyString "${unzipFolder}")" = 'true' || "$(wc -l <<< "${unzipFolder}")" != '1' ]] 32 | then 33 | fatal 'FATAL : multiple unzip folder names found' 34 | fi 35 | 36 | if [[ "$(ls -A "${unzipFolder}")" = '' ]] 37 | then 38 | fatal "FATAL : folder '${unzipFolder}' empty" 39 | fi 40 | 41 | # Move Folder 42 | 43 | moveFolderContent "${unzipFolder}" "${GROOVY_INSTALL_FOLDER_PATH}" 44 | rm -f -r "${unzipFolder}" 45 | 46 | # Config Lib 47 | 48 | chown -R "$(whoami):$(whoami)" "${GROOVY_INSTALL_FOLDER_PATH}" 49 | symlinkListUsrBin "${GROOVY_INSTALL_FOLDER_PATH}/bin/groovy" 50 | 51 | # Config Profile 52 | 53 | createFileFromTemplate \ 54 | "$(dirname "${BASH_SOURCE[0]}")/../templates/groovy.sh.profile" \ 55 | '/etc/profile.d/groovy.sh' \ 56 | '__INSTALL_FOLDER_PATH__' "${GROOVY_INSTALL_FOLDER_PATH}" 57 | 58 | # Display Version 59 | 60 | displayVersion "$(groovy --version)" 61 | 62 | umask '0077' 63 | } 64 | 65 | function main() 66 | { 67 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 68 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 69 | 70 | header 'INSTALLING GROOVY' 71 | 72 | checkRequireLinuxSystem 73 | checkRequireRootUser 74 | 75 | installDependencies 76 | install 77 | installCleanUp 78 | } 79 | 80 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/groovy/templates/groovy.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/haproxy/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export HAPROXY_VERSION='1.8' -------------------------------------------------------------------------------- /cookbooks/haproxy/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | if [[ "${HAPROXY_VERSION}" != '1.4' ]] 8 | then 9 | info '\nadd-apt-repository' 10 | add-apt-repository -y "ppa:vbernat/haproxy-${HAPROXY_VERSION}" 11 | 12 | info '\napt-get update' 13 | apt-get update -m 14 | fi 15 | 16 | installPackages 'haproxy' 17 | 18 | # Enable Haproxy 19 | 20 | if [[ "${HAPROXY_VERSION}" = '1.4' ]] 21 | then 22 | echo 'ENABLED=1' > '/etc/default/haproxy' 23 | fi 24 | 25 | # Display Open Ports 26 | 27 | displayOpenPorts '5' 28 | 29 | # Display Version 30 | 31 | displayVersion "$(haproxy -vv 2>&1)" 32 | 33 | umask '0077' 34 | } 35 | 36 | function main() 37 | { 38 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 39 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 40 | 41 | header 'INSTALLING HAPROXY' 42 | 43 | checkRequireLinuxSystem 44 | checkRequireRootUser 45 | 46 | install 47 | installCleanUp 48 | } 49 | 50 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jdk/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export JDK_DOWNLOAD_URL='https://www.dropbox.com/scl/fi/kx80nxd0uno0jwai4v7xw/jdk-23_linux-x64_bin.tar.gz?rlkey=il208c7isivlkkqo2uj02d1y5&dl=1' 4 | # export JDK_DOWNLOAD_URL='https://www.dropbox.com/scl/fi/4fpj1h764m7nlsgs02n0t/jdk-21_linux-x64_bin.tar.gz?rlkey=8h43zzby8s269ixkfw207x3lz&dl=1' 5 | # export JDK_DOWNLOAD_URL='https://www.dropbox.com/scl/fi/vvju215ky27bci8itpm5z/jdk-17.0.14_linux-x64_bin.tar.gz?rlkey=4zfnzm66kxaad4zw3r6c6qq6j&dl=1' 6 | # export JDK_DOWNLOAD_URL='https://www.dropbox.com/scl/fi/u9suklxb7xj741zirvcm7/jdk-11.0.26_linux-x64_bin.tar.gz?rlkey=rrupf7tuyomzq9gxee75jk17h&dl=1' 7 | # export JDK_DOWNLOAD_URL='https://www.dropbox.com/scl/fi/ntuetb2ckwda2g3y2hgok/jdk-8u441-linux-x64.tar.gz?rlkey=488i4u37fzb053fpq8y2kzand&dl=1' 8 | 9 | export JDK_INSTALL_FOLDER_PATH='/opt/jdk' -------------------------------------------------------------------------------- /cookbooks/jdk/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | initializeFolder "${JDK_INSTALL_FOLDER_PATH}" 8 | curl -b 'oraclelicense=accept-securebackup-cookie' -C - -L "${JDK_DOWNLOAD_URL}" --retry 12 --retry-delay 5 | 9 | tar -C "${JDK_INSTALL_FOLDER_PATH}" -x -z --strip 1 10 | chown -R "$(whoami):$(whoami)" "${JDK_INSTALL_FOLDER_PATH}" 11 | 12 | symlinkListUsrBin \ 13 | "${JDK_INSTALL_FOLDER_PATH}/bin/jar" \ 14 | "${JDK_INSTALL_FOLDER_PATH}/bin/java" \ 15 | "${JDK_INSTALL_FOLDER_PATH}/bin/javac" 16 | 17 | createFileFromTemplate \ 18 | "$(dirname "${BASH_SOURCE[0]}")/../templates/jdk.sh.profile" \ 19 | '/etc/profile.d/jdk.sh' \ 20 | '__INSTALL_FOLDER_PATH__' \ 21 | "${JDK_INSTALL_FOLDER_PATH}" 22 | 23 | displayVersion "$(java -version 2>&1)" 24 | 25 | umask '0077' 26 | } 27 | 28 | function main() 29 | { 30 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 31 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 32 | 33 | header 'INSTALLING JDK' 34 | 35 | checkRequireLinuxSystem 36 | checkRequireRootUser 37 | 38 | install 39 | installCleanUp 40 | } 41 | 42 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jdk/templates/jdk.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export JAVA_HOME='__INSTALL_FOLDER_PATH__' 4 | export PATH="${JAVA_HOME}/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/jenkins/attributes/master.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | source "$(dirname "${BASH_SOURCE[0]}")/../../groovy/attributes/default.bash" 4 | source "$(dirname "${BASH_SOURCE[0]}")/../../tomcat/attributes/default.bash" 5 | 6 | export JENKINS_DOWNLOAD_URL='http://mirrors.jenkins-ci.org/war/latest/jenkins.war' 7 | export JENKINS_UPDATE_CENTER_URL='https://archives.jenkins.io/update-center/current/update-center.json' 8 | 9 | export JENKINS_INSTALL_FOLDER_PATH='/opt/jenkins' 10 | 11 | export JENKINS_GROOVY_INSTALL_FOLDER_PATH="${GROOVY_INSTALL_FOLDER_PATH}" 12 | 13 | export JENKINS_TOMCAT_INSTALL_FOLDER_PATH="${TOMCAT_INSTALL_FOLDER_PATH}" 14 | export JENKINS_TOMCAT_HTTP_PORT="${TOMCAT_HTTP_PORT}" 15 | 16 | export JENKINS_USER_NAME="${TOMCAT_USER_NAME}" 17 | export JENKINS_GROUP_NAME="${TOMCAT_GROUP_NAME}" 18 | 19 | export JENKINS_UPDATE_ALL_PLUGINS='true' 20 | 21 | export JENKINS_INSTALL_PLUGINS=( 22 | 'multiple-scms' 23 | 'simple-theme-plugin' 24 | ) -------------------------------------------------------------------------------- /cookbooks/jenkins/attributes/slave.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | source "$(dirname "${BASH_SOURCE[0]}")/../../tomcat/attributes/default.bash" 4 | 5 | export JENKINS_WORKSPACE_FOLDER='/opt/jenkins' 6 | 7 | export JENKINS_USER_NAME="${TOMCAT_USER_NAME}" 8 | export JENKINS_GROUP_NAME="${TOMCAT_GROUP_NAME}" -------------------------------------------------------------------------------- /cookbooks/jenkins/libraries/app.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 4 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/master.bash" 5 | 6 | function jenkinsMasterWARAppCleanUp() 7 | { 8 | local -r appName="$(getFileName "${JENKINS_DOWNLOAD_URL}")" 9 | 10 | checkNonEmptyString "${appName}" 11 | 12 | rm -f -r "${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/webapps/${appName}.war" \ 13 | "${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/webapps/${appName}" 14 | } 15 | 16 | function jenkinsMasterDownloadWARApp() 17 | { 18 | local -r appName="$(getFileName "${JENKINS_DOWNLOAD_URL}")" 19 | local -r temporaryFile="$(getTemporaryFile)" 20 | 21 | checkNonEmptyString "${appName}" 22 | checkExistFile "${temporaryFile}" 23 | checkExistFolder "${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/webapps" 24 | 25 | downloadFile "${JENKINS_DOWNLOAD_URL}" "${temporaryFile}" 'true' 26 | chown "${JENKINS_USER_NAME}:${JENKINS_GROUP_NAME}" "${temporaryFile}" 27 | mv "${temporaryFile}" "${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/webapps/${appName}.war" 28 | } 29 | 30 | function jenkinsMasterDisplayVersion() 31 | { 32 | local -r appName="$(getFileName "${JENKINS_DOWNLOAD_URL}")" 33 | local -r jenkinsCLIPath="${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/webapps/${appName}/WEB-INF/jenkins-cli.jar" 34 | 35 | checkNonEmptyString "${appName}" 36 | checkExistFile "${jenkinsCLIPath}" 37 | 38 | info "\nVersion : $( 39 | java \ 40 | -jar "${jenkinsCLIPath}" \ 41 | -s "http://127.0.0.1:${JENKINS_TOMCAT_HTTP_PORT}/${appName}" \ 42 | -version 43 | )" 44 | } 45 | 46 | function jenkinsMasterRefreshUpdateCenter() 47 | { 48 | checkTrueFalseString "${JENKINS_UPDATE_ALL_PLUGINS}" 49 | 50 | "$(dirname "${BASH_SOURCE[0]}")/../recipes/refresh-master-update-center.bash" 51 | } 52 | 53 | function jenkinsMasterUpdatePlugins() 54 | { 55 | if [[ "${JENKINS_UPDATE_ALL_PLUGINS}" = 'true' ]] 56 | then 57 | "$(dirname "${BASH_SOURCE[0]}")/../recipes/update-master-plugins.bash" 58 | fi 59 | } 60 | 61 | function jenkinsMasterInstallPlugins() 62 | { 63 | if [[ "${#JENKINS_INSTALL_PLUGINS[@]}" -gt '0' ]] 64 | then 65 | "$(dirname "${BASH_SOURCE[0]}")/../recipes/install-master-plugins.bash" "${JENKINS_INSTALL_PLUGINS[@]}" 66 | fi 67 | } 68 | 69 | function jenkinsMasterSafeRestart() 70 | { 71 | if [[ "${#JENKINS_INSTALL_PLUGINS[@]}" -gt '0' || "${JENKINS_UPDATE_ALL_PLUGINS}" = 'true' ]] 72 | then 73 | "$(dirname "${BASH_SOURCE[0]}")/../recipes/safe-restart-master.bash" 74 | fi 75 | } 76 | 77 | function jenkinsMasterUnlock() 78 | { 79 | header 'UNLOCKING JENKINS' 80 | 81 | createFileFromTemplate \ 82 | "${JENKINS_INSTALL_FOLDER_PATH}/config.xml" \ 83 | "${JENKINS_INSTALL_FOLDER_PATH}/config.xml" \ 84 | 'true' 'false' 85 | 86 | cat "${JENKINS_INSTALL_FOLDER_PATH}/config.xml" 87 | 88 | echo '2.0' > "${JENKINS_INSTALL_FOLDER_PATH}/jenkins.install.InstallUtil.lastExecVersion" 89 | cat "${JENKINS_INSTALL_FOLDER_PATH}/jenkins.install.InstallUtil.lastExecVersion" 90 | } -------------------------------------------------------------------------------- /cookbooks/jenkins/recipes/install-master-plugins.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | local -r pluginList=($(sed -e 's/\n/ /g' <<< "${@}")) 6 | 7 | umask '0022' 8 | 9 | if [[ "${#pluginList[@]}" -gt '0' ]] 10 | then 11 | local -r appName="$(getFileName "${JENKINS_DOWNLOAD_URL}")" 12 | local -r jenkinsCLIPath="${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/webapps/${appName}/WEB-INF/jenkins-cli.jar" 13 | local -r jenkinsAppURL="http://127.0.0.1:${JENKINS_TOMCAT_HTTP_PORT}/${appName}" 14 | 15 | checkNonEmptyString "${appName}" 16 | checkExistFile "${jenkinsCLIPath}" 17 | sleep 75 18 | checkExistURL "${jenkinsAppURL}" 19 | 20 | java -jar "${jenkinsCLIPath}" -s "${jenkinsAppURL}" install-plugin "${pluginList[@]}" 21 | else 22 | info 'No installs/updates available' 23 | fi 24 | 25 | umask '0077' 26 | } 27 | 28 | function main() 29 | { 30 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 31 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 32 | 33 | header 'INSTALLING MASTER PLUGINS JENKINS' 34 | 35 | checkRequireLinuxSystem 36 | checkRequireRootUser 37 | 38 | install "${@}" 39 | installCleanUp 40 | } 41 | 42 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jenkins/recipes/install-master.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | # Groovy 6 | 7 | if [[ "$(existCommand 'groovy')" = 'false' || ! -d "${JENKINS_GROOVY_INSTALL_FOLDER_PATH}" ]] 8 | then 9 | "$(dirname "${BASH_SOURCE[0]}")/../../groovy/recipes/install.bash" "${JENKINS_GROOVY_INSTALL_FOLDER_PATH}" 10 | fi 11 | 12 | # Tomcat 13 | 14 | if [[ ! -f "${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/bin/catalina.sh" ]] 15 | then 16 | "$(dirname "${BASH_SOURCE[0]}")/../../tomcat/recipes/install.bash" "${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}" 17 | fi 18 | } 19 | 20 | function install() 21 | { 22 | umask '0022' 23 | 24 | # Set Install Folder Path 25 | 26 | local -r jenkinsDefaultInstallFolder="$(getUserHomeFolder "${JENKINS_USER_NAME}")/.jenkins" 27 | 28 | if [[ "$(isEmptyString "${JENKINS_INSTALL_FOLDER_PATH}")" = 'true' ]] 29 | then 30 | JENKINS_INSTALL_FOLDER_PATH="${jenkinsDefaultInstallFolder}" 31 | fi 32 | 33 | # Clean Up 34 | 35 | jenkinsMasterWARAppCleanUp 36 | 37 | rm -f -r "${jenkinsDefaultInstallFolder}" "${JENKINS_INSTALL_FOLDER_PATH}" 38 | 39 | # Create Non-Default Jenkins Home 40 | 41 | if [[ "${JENKINS_INSTALL_FOLDER_PATH}" != "${jenkinsDefaultInstallFolder}" ]] 42 | then 43 | initializeFolder "${JENKINS_INSTALL_FOLDER_PATH}" 44 | ln -f -s "${JENKINS_INSTALL_FOLDER_PATH}" "${jenkinsDefaultInstallFolder}" 45 | chown -R "${JENKINS_USER_NAME}:${JENKINS_GROUP_NAME}" "${jenkinsDefaultInstallFolder}" "${JENKINS_INSTALL_FOLDER_PATH}" 46 | fi 47 | 48 | # Config Profile 49 | 50 | createFileFromTemplate \ 51 | "$(dirname "${BASH_SOURCE[0]}")/../templates/jenkins.sh.profile" \ 52 | '/etc/profile.d/jenkins.sh' \ 53 | '__INSTALL_FOLDER_PATH__' "${JENKINS_INSTALL_FOLDER_PATH}" 54 | 55 | # Config Cron 56 | 57 | createFileFromTemplate \ 58 | "$(dirname "${BASH_SOURCE[0]}")/../templates/jenkins.cron" \ 59 | '/etc/cron.daily/jenkins' \ 60 | '__USER_NAME__' "${JENKINS_USER_NAME}" \ 61 | '__GROUP_NAME__' "${JENKINS_GROUP_NAME}" \ 62 | '__INSTALL_FOLDER_PATH__' "${JENKINS_INSTALL_FOLDER_PATH}" 63 | 64 | chmod 755 '/etc/cron.daily/jenkins' 65 | 66 | # Install 67 | 68 | jenkinsMasterDownloadWARApp 69 | sleep 72 70 | jenkinsMasterDisplayVersion 71 | jenkinsMasterRefreshUpdateCenter 72 | jenkinsMasterUnlock 73 | restartService "${TOMCAT_SERVICE_NAME}" 74 | jenkinsMasterInstallPlugins 75 | jenkinsMasterUpdatePlugins 76 | jenkinsMasterSafeRestart 77 | 78 | umask '0077' 79 | } 80 | 81 | function main() 82 | { 83 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 84 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/master.bash" 85 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/app.bash" 86 | 87 | header 'INSTALLING MASTER JENKINS' 88 | 89 | checkRequireLinuxSystem 90 | checkRequireRootUser 91 | 92 | installDependencies 93 | install 94 | installCleanUp 95 | } 96 | 97 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jenkins/recipes/install-slave.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | initializeFolder "${JENKINS_WORKSPACE_FOLDER}" 16 | addUser "${JENKINS_USER_NAME}" "${JENKINS_GROUP_NAME}" 'true' 'true' 'true' 17 | chown -R "${JENKINS_USER_NAME}:${JENKINS_GROUP_NAME}" "${JENKINS_WORKSPACE_FOLDER}" 18 | 19 | umask '0077' 20 | } 21 | 22 | function main() 23 | { 24 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 25 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/slave.bash" 26 | 27 | header 'INSTALLING SLAVE JENKINS' 28 | 29 | checkRequireLinuxSystem 30 | checkRequireRootUser 31 | 32 | installDependencies 33 | install 34 | installCleanUp 35 | } 36 | 37 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jenkins/recipes/refresh-master-update-center.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function refreshUpdateCenter() 4 | { 5 | umask '0022' 6 | 7 | # Validate Jenkins Config Folder 8 | 9 | if [[ "$(isEmptyString "${JENKINS_INSTALL_FOLDER_PATH}")" = 'true' ]] 10 | then 11 | JENKINS_INSTALL_FOLDER_PATH="$(getUserHomeFolder "${JENKINS_USER_NAME}")/.jenkins" 12 | fi 13 | 14 | checkExistFolder "${JENKINS_INSTALL_FOLDER_PATH}" 15 | 16 | # Validate JSON Content 17 | 18 | local updateInfo='' 19 | updateInfo="$(getRemoteFileContent "${JENKINS_UPDATE_CENTER_URL}")" 20 | updateInfo="$(sed '1d;$d' <<< "${updateInfo}")" 21 | 22 | checkNonEmptyString "${updateInfo}" 'undefined content of update center url' 23 | 24 | # Update JSON File 25 | 26 | local -r jsonFilePath="${JENKINS_INSTALL_FOLDER_PATH}/updates/default.json" 27 | local -r updateFolderPath="$(dirname "${jsonFilePath}")" 28 | 29 | mkdir -p "${updateFolderPath}" 30 | echo "${updateInfo}" > "${jsonFilePath}" 31 | chown -R "${JENKINS_USER_NAME}:${JENKINS_GROUP_NAME}" "${updateFolderPath}" 32 | info "Updated '${jsonFilePath}'" 33 | 34 | umask '0077' 35 | } 36 | 37 | function main() 38 | { 39 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 40 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 41 | 42 | checkRequireLinuxSystem 43 | checkRequireRootUser 44 | 45 | header 'REFRESHING MASTER UPDATE CENTER JENKINS' 46 | 47 | refreshUpdateCenter 48 | installCleanUp 49 | } 50 | 51 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jenkins/recipes/safe-restart-master.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function safeRestart() 4 | { 5 | umask '0022' 6 | 7 | local -r appName="$(getFileName "${JENKINS_DOWNLOAD_URL}")" 8 | local -r jenkinsCLIPath="${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/webapps/${appName}/WEB-INF/jenkins-cli.jar" 9 | local -r jenkinsAppURL="http://127.0.0.1:${JENKINS_TOMCAT_HTTP_PORT}/${appName}" 10 | 11 | checkNonEmptyString "${appName}" 12 | checkExistFile "${jenkinsCLIPath}" 13 | checkExistURL "${jenkinsAppURL}" 14 | 15 | java -jar "${jenkinsCLIPath}" -s "${jenkinsAppURL}" safe-restart 16 | 17 | umask '0077' 18 | } 19 | 20 | function main() 21 | { 22 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 23 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 24 | 25 | checkRequireLinuxSystem 26 | checkRequireRootUser 27 | 28 | header 'SAFE-RESTARTING MASTER JENKINS' 29 | 30 | safeRestart 31 | installCleanUp 32 | } 33 | 34 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jenkins/recipes/update-master-plugins.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function updatePlugins() 4 | { 5 | umask '0022' 6 | 7 | local -r appName="$(getFileName "${JENKINS_DOWNLOAD_URL}")" 8 | local -r jenkinsCLIPath="${JENKINS_TOMCAT_INSTALL_FOLDER_PATH}/webapps/${appName}/WEB-INF/jenkins-cli.jar" 9 | local -r jenkinsAppURL="http://127.0.0.1:${JENKINS_TOMCAT_HTTP_PORT}/${appName}" 10 | 11 | checkNonEmptyString "${appName}" 12 | checkExistFile "${jenkinsCLIPath}" 13 | checkExistURL "${jenkinsAppURL}" 14 | 15 | local -r updateList=("$(java -jar "${jenkinsCLIPath}" -s "${jenkinsAppURL}" list-plugins | grep ')$' | awk '{ print $1 }' | sort -f)") 16 | 17 | "$(dirname "${BASH_SOURCE[0]}")/install-master-plugins.bash" "${updateList[@]}" 18 | 19 | umask '0077' 20 | } 21 | 22 | function main() 23 | { 24 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 25 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/master.bash" 26 | 27 | checkRequireLinuxSystem 28 | checkRequireRootUser 29 | 30 | updatePlugins 31 | installCleanUp 32 | } 33 | 34 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jenkins/recipes/upgrade-master.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | # Clean Up 8 | 9 | jenkinsMasterWARAppCleanUp 10 | 11 | # Install 12 | 13 | jenkinsMasterDownloadWARApp 14 | sleep 75 15 | jenkinsMasterDisplayVersion 16 | jenkinsMasterRefreshUpdateCenter 17 | jenkinsMasterUpdatePlugins 18 | jenkinsMasterSafeRestart 19 | 20 | umask '0077' 21 | } 22 | 23 | function main() 24 | { 25 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 26 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 27 | 28 | header 'UPGRADING MASTER JENKINS' 29 | 30 | checkRequireLinuxSystem 31 | checkRequireRootUser 32 | 33 | install 34 | installCleanUp 35 | } 36 | 37 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/jenkins/templates/jenkins.cron: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | chown -R '__USER_NAME__:__GROUP_NAME__' '__INSTALL_FOLDER_PATH__' -------------------------------------------------------------------------------- /cookbooks/jenkins/templates/jenkins.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export JENKINS_HOME='__INSTALL_FOLDER_PATH__' -------------------------------------------------------------------------------- /cookbooks/jq/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export JQ_DOWNLOAD_URL='https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-i386' 4 | 5 | export JQ_INSTALL_FOLDER_PATH='/opt/jq' -------------------------------------------------------------------------------- /cookbooks/jq/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | installPortableBinary \ 9 | 'JQ' \ 10 | "${JQ_DOWNLOAD_URL}" \ 11 | "${JQ_INSTALL_FOLDER_PATH}" \ 12 | 'jq' \ 13 | '--version' \ 14 | 'false' 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/kibana/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export KIBANA_DOWNLOAD_URL='https://artifacts.elastic.co/downloads/kibana/kibana-7.4.2-linux-x86_64.tar.gz' 4 | export KIBANA_ELASTIC_SEARCH_URL='http://127.0.0.1:9200' 5 | 6 | export KIBANA_INSTALL_FOLDER_PATH='/opt/kibana' 7 | 8 | export KIBANA_SERVICE_NAME='kibana' 9 | 10 | export KIBANA_USER_NAME='kibana' 11 | export KIBANA_GROUP_NAME='kibana' -------------------------------------------------------------------------------- /cookbooks/kibana/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | # Clean Up 8 | 9 | initializeFolder "${KIBANA_INSTALL_FOLDER_PATH}" 10 | 11 | # Install 12 | 13 | unzipRemoteFile "${KIBANA_DOWNLOAD_URL}" "${KIBANA_INSTALL_FOLDER_PATH}" 14 | 15 | # Config Server 16 | 17 | createFileFromTemplate \ 18 | "${KIBANA_INSTALL_FOLDER_PATH}/config/kibana.yml" \ 19 | "${KIBANA_INSTALL_FOLDER_PATH}/config/kibana.yml" \ 20 | 'http://localhost:9200' "${KIBANA_ELASTIC_SEARCH_URL}" 21 | 22 | # Config Profile 23 | 24 | createFileFromTemplate \ 25 | "$(dirname "${BASH_SOURCE[0]}")/../templates/kibana.sh.profile" \ 26 | '/etc/profile.d/kibana.sh' \ 27 | '__INSTALL_FOLDER_PATH__' "${KIBANA_INSTALL_FOLDER_PATH}" 28 | 29 | # Config Init 30 | 31 | createInitFileFromTemplate \ 32 | "${KIBANA_SERVICE_NAME}" \ 33 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 34 | '__INSTALL_FOLDER_PATH__' "${KIBANA_INSTALL_FOLDER_PATH}" \ 35 | '__USER_NAME__' "${KIBANA_USER_NAME}" \ 36 | '__GROUP_NAME__' "${KIBANA_GROUP_NAME}" 37 | 38 | # Start 39 | 40 | addUser "${KIBANA_USER_NAME}" "${KIBANA_GROUP_NAME}" 'false' 'true' 'false' 41 | chown -R "${KIBANA_USER_NAME}:${KIBANA_GROUP_NAME}" "${KIBANA_INSTALL_FOLDER_PATH}" 42 | startService "${KIBANA_SERVICE_NAME}" 43 | 44 | # Display Open Ports 45 | 46 | displayOpenPorts '5' 47 | 48 | umask '0077' 49 | } 50 | 51 | function main() 52 | { 53 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 54 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 55 | 56 | header 'INSTALLING KIBANA' 57 | 58 | checkRequireLinuxSystem 59 | checkRequireRootUser 60 | 61 | install 62 | installCleanUp 63 | } 64 | 65 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/kibana/templates/kibana.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Kibana Server 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | WorkingDirectory=__INSTALL_FOLDER_PATH__ 35 | 36 | ExecStart='__INSTALL_FOLDER_PATH__/bin/kibana' -------------------------------------------------------------------------------- /cookbooks/kibana/templates/kibana.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/logrotate/files/logrotate.conf.apt: -------------------------------------------------------------------------------- 1 | create 2 | daily 3 | rotate 0 4 | su root syslog 5 | 6 | include /etc/logrotate.d 7 | 8 | /var/log/wtmp { 9 | create 0664 root utmp 10 | daily 11 | missingok 12 | rotate 0 13 | } 14 | 15 | /var/log/btmp { 16 | create 0660 root utmp 17 | daily 18 | missingok 19 | rotate 0 20 | } -------------------------------------------------------------------------------- /cookbooks/logrotate/files/logrotate.conf.rpm: -------------------------------------------------------------------------------- 1 | create 2 | daily 3 | dateext 4 | rotate 0 5 | 6 | include /etc/logrotate.d 7 | 8 | /var/log/wtmp { 9 | create 0664 root utmp 10 | daily 11 | minsize 1M 12 | rotate 0 13 | } 14 | 15 | /var/log/btmp { 16 | create 0600 root utmp 17 | daily 18 | missingok 19 | rotate 0 20 | } -------------------------------------------------------------------------------- /cookbooks/logrotate/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | # Install Package 8 | 9 | installPackages 'logrotate' 10 | 11 | # Configure Logrotate 12 | 13 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 14 | then 15 | cp -f "$(dirname "${BASH_SOURCE[0]}")/../files/logrotate.conf.apt" '/etc/logrotate.conf' 16 | else 17 | cp -f "$(dirname "${BASH_SOURCE[0]}")/../files/logrotate.conf.rpm" '/etc/logrotate.conf' 18 | fi 19 | 20 | info '/etc/logrotate.conf' 21 | indentString ' ' "$(cat '/etc/logrotate.conf')" 22 | 23 | # Configure Cron 24 | 25 | cp -f -p '/etc/cron.daily/logrotate' '/etc/cron.hourly/logrotate' 26 | 27 | info '\n/etc/cron.hourly/logrotate' 28 | indentString ' ' "$(cat '/etc/cron.hourly/logrotate')" 29 | 30 | umask '0077' 31 | } 32 | 33 | function main() 34 | { 35 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 36 | 37 | header 'INSTALLING LOGROTATE' 38 | 39 | checkRequireLinuxSystem 40 | checkRequireRootUser 41 | 42 | install 43 | installCleanUp 44 | } 45 | 46 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/maven/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export MAVEN_DOWNLOAD_URL='https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz' 4 | 5 | export MAVEN_INSTALL_FOLDER_PATH='/opt/maven' -------------------------------------------------------------------------------- /cookbooks/maven/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function main() 12 | { 13 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 14 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 15 | 16 | installDependencies 17 | installPortableBinary \ 18 | 'MAVEN' \ 19 | "${MAVEN_DOWNLOAD_URL}" \ 20 | "${MAVEN_INSTALL_FOLDER_PATH}" \ 21 | 'bin/mvn' \ 22 | '--version' \ 23 | 'true' 24 | } 25 | 26 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/mongodb/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export MONGODB_DOWNLOAD_URL='https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.2.1.tgz' 4 | 5 | export MONGODB_INSTALL_FOLDER_PATH='/opt/mongodb' 6 | export MONGODB_INSTALL_DATA_FOLDER="${MONGODB_INSTALL_FOLDER_PATH}/data" 7 | 8 | export MONGODB_SERVICE_NAME='mongodb' 9 | 10 | export MONGODB_USER_NAME='mongodb' 11 | export MONGODB_GROUP_NAME='mongodb' 12 | 13 | export MONGODB_PORT='27017' -------------------------------------------------------------------------------- /cookbooks/mongodb/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | # Clean Up 8 | 9 | initializeFolder "${MONGODB_INSTALL_FOLDER_PATH}" 10 | initializeFolder "${MONGODB_INSTALL_DATA_FOLDER}" 11 | 12 | # Install 13 | 14 | unzipRemoteFile "${MONGODB_DOWNLOAD_URL}" "${MONGODB_INSTALL_FOLDER_PATH}" 15 | 16 | # Config Profile 17 | 18 | createFileFromTemplate \ 19 | "$(dirname "${BASH_SOURCE[0]}")/../templates/mongodb.sh.profile" \ 20 | '/etc/profile.d/mongodb.sh' \ 21 | '__INSTALL_FOLDER_PATH__' "${MONGODB_INSTALL_FOLDER_PATH}" 22 | 23 | # Config Init 24 | 25 | createInitFileFromTemplate \ 26 | "${MONGODB_SERVICE_NAME}" \ 27 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 28 | '__INSTALL_FOLDER_PATH__' "${MONGODB_INSTALL_FOLDER_PATH}" \ 29 | '__INSTALL_DATA_FOLDER__' "${MONGODB_INSTALL_DATA_FOLDER}" \ 30 | '__USER_NAME__' "${MONGODB_USER_NAME}" \ 31 | '__GROUP_NAME__' "${MONGODB_GROUP_NAME}" \ 32 | '__PORT__' "${MONGODB_PORT}" 33 | 34 | chown -R "$(whoami):$(whoami)" "${MONGODB_INSTALL_FOLDER_PATH}" 35 | 36 | # Start 37 | 38 | addUser "${MONGODB_USER_NAME}" "${MONGODB_GROUP_NAME}" 'false' 'true' 'false' 39 | chown -R "${MONGODB_USER_NAME}:${MONGODB_GROUP_NAME}" "${MONGODB_INSTALL_FOLDER_PATH}" 40 | startService "${MONGODB_SERVICE_NAME}" 41 | 42 | # Display Open Ports 43 | 44 | displayOpenPorts '5' 45 | 46 | # Display Version 47 | 48 | displayVersion "$(mongo --version)" 49 | 50 | umask '0077' 51 | } 52 | 53 | function main() 54 | { 55 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 56 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 57 | 58 | header 'INSTALLING MONGODB' 59 | 60 | checkRequireLinuxSystem 61 | checkRequireRootUser 62 | checkRequirePorts "${MONGODB_PORT}" 63 | 64 | install 65 | installCleanUp 66 | } 67 | 68 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/mongodb/templates/mongodb.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=MongoDB Server 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | ExecStart='__INSTALL_FOLDER_PATH__/bin/mongod' --port __PORT__ --dbpath '__INSTALL_DATA_FOLDER__' -------------------------------------------------------------------------------- /cookbooks/mongodb/templates/mongodb.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/mount-hd/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export MOUNT_HD_PARTITION_NUMBER='1' 4 | export MOUNT_HD_FS_TYPE='ext4' 5 | export MOUNT_HD_MOUNT_OPTIONS='defaults' 6 | export MOUNT_HD_DUMP='0' 7 | export MOUNT_HD_FSCK_OPTION='2' -------------------------------------------------------------------------------- /cookbooks/mount-hd/recipes/extend.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function extend() 4 | { 5 | local -r disk="${1}" 6 | local -r mountOn="${2}" 7 | 8 | umask '0022' 9 | 10 | if [[ "$(existDisk "${disk}")" = 'true' ]] 11 | then 12 | if [[ "$(existDiskMount "${disk}${MOUNT_HD_PARTITION_NUMBER}" "${mountOn}")" = 'false' ]] 13 | then 14 | rm -f -r -v "${mountOn}" 15 | "$(dirname "${BASH_SOURCE[0]}")/install.bash" "${disk}" "${mountOn}" 16 | else 17 | info "Already mounted '${disk}${MOUNT_HD_PARTITION_NUMBER}' to '${mountOn}'\n" 18 | df -h -T 19 | fi 20 | else 21 | info "Extended volume '${disk}' not found" 22 | fi 23 | 24 | umask '0077' 25 | } 26 | 27 | function main() 28 | { 29 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 30 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 31 | 32 | header 'EXTENDING MOUNT-HD' 33 | 34 | checkRequireLinuxSystem 35 | checkRequireRootUser 36 | 37 | extend "${@}" 38 | installCleanUp 39 | } 40 | 41 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/mount-hd/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | local -r disk="$(formatPath "${1}")" 6 | local -r mountOn="$(formatPath "${2}")" 7 | 8 | umask '0022' 9 | 10 | # Create Partition 11 | 12 | checkNonEmptyString "${disk}" 'undefined disk' 13 | checkNonEmptyString "${mountOn}" 'undefined mount-on' 14 | 15 | if [[ "$(existDisk "${disk}")" = 'false' ]] 16 | then 17 | fatal "FATAL : disk '${disk}' not found" 18 | fi 19 | 20 | local -r newDisk="${disk}${MOUNT_HD_PARTITION_NUMBER}" 21 | 22 | if [[ -d "${mountOn}" ]] 23 | then 24 | if [[ "$(existDiskMount "${newDisk}" "${mountOn}")" = 'false' ]] 25 | then 26 | fatal "FATAL : mount-on '${mountOn}' found" 27 | fi 28 | 29 | info "Already mounted '${newDisk}' to '${mountOn}'\n" 30 | df -h -T 31 | else 32 | resetPartition "${disk}" 33 | createPartition "${disk}" 34 | 35 | mkfs -t "${MOUNT_HD_FS_TYPE}" "${newDisk}" 36 | mkdir "${mountOn}" 37 | mount -t "${MOUNT_HD_FS_TYPE}" "${newDisk}" "${mountOn}" 38 | 39 | # Config Static File System 40 | 41 | local -r fstabConfig="${newDisk} ${mountOn} ${MOUNT_HD_FS_TYPE} ${MOUNT_HD_MOUNT_OPTIONS} ${MOUNT_HD_DUMP} ${MOUNT_HD_FSCK_OPTION}" 42 | 43 | appendToFileIfNotFound \ 44 | '/etc/fstab' \ 45 | "$(stringToSearchPattern "${fstabConfig}")" "${fstabConfig}" \ 46 | 'true' \ 47 | 'false' \ 48 | 'true' 49 | 50 | # Display File System 51 | 52 | df -h -T 53 | fi 54 | 55 | umask '0077' 56 | } 57 | 58 | function resetPartition() 59 | { 60 | local -r disk="${1}" 61 | 62 | local -r mountOn="$(df "${disk}" --output='target' | tail -1)" 63 | 64 | if [[ "$(isEmptyString "${mountOn}")" = 'false' && "$(dirname "${mountOn}")" != '/' ]] 65 | then 66 | umount -v "${mountOn}" 67 | fi 68 | } 69 | 70 | function createPartition() 71 | { 72 | local -r disk="${1}" 73 | 74 | installPackages 'expect' 75 | 76 | expect << DONE 77 | spawn fdisk "${disk}" 78 | 79 | expect "Command (m for help): " 80 | send -- "n\r" 81 | 82 | expect "Select (default p): " 83 | send -- "\r" 84 | 85 | expect "Partition number (1-4, default 1): " 86 | send -- "\r" 87 | 88 | expect "First sector (*, default *): " 89 | send -- "\r" 90 | 91 | expect "Last sector, +sectors or +size{K,M,G} (*, default *): " 92 | send -- "\r" 93 | 94 | expect "Command (m for help): " 95 | send -- "w\r" 96 | 97 | expect eof 98 | DONE 99 | } 100 | 101 | function main() 102 | { 103 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 104 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 105 | 106 | header 'INSTALLING MOUNT-HD' 107 | 108 | checkRequireLinuxSystem 109 | checkRequireRootUser 110 | 111 | install "${@}" 112 | installCleanUp 113 | } 114 | 115 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/mysql/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export MYSQL_DOWNLOAD_URL='http://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz' 4 | 5 | export MYSQL_INSTALL_FOLDER_PATH='/opt/mysql' 6 | 7 | export MYSQL_USER_NAME='mysql' 8 | export MYSQL_GROUP_NAME='mysql' 9 | 10 | export MYSQL_SERVICE_NAME='mysql' 11 | 12 | export MYSQL_PORT='3306' 13 | 14 | export MYSQL_RUN_POST_SECURE_INSTALLATION='true' 15 | 16 | export MYSQL_ROOT_PASSWORD='' 17 | export MYSQL_DELETE_ANONYMOUS_USERS='true' 18 | export MYSQL_DISALLOW_ROOT_LOGIN_REMOTELY='true' 19 | export MYSQL_DELETE_TEST_DATABASE='true' 20 | export MYSQL_RELOAD_PRIVILEGE_TABLE='true' -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | installPackages 'libaio1' 'sysv-rc-conf' 6 | } 7 | 8 | function install() 9 | { 10 | umask '0022' 11 | 12 | # Clean Up 13 | 14 | local -r installFolderName="$(getFileName "${MYSQL_INSTALL_FOLDER_PATH}")" 15 | 16 | initializeFolder "${MYSQL_INSTALL_FOLDER_PATH}" 17 | rm -f -r "/usr/local/${installFolderName:?}" 18 | 19 | # Install 20 | 21 | unzipRemoteFile "${MYSQL_DOWNLOAD_URL}" "${MYSQL_INSTALL_FOLDER_PATH}" 22 | addUser "${MYSQL_USER_NAME}" "${MYSQL_GROUP_NAME}" 'false' 'true' 'false' 23 | ln -f -s "${MYSQL_INSTALL_FOLDER_PATH}" "/usr/local/$(getFileName "${MYSQL_INSTALL_FOLDER_PATH}")" 24 | 25 | cd "${MYSQL_INSTALL_FOLDER_PATH}" 26 | 27 | mkdir -m 770 -p 'mysql-files' 28 | chown -R "${MYSQL_USER_NAME}:${MYSQL_GROUP_NAME}" "${MYSQL_INSTALL_FOLDER_PATH}" 29 | "${MYSQL_INSTALL_FOLDER_PATH}/bin/mysqld" --initialize --user="${MYSQL_USER_NAME}" 30 | "${MYSQL_INSTALL_FOLDER_PATH}/bin/mysql_ssl_rsa_setup" 31 | chown -R "$(whoami)" "${MYSQL_INSTALL_FOLDER_PATH}" 32 | chown -R "${MYSQL_USER_NAME}" 'data' 'mysql-files' 33 | symlinkListUsrBin "${MYSQL_INSTALL_FOLDER_PATH}/bin/mysql" 34 | 35 | # Config Server 36 | 37 | createFileFromTemplate \ 38 | "$(dirname "${BASH_SOURCE[0]}")/../templates/my.cnf.conf" \ 39 | "${MYSQL_INSTALL_FOLDER_PATH}/my.cnf" \ 40 | '__PORT__' "${MYSQL_PORT}" 41 | 42 | # Config Service 43 | 44 | cp -f "${MYSQL_INSTALL_FOLDER_PATH}/support-files/mysql.server" "/etc/init.d/${MYSQL_SERVICE_NAME}" 45 | sysv-rc-conf --level 2345 "${MYSQL_SERVICE_NAME}" on 46 | 47 | # Config Profile 48 | 49 | createFileFromTemplate \ 50 | "$(dirname "${BASH_SOURCE[0]}")/../templates/mysql.sh.profile" \ 51 | '/etc/profile.d/mysql.sh' \ 52 | '__INSTALL_FOLDER_PATH__' "${MYSQL_INSTALL_FOLDER_PATH}" 53 | 54 | # Start 55 | 56 | service "${MYSQL_SERVICE_NAME}" start 57 | 58 | # Run Secure Installation 59 | 60 | #if [[ "${MYSQL_RUN_POST_SECURE_INSTALLATION}" = 'true' ]] 61 | # then 62 | # secureInstallation 63 | #fi 64 | 65 | # Display Open Ports 66 | 67 | displayOpenPorts '5' 68 | 69 | # Display Version 70 | 71 | displayVersion "$(mysql --version)" 72 | 73 | umask '0077' 74 | } 75 | 76 | function secureInstallation() 77 | { 78 | local -r secureInstaller="${MYSQL_INSTALL_FOLDER_PATH}/bin/mysql_secure_installation" 79 | 80 | checkExistFile "${secureInstaller}" 81 | 82 | # Install Expect 83 | 84 | installPackages 'expect' 85 | 86 | # Config Option 87 | 88 | local setMySQLRootPassword='n' 89 | 90 | if [[ "${MYSQL_ROOT_PASSWORD}" != '' ]] 91 | then 92 | setMySQLRootPassword='Y' 93 | fi 94 | 95 | if [[ "${MYSQL_DELETE_ANONYMOUS_USERS}" = 'true' ]] 96 | then 97 | MYSQL_DELETE_ANONYMOUS_USERS='Y' 98 | else 99 | MYSQL_DELETE_ANONYMOUS_USERS='n' 100 | fi 101 | 102 | if [[ "${MYSQL_DISALLOW_ROOT_LOGIN_REMOTELY}" = 'true' ]] 103 | then 104 | MYSQL_DISALLOW_ROOT_LOGIN_REMOTELY='Y' 105 | else 106 | MYSQL_DISALLOW_ROOT_LOGIN_REMOTELY='n' 107 | fi 108 | 109 | if [[ "${MYSQL_DELETE_TEST_DATABASE}" = 'true' ]] 110 | then 111 | MYSQL_DELETE_TEST_DATABASE='Y' 112 | else 113 | MYSQL_DELETE_TEST_DATABASE='n' 114 | fi 115 | 116 | if [[ "${MYSQL_RELOAD_PRIVILEGE_TABLE}" = 'true' ]] 117 | then 118 | MYSQL_RELOAD_PRIVILEGE_TABLE='Y' 119 | else 120 | MYSQL_RELOAD_PRIVILEGE_TABLE='n' 121 | fi 122 | 123 | # Run Config 124 | 125 | cd "${MYSQL_INSTALL_FOLDER_PATH}" 126 | 127 | expect << DONE 128 | set timeout 3 129 | spawn "${secureInstaller}" 130 | 131 | expect "Enter password for user root: " 132 | send -- "\r" 133 | 134 | expect "Set root password? \[Y/n] " 135 | send -- "${setMySQLRootPassword}\r" 136 | 137 | if { "${setMySQLRootPassword}" == "Y" } { 138 | expect "New password: " 139 | send -- "${MYSQL_ROOT_PASSWORD}\r" 140 | 141 | expect "Re-enter new password: " 142 | send -- "${MYSQL_ROOT_PASSWORD}\r" 143 | } 144 | 145 | expect "Remove anonymous users? \[Y/n] " 146 | send -- "${MYSQL_DELETE_ANONYMOUS_USERS}\r" 147 | 148 | expect "Disallow root login remotely? \[Y/n] " 149 | send -- "${MYSQL_DISALLOW_ROOT_LOGIN_REMOTELY}\r" 150 | 151 | expect "Remove test database and access to it? \[Y/n] " 152 | send -- "${MYSQL_DELETE_TEST_DATABASE}\r" 153 | 154 | expect "Reload privilege tables now? \[Y/n] " 155 | send -- "${MYSQL_RELOAD_PRIVILEGE_TABLE}\r" 156 | 157 | expect eof 158 | DONE 159 | } 160 | 161 | function main() 162 | { 163 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 164 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 165 | 166 | header 'INSTALLING MYSQL' 167 | 168 | checkRequireLinuxSystem 169 | checkRequireRootUser 170 | checkRequirePorts "${MYSQL_PORT}" 171 | 172 | installDependencies 173 | install 174 | installCleanUp 175 | } 176 | 177 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/mysql/templates/my.cnf.conf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | 3 | log_error = /var/log/mysql/mysql_error.log 4 | 5 | general_log_file = /var/log/mysql/mysql.log 6 | general_log = 1 7 | 8 | port = __PORT__ 9 | sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES -------------------------------------------------------------------------------- /cookbooks/mysql/templates/mysql.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export NGINX_PORT='80' 4 | 5 | export NGINX_AMAZON_LINUX_ID='centos' 6 | export NGINX_AMAZON_LINUX_VERSION_ID='7' -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | # Add Package Link 8 | 9 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 10 | then 11 | local -r releaseFilePath='/etc/lsb-release' 12 | 13 | checkExistFile "${releaseFilePath}" 14 | 15 | source "${releaseFilePath}" 16 | 17 | createFileFromTemplate \ 18 | "$(dirname "${BASH_SOURCE[0]}")/../templates/nginx.list.apt" \ 19 | '/etc/apt/sources.list.d/nginx.list' \ 20 | '__DISTRIBUTION_CODE_NAME__' "${DISTRIB_CODENAME}" 21 | 22 | curl -s -L 'http://nginx.org/keys/nginx_signing.key' --retry 12 --retry-delay 5 | apt-key add - 23 | apt-get update -m 24 | else 25 | local -r releaseFilePath='/etc/os-release' 26 | 27 | checkExistFile "${releaseFilePath}" 28 | 29 | source "${releaseFilePath}" 30 | 31 | # Set ID For Amazon Linux 32 | 33 | if [[ "${ID}" = 'amzn' ]] 34 | then 35 | ID="${NGINX_AMAZON_LINUX_ID}" 36 | VERSION_ID="${NGINX_AMAZON_LINUX_VERSION_ID}" 37 | fi 38 | 39 | # Generate Repo File 40 | 41 | createFileFromTemplate \ 42 | "$(dirname "${BASH_SOURCE[0]}")/../templates/nginx.repo" \ 43 | '/etc/yum.repos.d/nginx.repo' \ 44 | '__PLATFORM_FAMILY__' "${ID}" \ 45 | '__PLATFORM_VERSION__' "$(awk -F '.' '{ print $1 }' <<< "${VERSION_ID}")" 46 | fi 47 | 48 | # Install 49 | 50 | installPackages 'nginx' 51 | startService 'nginx' 52 | 53 | # Display Open Ports 54 | 55 | displayOpenPorts '5' 56 | 57 | # Display Version 58 | 59 | displayVersion "$(nginx -V 2>&1)" 60 | 61 | umask '0077' 62 | } 63 | 64 | function main() 65 | { 66 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 67 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 68 | 69 | header 'INSTALLING NGINX' 70 | 71 | checkRequireLinuxSystem 72 | checkRequireRootUser 73 | checkRequirePorts "${NGINX_PORT}" 74 | 75 | install 76 | installCleanUp 77 | } 78 | 79 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/nginx/templates/nginx.list.apt: -------------------------------------------------------------------------------- 1 | deb http://nginx.org/packages/mainline/ubuntu __DISTRIBUTION_CODE_NAME__ nginx 2 | deb-src http://nginx.org/packages/mainline/ubuntu __DISTRIBUTION_CODE_NAME__ nginx -------------------------------------------------------------------------------- /cookbooks/nginx/templates/nginx.repo: -------------------------------------------------------------------------------- 1 | [nginx] 2 | name=Nginx 3 | baseurl=http://nginx.org/packages/mainline/__PLATFORM_FAMILY__/__PLATFORM_VERSION__/$basearch/ 4 | gpgcheck=0 5 | enabled=1 -------------------------------------------------------------------------------- /cookbooks/node/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export NODE_VERSION='latest' 4 | # export NODE_VERSION='v22.14.0' 5 | 6 | export NODE_INSTALL_FOLDER_PATH='/opt/node' 7 | 8 | export NODE_INSTALL_NPM_PACKAGES=( 9 | # First 10 | 11 | 'npm@latest' 12 | ) -------------------------------------------------------------------------------- /cookbooks/node/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 6 | then 7 | installBuildEssential 8 | installPackages 'python3' 9 | else 10 | installPackages 'gcc-c++' 'make' 'python3' 11 | fi 12 | } 13 | 14 | function resetOwnerAndSymlinkLocalBin() 15 | { 16 | chown -R "$(whoami):$(whoami)" "${NODE_INSTALL_FOLDER_PATH}" 17 | symlinkUsrBin "${NODE_INSTALL_FOLDER_PATH}/bin" 18 | symlinkListUsrBin "${NODE_INSTALL_FOLDER_PATH}/bin/node" 19 | } 20 | 21 | function install() 22 | { 23 | umask '0022' 24 | 25 | # Clean Up 26 | 27 | initializeFolder "${NODE_INSTALL_FOLDER_PATH}" 28 | 29 | # Install 30 | 31 | if [[ "${NODE_VERSION}" = 'latest' ]] 32 | then 33 | NODE_VERSION="$(getLatestVersionNumber)" 34 | local -r url="https://nodejs.org/dist/latest/node-${NODE_VERSION}-linux-x64.tar.gz" 35 | else 36 | if [[ "$(grep -o '^v' <<< "${NODE_VERSION}")" = '' ]] 37 | then 38 | NODE_VERSION="v${NODE_VERSION}" 39 | fi 40 | 41 | local -r url="https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz" 42 | fi 43 | 44 | unzipRemoteFile "${url}" "${NODE_INSTALL_FOLDER_PATH}" 45 | 46 | # Reset Owner And Symlink Local Bin 47 | 48 | resetOwnerAndSymlinkLocalBin 49 | 50 | # Install NPM Packages 51 | 52 | local package='' 53 | 54 | for package in "${NODE_INSTALL_NPM_PACKAGES[@]}" 55 | do 56 | header "INSTALLING NODE PACKAGE ${package}" 57 | "${NODE_INSTALL_FOLDER_PATH}/bin/npm" install -g --prefix "${NODE_INSTALL_FOLDER_PATH}" "${package}" 58 | done 59 | 60 | # Reset Owner And Symlink Local Bin 61 | 62 | resetOwnerAndSymlinkLocalBin 63 | 64 | # Config Profile 65 | 66 | createFileFromTemplate \ 67 | "$(dirname "${BASH_SOURCE[0]}")/../templates/node.sh.profile" \ 68 | '/etc/profile.d/node.sh' \ 69 | '__INSTALL_FOLDER_PATH__' "${NODE_INSTALL_FOLDER_PATH}" 70 | 71 | # Clean Up 72 | 73 | local -r userHomeFolderPath="$(getCurrentUserHomeFolder)" 74 | 75 | rm -f -r "${userHomeFolderPath}/.cache" \ 76 | "${userHomeFolderPath}/.npm" 77 | 78 | # Display Version 79 | 80 | displayVersion "Node Version : $(node --version)\nNPM Version : $(npm --version)" 81 | 82 | umask '0077' 83 | } 84 | 85 | function getLatestVersionNumber() 86 | { 87 | local -r versionPattern='v[[:digit:]]{1,2}\.[[:digit:]]{1,2}\.[[:digit:]]{1,3}' 88 | local -r shaSum256="$(getRemoteFileContent 'https://nodejs.org/dist/latest/SHASUMS256.txt.asc')" 89 | 90 | grep -E -o "node-${versionPattern}\.tar\.gz" <<< "${shaSum256}" | grep -E -o "${versionPattern}" 91 | } 92 | 93 | function main() 94 | { 95 | local -r version="${1}" 96 | 97 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 98 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 99 | 100 | header 'INSTALLING NODE' 101 | 102 | # Override Default Config 103 | 104 | if [[ "$(isEmptyString "${version}")" = 'false' ]] 105 | then 106 | NODE_VERSION="${version}" 107 | fi 108 | 109 | # Validation 110 | 111 | checkRequireLinuxSystem 112 | checkRequireRootUser 113 | 114 | # Install 115 | 116 | installDependencies 117 | install 118 | installCleanUp 119 | } 120 | 121 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/node/templates/node.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/nomad/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export NOMAD_DOWNLOAD_URL='https://releases.hashicorp.com/nomad/0.10.1/nomad_0.10.1_linux_amd64.zip' 4 | 5 | export NOMAD_INSTALL_FOLDER_PATH='/opt/nomad' -------------------------------------------------------------------------------- /cookbooks/nomad/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | installPortableBinary \ 9 | 'NOMAD' \ 10 | "${NOMAD_DOWNLOAD_URL}" \ 11 | "${NOMAD_INSTALL_FOLDER_PATH}" \ 12 | 'nomad' \ 13 | 'version' \ 14 | 'true' 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/packer/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PACKER_DOWNLOAD_URL='https://releases.hashicorp.com/packer/1.4.5/packer_1.4.5_linux_amd64.zip' 4 | 5 | export PACKER_INSTALL_FOLDER_PATH='/opt/packer' -------------------------------------------------------------------------------- /cookbooks/packer/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | installPortableBinary \ 9 | 'PACKER' \ 10 | "${PACKER_DOWNLOAD_URL}" \ 11 | "${PACKER_INSTALL_FOLDER_PATH}" \ 12 | 'packer' \ 13 | 'version' \ 14 | 'true' 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/pm2/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | source "$(dirname "${BASH_SOURCE[0]}")/../../node/attributes/default.bash" 4 | 5 | export PM2_NODE_INSTALL_FOLDER_PATH="${NODE_INSTALL_FOLDER_PATH}" 6 | export PM2_NODE_VERSION='latest' 7 | 8 | export PM2_USER_NAME='pm2' 9 | export PM2_GROUP_NAME='pm2' -------------------------------------------------------------------------------- /cookbooks/pm2/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'node')" = 'false' || "$(existCommand 'npm')" = 'false' || ! -d "${PM2_NODE_INSTALL_FOLDER_PATH}" ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../node/recipes/install.bash" "${PM2_NODE_VERSION}" "${PM2_NODE_INSTALL_FOLDER_PATH}" 8 | fi 9 | } 10 | 11 | function resetOwnerAndSymlinkLocalBin() 12 | { 13 | chown -R "$(whoami):$(whoami)" "${PM2_NODE_INSTALL_FOLDER_PATH}" 14 | symlinkUsrBin "${PM2_NODE_INSTALL_FOLDER_PATH}/bin" 15 | } 16 | 17 | function install() 18 | { 19 | umask '0022' 20 | 21 | # Install 22 | 23 | npm install -g --prefix "${PM2_NODE_INSTALL_FOLDER_PATH}" 'pm2@latest' 24 | 25 | # Reset Owner And Symlink Local Bin 26 | 27 | resetOwnerAndSymlinkLocalBin 28 | 29 | # Add User 30 | 31 | addUser "${PM2_USER_NAME}" "${PM2_GROUP_NAME}" 'true' 'true' 'true' 32 | 33 | local -r userHome="$(getUserHomeFolder "${PM2_USER_NAME}")" 34 | 35 | checkExistFolder "${userHome}" 36 | 37 | # Config Profile 38 | 39 | createFileFromTemplate \ 40 | "$(dirname "${BASH_SOURCE[0]}")/../templates/pm2.sh.profile" \ 41 | '/etc/profile.d/pm2.sh' \ 42 | '__HOME_FOLDER__' "${userHome}/.pm2" 43 | 44 | # Config Log Rotate 45 | 46 | createFileFromTemplate \ 47 | "$(dirname "${BASH_SOURCE[0]}")/../templates/pm2.logrotate" \ 48 | '/etc/logrotate.d/pm2' \ 49 | '__HOME_FOLDER__' "${userHome}/.pm2" 50 | 51 | # Clean Up 52 | 53 | local -r userHomeFolderPath="$(getCurrentUserHomeFolder)" 54 | 55 | rm -f -r "${userHomeFolderPath}/.cache" \ 56 | "${userHomeFolderPath}/.npm" 57 | 58 | # Start 59 | 60 | export PM2_HOME="${userHome}/.pm2" 61 | pm2 startup 'linux' --hp "${userHome}/.pm2" --user "${PM2_USER_NAME}" 62 | pkill -f 'PM2' 63 | chown -R "${PM2_USER_NAME}:${PM2_GROUP_NAME}" "${userHome}/.pm2" 64 | service 'pm2-init.sh' start 65 | 66 | # Display Version 67 | 68 | displayVersion "Node Version : $(node --version)\nNPM Version : $(npm --version)\nPM2 Version : $(pm2 --version)" 69 | 70 | umask '0077' 71 | } 72 | 73 | function main() 74 | { 75 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 76 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 77 | 78 | header 'INSTALLING PM2' 79 | 80 | checkRequireLinuxSystem 81 | checkRequireRootUser 82 | 83 | installDependencies 84 | install 85 | installCleanUp 86 | } 87 | 88 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/pm2/templates/pm2.logrotate: -------------------------------------------------------------------------------- 1 | __HOME_FOLDER__/pm2.log __HOME_FOLDER__/logs/*.log { 2 | compress 3 | create 644 pm2 pm2 4 | daily 5 | missingok 6 | notifempty 7 | rotate 7 8 | } -------------------------------------------------------------------------------- /cookbooks/pm2/templates/pm2.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PM2_HOME='__HOME_FOLDER__' -------------------------------------------------------------------------------- /cookbooks/ps1/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PS1_ROOT_PROMPT='\n\033[1;36m<\033[31m\u\033[34m@\033[33m\h\033[36m><\033[35m\w\033[36m>\033[0m\n# ' 4 | export PS1_USER_PROMPT='\n\033[1;36m<\033[35m\u\033[34m@\033[32m\h\033[36m><\033[35m\w\033[36m>\033[0m\n$ ' -------------------------------------------------------------------------------- /cookbooks/ps1/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function displayUsage() 4 | { 5 | local -r scriptName="$(basename "${BASH_SOURCE[0]}")" 6 | 7 | echo -e "\033[1;33m" 8 | echo "SYNOPSIS :" 9 | echo " ${scriptName}" 10 | echo " --help" 11 | echo " --profile-file-name " 12 | echo " --host-name " 13 | echo " --users " 14 | echo -e "\033[1;35m" 15 | echo "DESCRIPTION :" 16 | echo " --help Help page (optional)" 17 | echo " --profile-file-name Profile file name such as '.profile', '.bash_profile', '.bashrc' (optional)" 18 | echo " --host-name Custom host name (optional). Default to current host name" 19 | echo " --users List of users separated by commas or spaces (optional). Default to current user" 20 | echo -e "\033[1;36m" 21 | echo "EXAMPLES :" 22 | echo " ./${scriptName} --help" 23 | echo " ./${scriptName}" 24 | echo " ./${scriptName} --users 'user1, user2, user3'" 25 | echo " ./${scriptName} --host-name 'my-server.com'" 26 | echo " ./${scriptName} --host-name 'my-server.com' --users 'user1 user2 user3'" 27 | echo " ./${scriptName} --profile-file-name '.bash_profile' --host-name 'my-server.com' --users 'user1 user2 user3'" 28 | echo -e "\033[0m" 29 | 30 | exit "${1}" 31 | } 32 | 33 | function install() 34 | { 35 | local -r profileFileName="${1}" 36 | local -r hostName="${2}" 37 | local userList=(${3//,/ }) 38 | 39 | umask '0022' 40 | 41 | # Reformat PS1 42 | 43 | if [[ "$(isEmptyString "${hostName}")" = 'false' ]] 44 | then 45 | PS1_ROOT_PROMPT="$(replaceString "${PS1_ROOT_PROMPT}" '\\h' "${hostName}")" 46 | PS1_USER_PROMPT="$(replaceString "${PS1_USER_PROMPT}" '\\h' "${hostName}")" 47 | fi 48 | 49 | # Add Current User To List When Array Is Empty 50 | 51 | if [[ "${#userList[@]}" -lt '1' ]] 52 | then 53 | userList=("$(whoami)") 54 | fi 55 | 56 | # Update Prompt 57 | 58 | local user='' 59 | 60 | for user in "${userList[@]}" 61 | do 62 | # Use Auto Detect Profile File Path Or Use Specified Profile File Name 63 | 64 | local profileFilePath='' 65 | profileFilePath="$(getProfileFilePath "${user}")" 66 | 67 | if [[ "$(isEmptyString "${profileFileName}")" = 'false' ]] 68 | then 69 | profileFilePath="$(getUserHomeFolder "${user}")/${profileFileName}" 70 | fi 71 | 72 | # Update Profile File Path 73 | 74 | if [[ "$(isEmptyString "${profileFilePath}")" = 'false' ]] 75 | then 76 | if [[ "$(whoami)" = "${user}" ]] 77 | then 78 | local prompt="export PS1=\"${PS1_ROOT_PROMPT}\"" 79 | else 80 | local prompt="export PS1=\"${PS1_USER_PROMPT}\"" 81 | fi 82 | 83 | echo -e "Updating '\033[1;32m${profileFilePath}\033[0m'" 84 | 85 | if [[ ! -f "${profileFilePath}" ]] 86 | then 87 | touch "${profileFilePath}" 88 | 89 | if [[ "$(existGroupName "${user}")" = 'true' ]] 90 | then 91 | chown "${user}:${user}" "${profileFilePath}" 92 | else 93 | chown "${user}:$(getUserGroupName "${user}")" "${profileFilePath}" 94 | fi 95 | fi 96 | 97 | appendToFileIfNotFound \ 98 | "${profileFilePath}" \ 99 | "${prompt}" \ 100 | "${prompt}" \ 101 | 'false' \ 102 | 'false' \ 103 | 'true' 104 | else 105 | warn "WARN : profile '${user}' not found" 106 | fi 107 | done 108 | 109 | # Update Default Prompt 110 | 111 | local -r defaultPrompt="export PS1=\"${PS1_USER_PROMPT}\"" 112 | 113 | if [[ -f '/etc/skel/.profile' ]] 114 | then 115 | local -r defaultProfileFilePath='/etc/skel/.profile' 116 | else 117 | local -r defaultProfileFilePath='/etc/skel/.bash_profile' 118 | fi 119 | 120 | echo -e "Updating '\033[1;32m${defaultProfileFilePath}\033[0m'" 121 | 122 | appendToFileIfNotFound \ 123 | "${defaultProfileFilePath}" \ 124 | "${defaultPrompt}" \ 125 | "${defaultPrompt}" \ 126 | 'false' \ 127 | 'false' \ 128 | 'true' 129 | 130 | umask '0077' 131 | } 132 | 133 | function main() 134 | { 135 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 136 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 137 | 138 | header 'INSTALLING PS1' 139 | 140 | while [[ "${#}" -gt '0' ]] 141 | do 142 | case "${1}" in 143 | --help) 144 | displayUsage 0 145 | ;; 146 | 147 | --profile-file-name) 148 | shift 149 | 150 | if [[ "${#}" -gt '0' ]] 151 | then 152 | local profileFileName='' 153 | profileFileName="$(trimString "${1}")" 154 | fi 155 | 156 | ;; 157 | 158 | --host-name) 159 | shift 160 | 161 | if [[ "${#}" -gt '0' ]] 162 | then 163 | local hostName='' 164 | hostName="$(trimString "${1}")" 165 | fi 166 | 167 | ;; 168 | 169 | --users) 170 | shift 171 | 172 | if [[ "${#}" -gt '0' ]] 173 | then 174 | local users='' 175 | users="$(trimString "${1}")" 176 | fi 177 | 178 | ;; 179 | 180 | *) 181 | shift 182 | ;; 183 | esac 184 | done 185 | 186 | checkRequireLinuxSystem 187 | checkRequireRootUser 188 | 189 | install "${profileFileName}" "${hostName}" "${users}" 190 | installCleanUp 191 | } 192 | 193 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/python/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PYTHON_DOWNLOAD_URL='https://www.python.org/ftp/python/3.13.2/Python-3.13.2.tgz' 4 | 5 | export PYTHON_INSTALL_FOLDER_PATH='/opt/python' -------------------------------------------------------------------------------- /cookbooks/python/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | installBuildEssential 6 | 7 | installPackage 'libffi-dev' 'libffi-devel' 8 | installPackage 'libssl-dev' 'openssl-devel' 9 | installPackage 'zlib1g-dev' 'zlib-devel' 10 | } 11 | 12 | function install() 13 | { 14 | umask '0022' 15 | 16 | # Install 17 | 18 | compileAndInstallFromSource "${PYTHON_DOWNLOAD_URL}" "${PYTHON_INSTALL_FOLDER_PATH}" "${PYTHON_INSTALL_FOLDER_PATH}/bin/python3" "$(whoami)" 19 | symlinkListUsrBin "${PYTHON_INSTALL_FOLDER_PATH}/bin/python3" 20 | 21 | # Config Profile 22 | 23 | createFileFromTemplate \ 24 | "$(dirname "${BASH_SOURCE[0]}")/../templates/python.sh.profile" \ 25 | '/etc/profile.d/python.sh' \ 26 | '__INSTALL_FOLDER_PATH__' "${PYTHON_INSTALL_FOLDER_PATH}" 27 | 28 | # Display Version 29 | 30 | displayVersion "$(python3 --version)" 31 | 32 | umask '0077' 33 | } 34 | 35 | function main() 36 | { 37 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 38 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 39 | 40 | header 'INSTALLING PYTHON' 41 | 42 | checkRequireLinuxSystem 43 | checkRequireRootUser 44 | 45 | installDependencies 46 | install 47 | installCleanUp 48 | } 49 | 50 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/python/templates/python.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/redis/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export REDIS_DOWNLOAD_URL='http://download.redis.io/releases/redis-stable.tar.gz' 4 | 5 | export REDIS_SERVICE_NAME='redis' 6 | 7 | export REDIS_USER_NAME='redis' 8 | export REDIS_GROUP_NAME='redis' 9 | 10 | export REDIS_PORT='6379' 11 | 12 | export REDIS_INSTALL_BIN_FOLDER='/opt/redis/bin' 13 | export REDIS_INSTALL_CONFIG_FOLDER='/opt/redis/config' 14 | export REDIS_INSTALL_DATA_FOLDER='/opt/redis/data' 15 | 16 | export REDIS_VM_OVER_COMMIT_MEMORY='1' -------------------------------------------------------------------------------- /cookbooks/redis/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | installBuildEssential 6 | } 7 | 8 | function install() 9 | { 10 | umask '0022' 11 | 12 | # Clean Up 13 | 14 | initializeFolder "${REDIS_INSTALL_BIN_FOLDER}" 15 | initializeFolder "${REDIS_INSTALL_CONFIG_FOLDER}" 16 | initializeFolder "${REDIS_INSTALL_DATA_FOLDER}" 17 | 18 | # Install 19 | 20 | local -r tempFolder="$(getTemporaryFolder)" 21 | 22 | unzipRemoteFile "${REDIS_DOWNLOAD_URL}" "${tempFolder}" 23 | cd "${tempFolder}" 24 | make 25 | 26 | find "${tempFolder}/src" \ 27 | -xtype f \ 28 | \( \ 29 | -not -name '*.rb' -a \ 30 | -not -name '*.sh' \ 31 | \) \ 32 | -perm -u+x \ 33 | -exec cp -f '{}' "${REDIS_INSTALL_BIN_FOLDER}" \; 34 | 35 | rm -f -r "${tempFolder}" 36 | 37 | createFileFromTemplate \ 38 | "$(dirname "${BASH_SOURCE[0]}")/../templates/redis.conf.conf" \ 39 | "${REDIS_INSTALL_CONFIG_FOLDER}/redis.conf" \ 40 | '__INSTALL_DATA_FOLDER__' "${REDIS_INSTALL_DATA_FOLDER}" \ 41 | '6379' "${REDIS_PORT}" 42 | 43 | createFileFromTemplate \ 44 | "$(dirname "${BASH_SOURCE[0]}")/../templates/redis.sh.profile" \ 45 | '/etc/profile.d/redis.sh' \ 46 | '__INSTALL_BIN_FOLDER__' "${REDIS_INSTALL_BIN_FOLDER}" 47 | 48 | createInitFileFromTemplate \ 49 | "${REDIS_SERVICE_NAME}" \ 50 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 51 | '__INSTALL_BIN_FOLDER__' "${REDIS_INSTALL_BIN_FOLDER}" \ 52 | '__INSTALL_CONFIG_FOLDER__' "${REDIS_INSTALL_CONFIG_FOLDER}" \ 53 | '__USER_NAME__' "${REDIS_USER_NAME}" \ 54 | '__GROUP_NAME__' "${REDIS_GROUP_NAME}" 55 | 56 | # Config System 57 | 58 | local -r overCommitMemoryConfig="vm.overcommit_memory = ${REDIS_VM_OVER_COMMIT_MEMORY}" 59 | 60 | appendToFileIfNotFound \ 61 | '/etc/sysctl.conf' \ 62 | "$(stringToSearchPattern "${overCommitMemoryConfig}")" \ 63 | "\n${overCommitMemoryConfig}" \ 64 | 'true' \ 65 | 'true' \ 66 | 'true' 67 | 68 | sysctl "$(deleteSpaces "${overCommitMemoryConfig}")" 69 | 70 | # Start 71 | 72 | addUser "${REDIS_USER_NAME}" "${REDIS_GROUP_NAME}" 'false' 'true' 'false' 73 | chown -R "${REDIS_USER_NAME}:${REDIS_GROUP_NAME}" "${REDIS_INSTALL_BIN_FOLDER}" "${REDIS_INSTALL_CONFIG_FOLDER}" "${REDIS_INSTALL_DATA_FOLDER}" 74 | startService "${REDIS_SERVICE_NAME}" 75 | 76 | # Display Open Ports 77 | 78 | displayOpenPorts '5' 79 | 80 | # Display Version 81 | 82 | displayVersion "$(redis-server --version)" 83 | 84 | umask '0077' 85 | } 86 | 87 | function main() 88 | { 89 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 90 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 91 | 92 | header 'INSTALLING REDIS' 93 | 94 | checkRequireLinuxSystem 95 | checkRequireRootUser 96 | checkRequirePorts "${REDIS_PORT}" 97 | 98 | installDependencies 99 | install 100 | installCleanUp 101 | } 102 | 103 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/redis/templates/redis.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Redis Server 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | ExecStart='__INSTALL_BIN_FOLDER__/redis-server' '__INSTALL_CONFIG_FOLDER__/redis.conf' -------------------------------------------------------------------------------- /cookbooks/redis/templates/redis.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_BIN_FOLDER__:${PATH}" -------------------------------------------------------------------------------- /cookbooks/ruby/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export RUBY_DOWNLOAD_URL='https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.gz' 4 | 5 | export RUBY_INSTALL_FOLDER_PATH='/opt/ruby' -------------------------------------------------------------------------------- /cookbooks/ruby/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | installBuildEssential 6 | 7 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 8 | then 9 | installPackages 'libffi-dev' 'libgdbm-dev' 'libreadline-dev' 'libssl-dev' 'zlib1g-dev' 10 | fi 11 | } 12 | 13 | function install() 14 | { 15 | umask '0022' 16 | 17 | compileAndInstallFromSource \ 18 | "${RUBY_DOWNLOAD_URL}" \ 19 | "${RUBY_INSTALL_FOLDER_PATH}" \ 20 | "${RUBY_INSTALL_FOLDER_PATH}/bin" \ 21 | "$(whoami)" 22 | 23 | displayVersion "$(ruby --version)" 24 | 25 | umask '0077' 26 | } 27 | 28 | function main() 29 | { 30 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 31 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 32 | 33 | header 'INSTALLING RUBY' 34 | 35 | checkRequireLinuxSystem 36 | checkRequireRootUser 37 | 38 | installDependencies 39 | install 40 | installCleanUp 41 | } 42 | 43 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/selenium-server/attributes/hub.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export SELENIUM_SERVER_DOWNLOAD_URL='https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.1.0/selenium-server-4.1.1.jar' 4 | 5 | export SELENIUM_SERVER_INSTALL_FOLDER_PATH='/opt/selenium-server/hub' 6 | 7 | export SELENIUM_SERVER_SERVICE_NAME='selenium-server-hub' 8 | 9 | export SELENIUM_SERVER_USER_NAME='selenium' 10 | export SELENIUM_SERVER_GROUP_NAME='selenium' 11 | 12 | export SELENIUM_SERVER_PORT='4444' -------------------------------------------------------------------------------- /cookbooks/selenium-server/attributes/node.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export SELENIUM_SERVER_DOWNLOAD_URL='http://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar' 4 | 5 | export SELENIUM_SERVER_INSTALL_FOLDER_PATH='/opt/selenium-server/node' 6 | 7 | export SELENIUM_SERVER_SERVICE_NAME='selenium-server-node' 8 | 9 | export SELENIUM_SERVER_USER_NAME='selenium' 10 | export SELENIUM_SERVER_GROUP_NAME='selenium' 11 | 12 | export SELENIUM_SERVER_PORT='5555' 13 | export SELENIUM_SERVER_HUB_PORT='4444' 14 | export SELENIUM_SERVER_HUB_HOST='127.0.0.1' -------------------------------------------------------------------------------- /cookbooks/selenium-server/libraries/app.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 4 | 5 | function installRole() 6 | { 7 | local -r role="${1}" 8 | local -r serverConfigDataRole=("${@:2}") 9 | 10 | checkNonEmptyString "${role}" 'undefined role' 11 | 12 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/${role}.bash" 13 | 14 | # Clean Up 15 | 16 | initializeFolder "${SELENIUM_SERVER_INSTALL_FOLDER_PATH}" 17 | 18 | # Install 19 | 20 | local -r jarFile="${SELENIUM_SERVER_INSTALL_FOLDER_PATH}/selenium-server.jar" 21 | 22 | downloadFile "${SELENIUM_SERVER_DOWNLOAD_URL}" "${jarFile}" 'true' 23 | 24 | # Config Server 25 | 26 | local -r configFile="${SELENIUM_SERVER_INSTALL_FOLDER_PATH}/selenium-server-${role}.json" 27 | 28 | createFileFromTemplate \ 29 | "$(dirname "${BASH_SOURCE[0]}")/../templates/selenium-server-${role}.json.conf" \ 30 | "${configFile}" \ 31 | "${serverConfigDataRole[@]}" 32 | 33 | # Config Init 34 | 35 | createInitFileFromTemplate \ 36 | "selenium-server-${role}" \ 37 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 38 | '__INSTALL_FILE__' "${jarFile}" \ 39 | '__CONFIG_FILE__' "${configFile}" \ 40 | '__USER_NAME__' "${SELENIUM_SERVER_USER_NAME}" \ 41 | '__GROUP_NAME__' "${SELENIUM_SERVER_GROUP_NAME}" 42 | 43 | # Start 44 | 45 | addUser "${SELENIUM_SERVER_USER_NAME}" "${SELENIUM_SERVER_GROUP_NAME}" 'false' 'true' 'false' 46 | chown -R "${SELENIUM_SERVER_USER_NAME}:${SELENIUM_SERVER_GROUP_NAME}" "${SELENIUM_SERVER_INSTALL_FOLDER_PATH}" 47 | startService "${SELENIUM_SERVER_SERVICE_NAME}" 48 | } -------------------------------------------------------------------------------- /cookbooks/selenium-server/recipes/install-hub.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | # Install 16 | 17 | installRole \ 18 | 'hub' \ 19 | '__PORT__' "${SELENIUM_SERVER_PORT}" 20 | 21 | # Display Open Ports 22 | 23 | displayOpenPorts '5' 24 | 25 | umask '0077' 26 | } 27 | 28 | function main() 29 | { 30 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 31 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/hub.bash" 32 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/app.bash" 33 | 34 | header 'INSTALLING HUB SELENIUM-SERVER' 35 | 36 | checkRequireLinuxSystem 37 | checkRequireRootUser 38 | checkRequirePorts "${SELENIUM_SERVER_PORT}" 39 | 40 | installDependencies 41 | install 42 | installCleanUp 43 | } 44 | 45 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/selenium-server/recipes/install-node.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | local -r hubHost="${1}" 14 | 15 | umask '0022' 16 | 17 | # Override Default 18 | 19 | if [[ "$(isEmptyString "${hubHost}")" = 'false' ]] 20 | then 21 | SELENIUM_SERVER_HUB_HOST="${hubHost}" 22 | fi 23 | 24 | checkNonEmptyString "${SELENIUM_SERVER_HUB_HOST}" 'undefined hub host' 25 | 26 | # Install Role 27 | 28 | installRole \ 29 | 'node' \ 30 | '__PORT__' "${SELENIUM_SERVER_PORT}" \ 31 | '__HUB_PORT__' "${SELENIUM_SERVER_HUB_PORT}" \ 32 | '__HUB_HOST__' "${SELENIUM_SERVER_HUB_HOST}" 33 | 34 | # Display Open Ports 35 | 36 | displayOpenPorts '5' 37 | 38 | umask '0077' 39 | } 40 | 41 | function main() 42 | { 43 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 44 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/node.bash" 45 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/app.bash" 46 | 47 | header 'INSTALLING NODE SELENIUM-SERVER' 48 | 49 | checkRequireLinuxSystem 50 | checkRequireRootUser 51 | checkRequirePorts "${SELENIUM_SERVER_PORT}" 52 | 53 | installDependencies 54 | install "${@}" 55 | installCleanUp 56 | } 57 | 58 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/selenium-server/templates/selenium-server-hub.json.conf: -------------------------------------------------------------------------------- 1 | { 2 | "browserTimeout": 1800, 3 | "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", 4 | "cleanUpCycle": 5000, 5 | "host": null, 6 | "jettyMaxThreads": -1, 7 | "maxSession": 5, 8 | "newSessionWaitTimeout": -1, 9 | "nodePolling": 5000, 10 | "port": __PORT__, 11 | "prioritizer": null, 12 | "role": "hub", 13 | "servlets": [], 14 | "throwOnCapabilityNotPresent": true, 15 | "timeout": 1800 16 | } -------------------------------------------------------------------------------- /cookbooks/selenium-server/templates/selenium-server-hub.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Selenium Server (Hub) 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | ExecStart=/bin/bash -c -e '\ 35 | java -jar \'__INSTALL_FILE__\' \'hub\' --config \'__CONFIG_FILE__\' \ 36 | ' -------------------------------------------------------------------------------- /cookbooks/selenium-server/templates/selenium-server-node.json.conf: -------------------------------------------------------------------------------- 1 | { 2 | "capabilities": [{ 3 | "browserName": "chrome", 4 | "maxInstances": 5, 5 | "seleniumProtocol": "WebDriver" 6 | }, { 7 | "browserName": "firefox", 8 | "maxInstances": 5, 9 | "seleniumProtocol": "WebDriver" 10 | }, { 11 | "browserName": "internet explorer", 12 | "maxInstances": 5, 13 | "seleniumProtocol": "WebDriver" 14 | }, { 15 | "browserName": "MicrosoftEdge", 16 | "maxInstances": 5, 17 | "seleniumProtocol": "WebDriver" 18 | }, { 19 | "browserName": "safari", 20 | "maxInstances": 5, 21 | "seleniumProtocol": "WebDriver" 22 | }], 23 | "hub": "http://__HUB_HOST__:__HUB_PORT__", 24 | "maxSession": 5, 25 | "port": __PORT__, 26 | "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", 27 | "register": true, 28 | "registerCycle": 5000 29 | } -------------------------------------------------------------------------------- /cookbooks/selenium-server/templates/selenium-server-node.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Selenium Server (Node) 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | ExecStart=/bin/bash -c -e '\ 35 | java -jar \'__INSTALL_FILE__\' -role \'node\' -nodeConfig \'__CONFIG_FILE__\' \ 36 | ' -------------------------------------------------------------------------------- /cookbooks/shell-check/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export SHELL_CHECK_CABAL_INSTALL_FOLDER_PATH='/opt/cabal' -------------------------------------------------------------------------------- /cookbooks/shell-check/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | installPackages 'cabal-install' 6 | } 7 | 8 | function install() 9 | { 10 | umask '0022' 11 | 12 | local -r userHomeFolderPath="$(getCurrentUserHomeFolder)" 13 | 14 | rm -f -r "${userHomeFolderPath}/.cabal" "${userHomeFolderPath}/.ghc" 15 | initializeFolder "${SHELL_CHECK_CABAL_INSTALL_FOLDER_PATH}" 16 | 17 | cabal update 18 | cabal install 'shellcheck' 19 | 20 | moveFolderContent "${userHomeFolderPath}/.cabal" "${SHELL_CHECK_CABAL_INSTALL_FOLDER_PATH}" 21 | rm -f -r "${userHomeFolderPath}/.cabal" "${userHomeFolderPath}/.ghc" 22 | symlinkListUsrBin "${SHELL_CHECK_CABAL_INSTALL_FOLDER_PATH}/bin/shellcheck" 23 | 24 | createFileFromTemplate \ 25 | "$(dirname "${BASH_SOURCE[0]}")/../templates/cabal.sh.profile" \ 26 | '/etc/profile.d/cabal.sh' \ 27 | '__INSTALL_FOLDER_PATH__' \ 28 | "${SHELL_CHECK_CABAL_INSTALL_FOLDER_PATH}" 29 | 30 | displayVersion "$(shellcheck -V)" 31 | 32 | umask '0077' 33 | } 34 | 35 | function main() 36 | { 37 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 38 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 39 | 40 | header 'INSTALLING SHELL-CHECK' 41 | 42 | checkRequireLinuxSystem 43 | checkRequireRootUser 44 | 45 | installDependencies 46 | install 47 | installCleanUp 48 | } 49 | 50 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/shell-check/templates/cabal.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/splunkforwarder/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export SPLUNKFORWARDER_DOWNLOAD_URL='https://download.splunk.com/products/universalforwarder/releases/7.3.1.1/linux/splunkforwarder-7.3.1.1-7651b7244cf2-Linux-x86_64.tgz' 4 | 5 | export SPLUNKFORWARDER_INSTALL_FOLDER_PATH='/opt/splunkforwarder' 6 | 7 | export SPLUNKFORWARDER_USER_NAME='splunk' 8 | export SPLUNKFORWARDER_GROUP_NAME='splunk' 9 | 10 | export SPLUNKFORWARDER_SERVICE_NAME='splunk' -------------------------------------------------------------------------------- /cookbooks/splunkforwarder/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | # Clean Up 8 | 9 | initializeFolder "${SPLUNKFORWARDER_INSTALL_FOLDER_PATH}" 10 | 11 | # Install 12 | 13 | unzipRemoteFile "${SPLUNKFORWARDER_DOWNLOAD_URL}" "${SPLUNKFORWARDER_INSTALL_FOLDER_PATH}" 14 | 15 | # Config Init 16 | 17 | if [[ "$(existCommand 'systemctl')" = 'true' ]] 18 | then 19 | createInitFileFromTemplate \ 20 | "${SPLUNKFORWARDER_SERVICE_NAME}" \ 21 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 22 | '__GROUP_NAME__' "${SPLUNKFORWARDER_GROUP_NAME}" \ 23 | '__INSTALL_FOLDER_PATH__' "${SPLUNKFORWARDER_INSTALL_FOLDER_PATH}" \ 24 | '__USER_NAME__' "${SPLUNKFORWARDER_USER_NAME}" 25 | else 26 | "${SPLUNKFORWARDER_INSTALL_FOLDER_PATH}/bin/splunk" enable boot-start --accept-license --answer-yes --no-prompt 27 | fi 28 | 29 | # Config Profile 30 | 31 | createFileFromTemplate \ 32 | "$(dirname "${BASH_SOURCE[0]}")/../templates/splunk.sh.profile" \ 33 | '/etc/profile.d/splunk.sh' \ 34 | '__INSTALL_FOLDER_PATH__' \ 35 | "${SPLUNKFORWARDER_INSTALL_FOLDER_PATH}" 36 | 37 | # Enable (Not Start Yet) 38 | 39 | addUser "${SPLUNKFORWARDER_USER_NAME}" "${SPLUNKFORWARDER_GROUP_NAME}" 'false' 'true' 'false' 40 | chown -R "${SPLUNKFORWARDER_USER_NAME}:${SPLUNKFORWARDER_GROUP_NAME}" "${SPLUNKFORWARDER_INSTALL_FOLDER_PATH}" 41 | enableService "${SPLUNKFORWARDER_SERVICE_NAME}" 42 | 43 | umask '0077' 44 | } 45 | 46 | function main() 47 | { 48 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 49 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 50 | 51 | header 'INSTALLING SPLUNKFORWARDER' 52 | 53 | checkRequireLinuxSystem 54 | checkRequireRootUser 55 | checkRequirePorts '8089' 56 | 57 | install 58 | installCleanUp 59 | } 60 | 61 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/splunkforwarder/templates/splunk.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=SplunkForwarder Server 3 | Wants=network.target syslog.service 4 | After=network.target syslog.target 5 | 6 | [Install] 7 | WantedBy=multi-user.target 8 | 9 | [Service] 10 | Type=forking 11 | RemainAfterExit=True 12 | 13 | LimitAS=infinity 14 | LimitCORE=infinity 15 | LimitCPU=infinity 16 | LimitDATA=infinity 17 | LimitFSIZE=infinity 18 | LimitLOCKS=infinity 19 | LimitMEMLOCK=64000 20 | LimitMSGQUEUE=819200 21 | LimitNOFILE=64000 22 | LimitNPROC=16000 23 | LimitRSS=infinity 24 | LimitRTPRIO=0 25 | LimitSIGPENDING=16000 26 | LimitSTACK=8192000 27 | 28 | Restart=always 29 | RestartSec=10 30 | 31 | TimeoutSec=30 32 | 33 | User=__USER_NAME__ 34 | Group=__GROUP_NAME__ 35 | 36 | Environment='SPLUNK_HOME=__INSTALL_FOLDER_PATH__' 37 | Environment='SPLUNK_MODULE_PATH=__INSTALL_FOLDER_PATH__/etc/modules' 38 | 39 | ExecStart='__INSTALL_FOLDER_PATH__/bin/splunk' start --accept-license --answer-yes --no-prompt 40 | ExecStop='__INSTALL_FOLDER_PATH__/bin/splunk' stop 41 | ExecReload='__INSTALL_FOLDER_PATH__/bin/splunk' restart -------------------------------------------------------------------------------- /cookbooks/splunkforwarder/templates/splunk.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export SPLUNK_HOME='__INSTALL_FOLDER_PATH__' 4 | export SPLUNK_MODULE_PATH='__INSTALL_FOLDER_PATH__/etc/modules' 5 | 6 | export PATH="__INSTALL_FOLDER_PATH__/bin:${PATH}" -------------------------------------------------------------------------------- /cookbooks/ssh/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export SSH_CONFIGS=( 4 | 'AllowTcpForwarding yes' 5 | 'GatewayPorts yes' 6 | 'PubkeyAuthentication yes' 7 | ) -------------------------------------------------------------------------------- /cookbooks/ssh/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | installPackages 'openssh-server' 6 | } 7 | 8 | function install() 9 | { 10 | umask '0022' 11 | 12 | local config='' 13 | 14 | for config in "${SSH_CONFIGS[@]}" 15 | do 16 | header "ADDING SSH CONFIG '${config}'" 17 | 18 | local searchRegex='' 19 | searchRegex="(^[[:space:]]*)($(awk '{ print $1 }' <<< "${config}")[[:space:]]+.*$)" 20 | 21 | sed -E "s/${searchRegex}/\1${config}/g" \ 22 | <<< "$(cat '/etc/ssh/sshd_config')" \ 23 | > '/etc/ssh/sshd_config' || true 24 | 25 | appendToFileIfNotFound \ 26 | '/etc/ssh/sshd_config' \ 27 | "$(stringToSearchPattern "${config}")" \ 28 | "${config}" \ 29 | 'true' \ 30 | 'false' \ 31 | 'true' 32 | 33 | grep -F "${config}" '/etc/ssh/sshd_config' | grep -v '^\s*#' 34 | done 35 | 36 | restartService 'sshd' 37 | 38 | if [[ "$(isPortOpen '22')" = 'false' ]] 39 | then 40 | fatal '\nFATAL : ssh service start failed' 41 | fi 42 | 43 | umask '0077' 44 | } 45 | 46 | function main() 47 | { 48 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 49 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 50 | 51 | header 'INSTALLING SSH' 52 | 53 | checkRequireLinuxSystem 54 | checkRequireRootUser 55 | 56 | installDependencies 57 | install 58 | installCleanUp 59 | } 60 | 61 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/terraform/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export TERRAFORM_DOWNLOAD_URL='https://releases.hashicorp.com/terraform/0.12.14/terraform_0.12.14_linux_amd64.zip' 4 | 5 | export TERRAFORM_INSTALL_FOLDER_PATH='/opt/terraform' -------------------------------------------------------------------------------- /cookbooks/terraform/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | installPortableBinary \ 9 | 'TERRAFORM' \ 10 | "${TERRAFORM_DOWNLOAD_URL}" \ 11 | "${TERRAFORM_INSTALL_FOLDER_PATH}" \ 12 | 'terraform' \ 13 | 'version' \ 14 | 'true' 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/test-ssl/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export TEST_SSL_DOWNLOAD_URL='https://codeload.github.com/drwetter/testssl.sh/tar.gz/v3.2.0' 4 | 5 | export TEST_SSL_INSTALL_FOLDER_PATH='/opt/test-ssl' -------------------------------------------------------------------------------- /cookbooks/test-ssl/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | initializeFolder "${TEST_SSL_INSTALL_FOLDER_PATH}" 8 | 9 | unzipRemoteFile "${TEST_SSL_DOWNLOAD_URL}" "${TEST_SSL_INSTALL_FOLDER_PATH}" 10 | chown -R "$(whoami):$(whoami)" "${TEST_SSL_INSTALL_FOLDER_PATH}" 11 | symlinkListUsrBin "${TEST_SSL_INSTALL_FOLDER_PATH}/testssl.sh" 12 | 13 | createFileFromTemplate \ 14 | "$(dirname "${BASH_SOURCE[0]}")/../templates/test-ssl.sh.profile" \ 15 | '/etc/profile.d/test-ssl.sh' \ 16 | '__INSTALL_FOLDER_PATH__' "${TEST_SSL_INSTALL_FOLDER_PATH}" 17 | 18 | displayVersion "$(testssl.sh -v)" 19 | 20 | umask '0077' 21 | } 22 | 23 | function main() 24 | { 25 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 26 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 27 | 28 | header 'INSTALLING TEST-SSL' 29 | 30 | checkRequireLinuxSystem 31 | checkRequireRootUser 32 | 33 | install 34 | installCleanUp 35 | } 36 | 37 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/test-ssl/templates/test-ssl.sh.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export PATH="__INSTALL_FOLDER_PATH__:${PATH}" -------------------------------------------------------------------------------- /cookbooks/tmp-reaper/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export TMP_REAPER_CRON_FOLDER='/etc/cron.hourly' 4 | 5 | export TMP_REAPER_FOLDERS=( 6 | '/tmp' '/tmp/vagrant-chef' '1d' 7 | '/var/tmp' '' '7d' 8 | ) -------------------------------------------------------------------------------- /cookbooks/tmp-reaper/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 8 | then 9 | # Install 10 | 11 | installPackages 'tmpreaper' 12 | 13 | # Config Cron 14 | 15 | local content='' 16 | local i=0 17 | 18 | for ((i = 0; i < ${#TMP_REAPER_FOLDERS[@]}; i = i + 3)) 19 | do 20 | if [[ "$(isEmptyString "${TMP_REAPER_FOLDERS[${i} + 1]}")" = 'true' ]] 21 | then 22 | content="${content}\ntmpreaper -a -f -s -v '${TMP_REAPER_FOLDERS[${i} + 2]}' '${TMP_REAPER_FOLDERS[${i}]}'" 23 | else 24 | content="${content}\ntmpreaper -a -f -s -v --protect '${TMP_REAPER_FOLDERS[${i} + 1]}' '${TMP_REAPER_FOLDERS[${i} + 2]}' '${TMP_REAPER_FOLDERS[${i}]}'" 25 | fi 26 | done 27 | 28 | echo -e "$(removeEmptyLines "${content}")" > "${TMP_REAPER_CRON_FOLDER}/tmp-reaper" 29 | chmod 755 "${TMP_REAPER_CRON_FOLDER}/tmp-reaper" 30 | rm -f "${TMP_REAPER_CRON_FOLDER}/.placeholder" 31 | 32 | echo 33 | cat "${TMP_REAPER_CRON_FOLDER}/tmp-reaper" 34 | else 35 | fatal 'FATAL : only support Ubuntu OS' 36 | fi 37 | 38 | umask '0077' 39 | } 40 | 41 | function main() 42 | { 43 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 44 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 45 | 46 | header 'INSTALLING TMP-REAPER' 47 | 48 | checkRequireLinuxSystem 49 | checkRequireRootUser 50 | 51 | install 52 | installCleanUp 53 | } 54 | 55 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/tmp-watch/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export TMP_WATCH_CRON_FOLDER='/etc/cron.hourly' 4 | 5 | export TMP_WATCH_FOLDERS=( 6 | '/tmp' '/tmp/vagrant-chef' '1d' 7 | '/var/tmp' '' '7d' 8 | ) -------------------------------------------------------------------------------- /cookbooks/tmp-watch/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | if [[ "$(isAmazonLinuxDistributor)" = 'true' || "$(isCentOSDistributor)" = 'true' || "$(isRedHatDistributor)" = 'true' ]] 8 | then 9 | # Install 10 | 11 | installPackages 'tmpwatch' 12 | 13 | # Config Cron 14 | 15 | local content='' 16 | local i=0 17 | 18 | for ((i = 0; i < ${#TMP_WATCH_FOLDERS[@]}; i = i + 3)) 19 | do 20 | if [[ "$(isEmptyString "${TMP_WATCH_FOLDERS[${i} + 1]}")" = 'true' ]] 21 | then 22 | content="${content}\ntmpwatch -a -f -u -v '${TMP_WATCH_FOLDERS[${i} + 2]}' '${TMP_WATCH_FOLDERS[${i}]}'" 23 | else 24 | content="${content}\ntmpwatch -a -f -u -v -x '${TMP_WATCH_FOLDERS[${i} + 1]}' '${TMP_WATCH_FOLDERS[${i} + 2]}' '${TMP_WATCH_FOLDERS[${i}]}'" 25 | fi 26 | done 27 | 28 | echo -e "$(removeEmptyLines "${content}")" > "${TMP_WATCH_CRON_FOLDER}/tmp-watch" 29 | chmod 755 "${TMP_WATCH_CRON_FOLDER}/tmp-watch" 30 | rm -f "${TMP_WATCH_CRON_FOLDER}/.placeholder" 31 | 32 | echo 33 | cat "${TMP_WATCH_CRON_FOLDER}/tmp-watch" 34 | else 35 | fatal 'FATAL : only support Amazon-Linux, CentOS or RedHat OS' 36 | fi 37 | 38 | umask '0077' 39 | } 40 | 41 | function main() 42 | { 43 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 44 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 45 | 46 | header 'INSTALLING TMP-WATCH' 47 | 48 | checkRequireLinuxSystem 49 | checkRequireRootUser 50 | 51 | install 52 | installCleanUp 53 | } 54 | 55 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/tomcat/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export TOMCAT_DOWNLOAD_URL='http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz' 4 | 5 | export TOMCAT_INSTALL_FOLDER_PATH='/opt/tomcat' 6 | 7 | export TOMCAT_SERVICE_NAME='tomcat' 8 | 9 | export TOMCAT_USER_NAME='tomcat' 10 | export TOMCAT_GROUP_NAME='tomcat' 11 | 12 | export TOMCAT_AJP_PORT='8009' 13 | export TOMCAT_COMMAND_PORT='8005' 14 | export TOMCAT_HTTP_PORT='8080' 15 | export TOMCAT_HTTPS_PORT='8443' -------------------------------------------------------------------------------- /cookbooks/tomcat/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | # Clean Up 16 | 17 | initializeFolder "${TOMCAT_INSTALL_FOLDER_PATH}" 18 | 19 | # Install 20 | 21 | unzipRemoteFile "${TOMCAT_DOWNLOAD_URL}" "${TOMCAT_INSTALL_FOLDER_PATH}" 22 | 23 | # Config Server 24 | 25 | createFileFromTemplate \ 26 | "${TOMCAT_INSTALL_FOLDER_PATH}/conf/server.xml" \ 27 | "${TOMCAT_INSTALL_FOLDER_PATH}/conf/server.xml" \ 28 | '8009' "${TOMCAT_AJP_PORT}" \ 29 | '8005' "${TOMCAT_COMMAND_PORT}" \ 30 | '8080' "${TOMCAT_HTTP_PORT}" \ 31 | '8443' "${TOMCAT_HTTPS_PORT}" 32 | 33 | # Add User 34 | 35 | addUser "${TOMCAT_USER_NAME}" "${TOMCAT_GROUP_NAME}" 'true' 'true' 'true' 36 | 37 | # Config Init 38 | 39 | createInitFileFromTemplate \ 40 | "${TOMCAT_SERVICE_NAME}" \ 41 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 42 | '__INSTALL_FOLDER_PATH__' "${TOMCAT_INSTALL_FOLDER_PATH}" \ 43 | '__USER_NAME__' "${TOMCAT_USER_NAME}" \ 44 | '__GROUP_NAME__' "${TOMCAT_GROUP_NAME}" 45 | 46 | # Start 47 | 48 | chown -R "${TOMCAT_USER_NAME}:${TOMCAT_GROUP_NAME}" "${TOMCAT_INSTALL_FOLDER_PATH}" 49 | startService "${TOMCAT_SERVICE_NAME}" 50 | 51 | # Display Open Ports 52 | 53 | displayOpenPorts '8' 54 | 55 | # Display Version 56 | 57 | displayVersion "$("${TOMCAT_INSTALL_FOLDER_PATH}/bin/version.sh")" 58 | 59 | umask '0077' 60 | } 61 | 62 | function main() 63 | { 64 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 65 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 66 | 67 | header 'INSTALLING TOMCAT' 68 | 69 | checkRequireLinuxSystem 70 | checkRequireRootUser 71 | checkRequirePorts "${TOMCAT_AJP_PORT}" "${TOMCAT_COMMAND_PORT}" "${TOMCAT_HTTP_PORT}" "${TOMCAT_HTTPS_PORT}" 72 | 73 | installDependencies 74 | install 75 | installCleanUp 76 | } 77 | 78 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/tomcat/templates/tomcat.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Tomcat Server 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=forking 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | ExecStartPre=/bin/bash -c -e '\ 35 | find \'__INSTALL_FOLDER_PATH__/logs\' -mindepth 1 -delete && \ 36 | find \'__INSTALL_FOLDER_PATH__/temp\' -mindepth 1 -delete \ 37 | ' 38 | ExecStart='__INSTALL_FOLDER_PATH__/bin/startup.sh' 39 | ExecStop='__INSTALL_FOLDER_PATH__/bin/shutdown.sh' -------------------------------------------------------------------------------- /cookbooks/tweaks/attributes/hugepage.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export HUGEPAGE_SERVICE_NAME='hugepage' -------------------------------------------------------------------------------- /cookbooks/tweaks/recipes/disable-hugepage.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | createInitFileFromTemplate "${HUGEPAGE_SERVICE_NAME}" "$(dirname "${BASH_SOURCE[0]}")/../templates" 8 | startService "${HUGEPAGE_SERVICE_NAME}" 9 | 10 | umask '0077' 11 | } 12 | 13 | function main() 14 | { 15 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 16 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/hugepage.bash" 17 | 18 | header 'DISABLING HUGEPAGE' 19 | 20 | checkRequireLinuxSystem 21 | checkRequireRootUser 22 | 23 | install 24 | installCleanUp 25 | } 26 | 27 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/tweaks/recipes/disable-icmp-timestamp.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | appendToFileIfNotFound \ 8 | '/etc/sysctl.conf' \ 9 | 'net.ipv4.icmp_echo_ignore_all = 1' \ 10 | 'net.ipv4.icmp_echo_ignore_all = 1' \ 11 | 'false' \ 12 | 'false' \ 13 | 'true' 14 | 15 | cat '/etc/sysctl.conf' 16 | 17 | umask '0077' 18 | } 19 | 20 | function main() 21 | { 22 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 23 | 24 | header 'DISABLING ICMP-TIMESTAMP' 25 | 26 | checkRequireLinuxSystem 27 | checkRequireRootUser 28 | 29 | install 30 | installCleanUp 31 | } 32 | 33 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/tweaks/recipes/disable-tcp-timestamp.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | appendToFileIfNotFound \ 8 | '/etc/sysctl.conf' \ 9 | 'net.ipv4.tcp_timestamps = 0' \ 10 | 'net.ipv4.tcp_timestamps = 0' \ 11 | 'false' \ 12 | 'false' \ 13 | 'true' 14 | 15 | cat '/etc/sysctl.conf' 16 | 17 | umask '0077' 18 | } 19 | 20 | function main() 21 | { 22 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 23 | 24 | header 'DISABLING TCP-TIMESTAMP' 25 | 26 | checkRequireLinuxSystem 27 | checkRequireRootUser 28 | 29 | install 30 | installCleanUp 31 | } 32 | 33 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/tweaks/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | "$(dirname "${BASH_SOURCE[0]}")/disable-hugepage.bash" 6 | "$(dirname "${BASH_SOURCE[0]}")/disable-icmp-timestamp.bash" 7 | "$(dirname "${BASH_SOURCE[0]}")/disable-tcp-timestamp.bash" 8 | } 9 | 10 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/tweaks/templates/hugepage.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Hugepage 3 | After=sshd.service 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=oneshot 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | User=root 27 | Group=root 28 | 29 | ExecStart=/bin/bash -c -e '\ 30 | echo \'never\' | tee \'/sys/kernel/mm/transparent_hugepage/defrag\' ; \ 31 | echo \'never\' | tee \'/sys/kernel/mm/transparent_hugepage/enabled\' ; \ 32 | ' -------------------------------------------------------------------------------- /cookbooks/ufw/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export UFW_POLICIES=( 4 | 'allow 22/tcp' 5 | 'allow 80/tcp' 6 | 'allow 443/tcp' 7 | ) -------------------------------------------------------------------------------- /cookbooks/ufw/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 8 | then 9 | installPackages 'ufw' 10 | 11 | # Set Up Policies 12 | 13 | ufw --force reset 14 | ufw default deny incoming 15 | ufw default allow outgoing 16 | 17 | local policy='' 18 | 19 | for policy in "${UFW_POLICIES[@]}" 20 | do 21 | local rule=(${policy}) 22 | 23 | ufw "${rule[@]}" 24 | done 25 | 26 | # Enable Service 27 | 28 | ufw --force enable 29 | ufw status verbose 30 | else 31 | fatal 'FATAL : only support Ubuntu OS' 32 | fi 33 | 34 | umask '0077' 35 | } 36 | 37 | function main() 38 | { 39 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 40 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 41 | 42 | header 'INSTALLING UFW' 43 | 44 | checkRequireLinuxSystem 45 | checkRequireRootUser 46 | 47 | install 48 | installCleanUp 49 | } 50 | 51 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/ulimit/files/limits.conf: -------------------------------------------------------------------------------- 1 | # core file size 2 | * - core unlimited 3 | root - core unlimited 4 | 5 | # cpu time 6 | * - cpu unlimited 7 | root - cpu unlimited 8 | 9 | # data seg size 10 | * - data unlimited 11 | root - data unlimited 12 | 13 | # file locks 14 | * - locks unlimited 15 | root - locks unlimited 16 | 17 | # file size 18 | * - fsize unlimited 19 | root - fsize unlimited 20 | 21 | # max locked memory 22 | * - memlock 64 23 | root - memlock 64 24 | 25 | # max memory size 26 | * - rss unlimited 27 | root - rss unlimited 28 | 29 | # max user processes 30 | * - nproc 16000 31 | root - nproc 16000 32 | 33 | # open files 34 | * - nofile 64000 35 | root - nofile 64000 36 | 37 | # pending signals 38 | * - sigpending 16000 39 | root - sigpending 16000 40 | 41 | # POSIX message queues 42 | * - msgqueue 819200 43 | root - msgqueue 819200 44 | 45 | # real-time priority 46 | * - rtprio 0 47 | root - rtprio 0 48 | 49 | # stack size 50 | * - stack 8192 51 | root - stack 8192 52 | 53 | # virtual memory 54 | * - as unlimited 55 | root - as unlimited -------------------------------------------------------------------------------- /cookbooks/ulimit/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | cp -f "$(dirname "${BASH_SOURCE[0]}")/../files/limits.conf" '/etc/security/limits.conf' 8 | displayVersion "$(cat '/etc/security/limits.conf')" 9 | 10 | umask '0077' 11 | } 12 | 13 | function main() 14 | { 15 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 16 | 17 | header 'INSTALLING ULIMIT' 18 | 19 | checkRequireLinuxSystem 20 | checkRequireRootUser 21 | 22 | install 23 | installCleanUp 24 | } 25 | 26 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/vault/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export VAULT_DOWNLOAD_URL='https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip' 4 | 5 | export VAULT_INSTALL_FOLDER_PATH='/opt/vault' -------------------------------------------------------------------------------- /cookbooks/vault/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | installPortableBinary \ 9 | 'VAULT' \ 10 | "${VAULT_DOWNLOAD_URL}" \ 11 | "${VAULT_INSTALL_FOLDER_PATH}" \ 12 | 'vault' \ 13 | 'version' \ 14 | 'true' 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/vbox-guest-additions/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export VBOX_GUEST_ADDITIONS_DOWNLOAD_URL='http://download.virtualbox.org/virtualbox/6.0.14/VBoxGuestAdditions_6.0.14.iso' -------------------------------------------------------------------------------- /cookbooks/vbox-guest-additions/files/vbox-guest-additions.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=VBox Guest Additions Module 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | ExecStart=/bin/bash -c -e '\ 32 | (lsmod | awk \'{ print $1 }\' | grep -F -o \'vboxguest\' > \'/dev/null\') || \ 33 | (modprobe -q \'vboxguest\') || \ 34 | (service \'vboxadd\' setup && service \'vboxadd\' start && service \'vboxadd-service\' start) \ 35 | ' -------------------------------------------------------------------------------- /cookbooks/vbox-guest-additions/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | installBuildEssential 6 | } 7 | 8 | function install() 9 | { 10 | umask '0022' 11 | 12 | # Download 13 | 14 | local -r tempISOFilePath="$(getTemporaryFile)" 15 | local -r tempMountFolderPath="$(getTemporaryFolder)" 16 | local -r tempInstallerFolderPath="$(getTemporaryFolder)" 17 | 18 | downloadFile "${VBOX_GUEST_ADDITIONS_DOWNLOAD_URL}" "${tempISOFilePath}" true 19 | mount -o loop "${tempISOFilePath}" "${tempMountFolderPath}" 20 | copyFolderContent "${tempMountFolderPath}" "${tempInstallerFolderPath}" 21 | umount -v "${tempMountFolderPath}" 22 | rm -f -r "${tempISOFilePath}" "${tempMountFolderPath}" 23 | 24 | # Install 25 | 26 | "${tempInstallerFolderPath}/VBoxLinuxAdditions.run" || true 27 | rm -f -r "${tempInstallerFolderPath}" 28 | 29 | # Config Init 30 | 31 | createInitFileFromTemplate 'vbox-guest-additions' "$(dirname "${BASH_SOURCE[0]}")/../files" 32 | 33 | # Check Service Status 34 | 35 | service vboxadd status 36 | service vboxadd-service status 37 | 38 | umask '0077' 39 | } 40 | 41 | function main() 42 | { 43 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 44 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 45 | 46 | header 'INSTALLING VBOX-GUEST-ADDITIONS' 47 | 48 | checkRequireLinuxSystem 49 | checkRequireRootUser 50 | 51 | installDependencies 52 | install 53 | installCleanUp 54 | } 55 | 56 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/vim/files/vimrc.local.conf: -------------------------------------------------------------------------------- 1 | """""""""" 2 | " COLORS " 3 | """""""""" 4 | 5 | colorscheme koehler 6 | set background=dark 7 | syntax enable 8 | 9 | """"""""" 10 | " FILES " 11 | """"""""" 12 | 13 | set nobackup 14 | set noswapfile 15 | set nowb 16 | set viminfo="0" 17 | 18 | """"""""""" 19 | " GENERAL " 20 | """"""""""" 21 | 22 | set autoread 23 | 24 | """"""""""""" 25 | " INTERFACE " 26 | """"""""""""" 27 | 28 | set hlsearch 29 | set ignorecase 30 | set incsearch 31 | set noerrorbells 32 | set novisualbell 33 | set ruler 34 | set showmatch 35 | set smartcase 36 | set wildmenu 37 | 38 | """""""" 39 | " TABS " 40 | """""""" 41 | 42 | set expandtab 43 | set shiftwidth=4 44 | set softtabstop=4 45 | set smarttab 46 | set tabstop=4 -------------------------------------------------------------------------------- /cookbooks/vim/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | installPackages 'vim' 8 | 9 | mkdir -m 755 -p '/etc/vim' 10 | cp -f "$(dirname "${BASH_SOURCE[0]}")/../files/vimrc.local.conf" '/etc/vim/vimrc.local' 11 | chmod 644 '/etc/vim/vimrc.local' 12 | 13 | if [[ "$(isAmazonLinuxDistributor)" = 'true' || "$(isCentOSDistributor)" = 'true' || "$(isRedHatDistributor)" = 'true' ]] 14 | then 15 | appendToFileIfNotFound \ 16 | '/etc/profile' \ 17 | 'alias vi=vim' \ 18 | 'alias vi=vim' \ 19 | 'false' \ 20 | 'false' \ 21 | 'true' 22 | 23 | appendToFileIfNotFound \ 24 | '/etc/vimrc' \ 25 | 'source /etc/vim/vimrc.local' \ 26 | 'source /etc/vim/vimrc.local' \ 27 | 'false' \ 28 | 'false' \ 29 | 'true' 30 | fi 31 | 32 | umask '0077' 33 | } 34 | 35 | function main() 36 | { 37 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 38 | 39 | header 'INSTALLING VIM' 40 | 41 | checkRequireLinuxSystem 42 | checkRequireRootUser 43 | 44 | install 45 | installCleanUp 46 | } 47 | 48 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/vmware-tools/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function install() 4 | { 5 | umask '0022' 6 | 7 | installPackages 'open-vm-tools' 8 | 9 | if [[ "$(isAmazonLinuxDistributor)" = 'true' || "$(isCentOSDistributor)" = 'true' || "$(isRedHatDistributor)" = 'true' ]] 10 | then 11 | restartService 'vmtoolsd' 12 | else 13 | restartService 'open-vm-tools' 14 | fi 15 | 16 | umask '0077' 17 | } 18 | 19 | function main() 20 | { 21 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 22 | 23 | header 'INSTALLING VMWARE-TOOLS' 24 | 25 | checkRequireLinuxSystem 26 | checkRequireRootUser 27 | 28 | install 29 | installCleanUp 30 | } 31 | 32 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/wildfly/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export WILDFLY_DOWNLOAD_URL='https://download.jboss.org/wildfly/18.0.0.Final/wildfly-18.0.0.Final.tar.gz' 4 | 5 | export WILDFLY_INSTALL_FOLDER_PATH='/opt/wildfly' 6 | 7 | export WILDFLY_USER_NAME='wildfly' 8 | export WILDFLY_GROUP_NAME='wildfly' 9 | 10 | export WILDFLY_MANAGEMENT_USER='wildfly' 11 | export WILDFLY_MANAGEMENT_PASSWORD='wildfly' 12 | 13 | export WILDFLY_SERVICE_NAME='wildfly' 14 | 15 | export WILDFLY_APPLICATION_BIND_ADDRESS='0.0.0.0' 16 | export WILDFLY_MANAGEMENT_BIND_ADDRESS='localhost' -------------------------------------------------------------------------------- /cookbooks/wildfly/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function installDependencies() 4 | { 5 | if [[ "$(existCommand 'java')" = 'false' ]] 6 | then 7 | "$(dirname "${BASH_SOURCE[0]}")/../../jdk/recipes/install.bash" 8 | fi 9 | } 10 | 11 | function install() 12 | { 13 | umask '0022' 14 | 15 | # Clean Up 16 | 17 | initializeFolder "${WILDFLY_INSTALL_FOLDER_PATH}" 18 | 19 | # Install 20 | 21 | unzipRemoteFile "${WILDFLY_DOWNLOAD_URL}" "${WILDFLY_INSTALL_FOLDER_PATH}" 22 | 23 | # Config Init 24 | 25 | createInitFileFromTemplate \ 26 | "${WILDFLY_SERVICE_NAME}" \ 27 | "$(dirname "${BASH_SOURCE[0]}")/../templates" \ 28 | '__APPLICATION_BIND_ADDRESS__' "${WILDFLY_APPLICATION_BIND_ADDRESS}" \ 29 | '__GROUP_NAME__' "${WILDFLY_GROUP_NAME}" \ 30 | '__INSTALL_FOLDER_PATH__' "${WILDFLY_INSTALL_FOLDER_PATH}" \ 31 | '__MANAGEMENT_BIND_ADDRESS__' "${WILDFLY_MANAGEMENT_BIND_ADDRESS}" \ 32 | '__USER_NAME__' "${WILDFLY_USER_NAME}" 33 | 34 | # Add Management User 35 | 36 | "${WILDFLY_INSTALL_FOLDER_PATH}/bin/add-user.sh" --user "${WILDFLY_MANAGEMENT_USER}" --password "${WILDFLY_MANAGEMENT_PASSWORD}" 37 | 38 | # Start 39 | 40 | addUser "${WILDFLY_USER_NAME}" "${WILDFLY_GROUP_NAME}" 'false' 'true' 'false' 41 | chown -R "${WILDFLY_USER_NAME}:${WILDFLY_GROUP_NAME}" "${WILDFLY_INSTALL_FOLDER_PATH}" 42 | startService "${WILDFLY_SERVICE_NAME}" 43 | 44 | # Display Open Ports 45 | 46 | displayOpenPorts '5' 47 | 48 | umask '0077' 49 | } 50 | 51 | function main() 52 | { 53 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 54 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 55 | 56 | header 'INSTALLING WILDFLY' 57 | 58 | checkRequireLinuxSystem 59 | checkRequireRootUser 60 | checkRequirePorts '8080' '9990' 61 | 62 | installDependencies 63 | install 64 | installCleanUp 65 | } 66 | 67 | main "${@}" -------------------------------------------------------------------------------- /cookbooks/wildfly/templates/wildfly.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=WildFly Server 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | Restart=always 27 | RestartSec=10 28 | 29 | TimeoutSec=30 30 | 31 | User=__USER_NAME__ 32 | Group=__GROUP_NAME__ 33 | 34 | ExecStart='__INSTALL_FOLDER_PATH__/bin/standalone.sh' -b=__APPLICATION_BIND_ADDRESS__ -bmanagement=__MANAGEMENT_BIND_ADDRESS__ -------------------------------------------------------------------------------- /cookbooks/zdm-util/attributes/default.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | export ZDM_UTIL_DOWNLOAD_URL='https://github.com/datastax/zdm-proxy-automation/releases/download/v2.3.1/zdm-util-linux-amd64-v2.3.1.tgz' 4 | 5 | export ZDM_UTIL_INSTALL_FOLDER_PATH='/opt/zdm-util' -------------------------------------------------------------------------------- /cookbooks/zdm-util/recipes/install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | source "$(dirname "${BASH_SOURCE[0]}")/../attributes/default.bash" 7 | 8 | header 'INSTALLING ZDM-UTIL' 9 | 10 | checkRequireLinuxSystem 11 | checkRequireRootUser 12 | 13 | umask '0022' 14 | initializeFolder "${ZDM_UTIL_INSTALL_FOLDER_PATH}" 15 | curl -L "${ZDM_UTIL_DOWNLOAD_URL}" --retry 12 --retry-delay 5 | tar -C "${ZDM_UTIL_INSTALL_FOLDER_PATH}" -x -z 16 | mv ${ZDM_UTIL_INSTALL_FOLDER_PATH}/zdm-util-v* "${ZDM_UTIL_INSTALL_FOLDER_PATH}/zdm-util" 17 | rm -f '/usr/bin/zdm-util' 18 | ln -f -s "${ZDM_UTIL_INSTALL_FOLDER_PATH}/zdm-util" '/usr/bin/zdm-util' 19 | umask '0077' 20 | } 21 | 22 | main "${@}" -------------------------------------------------------------------------------- /roles/essential.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | local -r ps1HostName="${1}" 6 | local -r ps1Users="${2}" 7 | 8 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 9 | 10 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/essential/recipes/install.bash" 11 | 12 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/chrony/recipes/install.bash" 13 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/clean-up/recipes/install.bash" 14 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/jq/recipes/install.bash" 15 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/logrotate/recipes/install.bash" 16 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ps1/recipes/install.bash" --host-name "${ps1HostName}" --users "${ps1Users}" 17 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ssh/recipes/install.bash" 18 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/tweaks/recipes/install.bash" 19 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ulimit/recipes/install.bash" 20 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/vim/recipes/install.bash" 21 | 22 | if [[ "$(isUbuntuDistributor)" = 'true' ]] 23 | then 24 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/tmp-reaper/recipes/install.bash" 25 | else 26 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/tmp-watch/recipes/install.bash" 27 | fi 28 | 29 | postUpMessage 30 | } 31 | 32 | main "${@}" -------------------------------------------------------------------------------- /roles/nam/libraries/app.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 4 | 5 | function autoSudo() 6 | { 7 | local -r userLogin="${1}" 8 | local -r profileFileName="${2}" 9 | 10 | header 'SETTING UP AUTO SUDO' 11 | 12 | local -r command='sudo su -l' 13 | 14 | appendToFileIfNotFound \ 15 | "$(getUserHomeFolder "${userLogin}")/${profileFileName}" \ 16 | "${command}" \ 17 | "${command}" \ 18 | 'false' \ 19 | 'false' \ 20 | 'true' 21 | } 22 | 23 | function setupRepository() 24 | { 25 | local -r repositoryPath='/opt' 26 | 27 | header 'SETTING UP REPOSITORY' 28 | 29 | mkdir -p "${repositoryPath}" 30 | 31 | if [[ -d "${repositoryPath}/linux-cookbooks" ]] 32 | then 33 | cd "${repositoryPath}/linux-cookbooks" 34 | git pull 35 | else 36 | cd "${repositoryPath}" 37 | git clone 'https://github.com/gdbtek/linux-cookbooks.git' 38 | fi 39 | } 40 | 41 | function updateRepositoryOnLogin() 42 | { 43 | local -r userLogin="${1}" 44 | 45 | header 'UPDATING REPOSITORY ON LOGIN' 46 | 47 | local -r command='cd /opt/linux-cookbooks/cookbooks && git pull' 48 | 49 | appendToFileIfNotFound \ 50 | "$(getProfileFilePath "${userLogin}")" \ 51 | "${command}" \ 52 | "${command}" \ 53 | 'false' \ 54 | 'false' \ 55 | 'true' 56 | } -------------------------------------------------------------------------------- /roles/nam/roles/virtual-machine-server.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | local -r firstLoginUser='nam' 6 | 7 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 8 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/app.bash" 9 | 10 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/jq/recipes/install.bash" 11 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/ps1/recipes/install.bash" --users "${firstLoginUser}, $(whoami)" 12 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/ssh/recipes/install.bash" 13 | 14 | runUpgrade 15 | setupRepository 16 | updateRepositoryOnLogin "$(whoami)" 17 | 18 | if [[ "$(existUserLogin "${firstLoginUser}")" = 'true' ]] 19 | then 20 | addUserToSudoWithoutPassword "${firstLoginUser}" 21 | autoSudo "${firstLoginUser}" "$(basename "$(getProfileFilePath "${firstLoginUser}")")" 22 | fi 23 | 24 | cleanUpSystemFolders 25 | resetLogs 26 | postUpMessage 27 | } 28 | 29 | main "${@}" -------------------------------------------------------------------------------- /roles/nam/roles/vmware-desktop.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | local -r firstLoginUser='nam' 6 | 7 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 8 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/app.bash" 9 | 10 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/essential/recipes/install.bash" 11 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/jq/recipes/install.bash" 12 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/ps1/recipes/install.bash" 13 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/ps1/recipes/install.bash" --profile-file-name '.bashrc' --users "${firstLoginUser}" 14 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/ssh/recipes/install.bash" 15 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/vim/recipes/install.bash" 16 | 17 | setupRepository 18 | updateRepositoryOnLogin "$(whoami)" 19 | 20 | if [[ "$(existUserLogin "${firstLoginUser}")" = 'true' ]] 21 | then 22 | addUserToSudoWithoutPassword "${firstLoginUser}" 23 | autoSudo "${firstLoginUser}" '.bashrc' 24 | fi 25 | 26 | cleanUpSystemFolders 27 | resetLogs 28 | postUpMessage 29 | } 30 | 31 | main "${@}" -------------------------------------------------------------------------------- /roles/test-cookbooks.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 6 | 7 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/essential/recipes/install.bash" 8 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/akamai-cli/recipes/install.bash" 9 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ant/recipes/install.bash" 10 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/aws-cli/recipes/install.bash" 11 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/chef-infra-client/recipes/install.bash" 12 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/chrony/recipes/install.bash" 13 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/clean-up/recipes/install.bash" 14 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/consul/recipes/install.bash" 15 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/datadog-agent/recipes/install.bash" 16 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/docker/recipes/install.bash" 17 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ec2-ami-tools/recipes/install.bash" 18 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ec2-api-tools/recipes/install.bash" 19 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/elastic-search/recipes/install.bash" 20 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/foodcritic/recipes/install.bash" 21 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/gocd/recipes/install-server-and-agent.bash" 22 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/go/recipes/install.bash" 23 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/groovy/recipes/install.bash" 24 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/haproxy/recipes/install.bash" 25 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/jdk/recipes/install.bash" 26 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/jenkins/recipes/install.bash" 27 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/jq/recipes/install.bash" 28 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/kibana/recipes/install.bash" 29 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/logrotate/recipes/install.bash" 30 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/maven/recipes/install.bash" 31 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/mongodb/recipes/install.bash" 32 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/mount-hd/recipes/install.bash" 33 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/mysql/recipes/install.bash" 34 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/nginx/recipes/install.bash" 35 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/node/recipes/install.bash" 36 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/nomad/recipes/install.bash" 37 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/packer/recipes/install.bash" 38 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/pm2/recipes/install.bash" 39 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ps1/recipes/install.bash" 40 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/python/recipes/install.bash" 41 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/redis/recipes/install.bash" 42 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ruby/recipes/install.bash" 43 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/selenium-server/recipes/install.bash" 44 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/shell-check/recipes/install.bash" 45 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/splunkforwarder/recipes/install.bash" 46 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ssh/recipes/install.bash" 47 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/terraform/recipes/install.bash" 48 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/test-ssl/recipes/install.bash" 49 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/tmp-reaper/recipes/install.bash" 50 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/tmp-watch/recipes/install.bash" 51 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/tomcat/recipes/install.bash" 52 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/tweaks/recipes/install.bash" 53 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ufw/recipes/install.bash" 54 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/ulimit/recipes/install.bash" 55 | "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/vault/recipes/install.bash" 56 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/vbox-guest-additions/recipes/install.bash" 57 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/vim/recipes/install.bash" 58 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/vmware-tools/recipes/install.bash" 59 | # "$(dirname "${BASH_SOURCE[0]}")/../cookbooks/wildfly/recipes/install.bash" 60 | 61 | postUpMessage 62 | } 63 | 64 | main "${@}" -------------------------------------------------------------------------------- /roles/work/jenkins/jenkins.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function configureJenkinsCI() 4 | { 5 | umask '0022' 6 | 7 | createInitFileFromTemplate 'jenkins-ci' "$(dirname "${BASH_SOURCE[0]}")/templates" 8 | startService 'jenkins-ci' 9 | 10 | umask '0077' 11 | } 12 | 13 | function main() 14 | { 15 | local -r ps1HostName="${1}" 16 | local -r ps1Users="${2}" 17 | 18 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 19 | 20 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/clean-up/recipes/install.bash" 21 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/jq/recipes/install.bash" 22 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/logrotate/recipes/install.bash" 23 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/ps1/recipes/install.bash" --host-name "${ps1HostName}" --users "${ps1Users}" 24 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/vim/recipes/install.bash" 25 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/chrony/recipes/install.bash" 26 | 27 | configureJenkinsCI 28 | 29 | postUpMessage 30 | } 31 | 32 | main "${@}" -------------------------------------------------------------------------------- /roles/work/jenkins/templates/jenkins-ci.service.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=jenkins-ci 3 | After=sshd.service 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=oneshot 10 | 11 | LimitAS=infinity 12 | LimitCORE=infinity 13 | LimitCPU=infinity 14 | LimitDATA=infinity 15 | LimitFSIZE=infinity 16 | LimitLOCKS=infinity 17 | LimitMEMLOCK=64000 18 | LimitMSGQUEUE=819200 19 | LimitNOFILE=64000 20 | LimitNPROC=16000 21 | LimitRSS=infinity 22 | LimitRTPRIO=0 23 | LimitSIGPENDING=16000 24 | LimitSTACK=8192000 25 | 26 | User=root 27 | Group=root 28 | 29 | ExecStart=/bin/bash -c -e '\ 30 | mount -o \'remount,rw,exec,nosuid,size=10G\' -v \'/tmp\' ; \ 31 | iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443 ; \ 32 | ' -------------------------------------------------------------------------------- /roles/work/zdm/jumphost.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | 7 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/cqlsh/recipes/install.bash" 8 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/docker/recipes/install.bash" 9 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/zdm-util/recipes/install.bash" 10 | 11 | docker image pull 'datastax/zdm-ansible:2.x' 12 | 13 | postUpMessage 14 | } 15 | 16 | main "${@}" -------------------------------------------------------------------------------- /roles/work/zdm/zdm-proxy.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../../../libraries/util.bash" 6 | 7 | apt-get update -m 8 | installPackages 'aptitude' 'curl' 'software-properties-common' 'python3-pip' 'virtualenv' 'python3-setuptools' 9 | 10 | "$(dirname "${BASH_SOURCE[0]}")/../../../cookbooks/docker/recipes/install.bash" 11 | 12 | docker image pull 'datastax/zdm-proxy:2.x' 13 | 14 | postUpMessage 15 | } 16 | 17 | main "${@}" -------------------------------------------------------------------------------- /tools/check-system-clock.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 6 | 7 | checkRequireLinuxSystem 8 | checkExistCommand 'chronyc' 9 | 10 | info '\nchronyc activity' 11 | chronyc activity 12 | 13 | info '\nchronyc sources -v' 14 | chronyc sources -v 15 | 16 | info '\nchronyc sourcestats -v' 17 | chronyc sourcestats -v 18 | 19 | info '\nchronyc tracking' 20 | chronyc tracking 21 | } 22 | 23 | main "${@}" -------------------------------------------------------------------------------- /tools/clean-up-jenkins-jobs.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############# 4 | # CONSTANTS # 5 | ############# 6 | 7 | DEFAULT_COMMAND_MODE='status' 8 | DEFAULT_NUMBER_BUILDS_TO_KEEP='25' 9 | 10 | ################## 11 | # IMPLEMENTATION # 12 | ################## 13 | 14 | function displayUsage() 15 | { 16 | local -r scriptName="$(basename "${BASH_SOURCE[0]}")" 17 | 18 | echo -e '\033[1;33m' 19 | echo 'SYNOPSIS :' 20 | echo " ${scriptName}" 21 | echo ' --help' 22 | echo ' --jobs-folder-path ' 23 | echo ' --number-builds-to-keep ' 24 | echo ' --command-mode ' 25 | echo -e '\033[1;35m' 26 | echo 'DESCRIPTION :' 27 | echo ' --help Help page (optional)' 28 | echo ' --jobs-folder-path Path to Jenkins jobs folder path (require)' 29 | echo ' Examples: /opt/jenkins/jobs, /apps/jenkins/latest/jobs' 30 | echo ' --number-builds-to-keep Max # of builds to keep with artifacts (optional)' 31 | echo " Default to ${DEFAULT_NUMBER_BUILDS_TO_KEEP}" 32 | echo " --command-mode Valid command mode : 'clean-up', or '${DEFAULT_COMMAND_MODE}' (optional)" 33 | echo " Default value is '${DEFAULT_COMMAND_MODE}'" 34 | echo -e '\033[1;36m' 35 | echo 'EXAMPLES :' 36 | echo " ./${scriptName} --help" 37 | echo " ./${scriptName} --jobs-folder-path '/opt/jenkins/jobs'" 38 | echo " ./${scriptName} --jobs-folder-path '/apps/jenkins/latest/jobs' --number-builds-to-keep '50'" 39 | echo " ./${scriptName} --jobs-folder-path '/apps/jenkins/latest/jobs' --number-builds-to-keep '50' --command-mode 'clean-up'" 40 | echo -e '\033[0m' 41 | 42 | exit "${1}" 43 | } 44 | 45 | function cleanUpDotBuilds() 46 | { 47 | local -r buildsFolderPath="${1}" 48 | local -r commandMode="${2}" 49 | 50 | # Dot Builds (builds/.12345) 51 | 52 | if [[ "${commandMode}" = 'clean-up' ]] 53 | then 54 | find "${buildsFolderPath}" \ 55 | -mindepth 1 \ 56 | -maxdepth 1 \ 57 | \( \ 58 | -type d -o \ 59 | -type l \ 60 | \) \ 61 | -regex "^${buildsFolderPath}/\.[1-9][0-9]*$" \ 62 | -delete 63 | fi 64 | } 65 | 66 | function cleanUpBrokenSymlinkNormalBuilds() 67 | { 68 | local -r buildsFolderPath="${1}" 69 | local -r commandMode="${2}" 70 | 71 | # Broken Symlink Normal Builds (builds/12345 -> non-existent) 72 | 73 | if [[ "${commandMode}" = 'clean-up' ]] 74 | then 75 | find "${buildsFolderPath}" \ 76 | -mindepth 1 \ 77 | -maxdepth 1 \ 78 | -type l \ 79 | -regex "^${buildsFolderPath}/[1-9][0-9]*$" \ 80 | ! -exec test -e '{}' \; \ 81 | -print0 | 82 | xargs -0 rm -f 83 | fi 84 | } 85 | 86 | function cleanUpNormalBuilds() 87 | { 88 | local -r buildsFolderPath="${1}" 89 | local -r commandMode="${2}" 90 | local -r numberBuildsToKeep="${3}" 91 | 92 | # Normal Builds (builds/12345) 93 | 94 | local builds='' 95 | builds="$( 96 | find "${buildsFolderPath}" \ 97 | -mindepth 1 \ 98 | -maxdepth 1 \ 99 | -type d \ 100 | -regex "^${buildsFolderPath}/[1-9][0-9]*$" \ 101 | -exec basename '{}' \; | 102 | sort -n -r 103 | )" 104 | 105 | local toDeleteBuilds='' 106 | toDeleteBuilds="$(tail -n "+$((numberBuildsToKeep + 1))" <<< "${builds}")" 107 | 108 | local toKeepBuilds='' 109 | toKeepBuilds="$(head "-${numberBuildsToKeep}" <<< "${builds}")" 110 | 111 | if [[ "$(isEmptyString "${toDeleteBuilds}")" = 'false' ]] 112 | then 113 | NEED_TO_CLEAN_UP_BUILDS='true' 114 | 115 | info "\n${buildsFolderPath}" 116 | 117 | # Print To Keep If Available 118 | 119 | if [[ "$(isEmptyString "${toKeepBuilds}")" = 'false' ]] 120 | then 121 | echo -e " \033[1;32mto keep builds :\033[0m" 122 | 123 | local toKeepBuild='' 124 | 125 | for toKeepBuild in ${toKeepBuilds} 126 | do 127 | checkPositiveInteger "${toKeepBuild}" 128 | 129 | echo " '${buildsFolderPath}/${toKeepBuild}'" 130 | done 131 | fi 132 | 133 | # Print To Delete As Always 134 | 135 | if [[ "${commandMode}" = 'clean-up' ]] 136 | then 137 | echo -e " \033[1;35mdeleting builds :\033[0m" 138 | else 139 | echo -e " \033[1;35mto delete builds :\033[0m" 140 | fi 141 | 142 | # Delete 143 | 144 | local toDeleteBuild='' 145 | 146 | for toDeleteBuild in ${toDeleteBuilds} 147 | do 148 | checkPositiveInteger "${toDeleteBuild}" 149 | 150 | echo " '${buildsFolderPath}/${toDeleteBuild}'" 151 | 152 | if [[ "${commandMode}" = 'clean-up' ]] 153 | then 154 | rm -f -r "${buildsFolderPath}/${toDeleteBuild}" 155 | fi 156 | done 157 | fi 158 | } 159 | 160 | function cleanJenkinsJobs() 161 | { 162 | local -r jobsFolderPath="${1}" 163 | local -r numberBuildsToKeep="${2}" 164 | local -r commandMode="${3}" 165 | 166 | local -r oldIFS="${IFS}" 167 | IFS=$'\n' 168 | 169 | NEED_TO_CLEAN_UP_BUILDS='false' 170 | 171 | local buildsFolderPath='' 172 | 173 | for buildsFolderPath in $(find "${jobsFolderPath}" -mindepth 1 -maxdepth 4 -type d -name 'builds') 174 | do 175 | cleanUpDotBuilds "${buildsFolderPath}" "${commandMode}" 176 | cleanUpNormalBuilds "${buildsFolderPath}" "${commandMode}" "${numberBuildsToKeep}" 177 | cleanUpBrokenSymlinkNormalBuilds "${buildsFolderPath}" "${commandMode}" 178 | done 179 | 180 | IFS="${oldIFS}" 181 | 182 | if [[ "${NEED_TO_CLEAN_UP_BUILDS}" = 'false' ]] 183 | then 184 | echo -e "\n\033[1;32mno build to clean up!\033[0m" 185 | fi 186 | } 187 | 188 | ######## 189 | # MAIN # 190 | ######## 191 | 192 | function main() 193 | { 194 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 195 | 196 | # Parsing Command Arguments 197 | 198 | local -r optCount="${#}" 199 | 200 | while [[ "${#}" -gt '0' ]] 201 | do 202 | case "${1}" in 203 | --help) 204 | displayUsage 0 205 | ;; 206 | 207 | --jobs-folder-path) 208 | shift 209 | 210 | if [[ "${#}" -gt '0' ]] 211 | then 212 | local jobsFolderPath="${1}" 213 | fi 214 | 215 | ;; 216 | 217 | --number-builds-to-keep) 218 | shift 219 | 220 | if [[ "${#}" -gt '0' ]] 221 | then 222 | local numberBuildsToKeep="${1}" 223 | fi 224 | 225 | ;; 226 | 227 | --command-mode) 228 | shift 229 | 230 | if [[ "${#}" -gt '0' ]] 231 | then 232 | local commandMode='' 233 | commandMode="$(trimString "${1}")" 234 | fi 235 | 236 | ;; 237 | 238 | *) 239 | shift 240 | ;; 241 | esac 242 | done 243 | 244 | # Validate Opt 245 | 246 | if [[ "${optCount}" -lt '1' ]] 247 | then 248 | displayUsage 0 249 | fi 250 | 251 | # Default Values 252 | 253 | if [[ "$(isEmptyString "${numberBuildsToKeep}")" = 'true' ]] 254 | then 255 | numberBuildsToKeep="${DEFAULT_NUMBER_BUILDS_TO_KEEP}" 256 | fi 257 | 258 | if [[ "$(isEmptyString "${commandMode}")" = 'true' ]] 259 | then 260 | commandMode="${DEFAULT_COMMAND_MODE}" 261 | fi 262 | 263 | # Validation 264 | 265 | checkExistFolder "${jobsFolderPath}" 266 | checkNaturalNumber "${numberBuildsToKeep}" 'number builds to keep is not natural number' 267 | 268 | if [[ ! -f "${jobsFolderPath}/../config.xml" || ! -d "${jobsFolderPath}/../plugins" ]] 269 | then 270 | fatal "\n'${jobsFolderPath}' is not jenkins jobs folder" 271 | fi 272 | 273 | if [[ "${commandMode}" != 'clean-up' && "${commandMode}" != 'status' ]] 274 | then 275 | error '\nERROR : command mode must be clean-up, or status' 276 | displayUsage 1 277 | fi 278 | 279 | # Start Cleaning 280 | 281 | cleanJenkinsJobs "${jobsFolderPath}" "${numberBuildsToKeep}" "${commandMode}" 282 | postUpMessage 283 | } 284 | 285 | main "${@}" -------------------------------------------------------------------------------- /tools/clean-up.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 6 | 7 | checkRequireLinuxSystem 8 | checkRequireRootUser 9 | 10 | installCleanUp 11 | } 12 | 13 | main "${@}" -------------------------------------------------------------------------------- /tools/clone-all-git-repositories.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ################## 4 | # IMPLEMENTATION # 5 | ################## 6 | 7 | function displayUsage() 8 | { 9 | local -r scriptName="$(basename "${BASH_SOURCE[0]}")" 10 | 11 | echo -e '\033[1;33m' 12 | echo 'SYNOPSIS :' 13 | echo " ${scriptName}" 14 | echo ' --help' 15 | echo ' --user ' 16 | echo ' --token ' 17 | echo ' --clone-depth ' 18 | echo ' --clone-folder ' 19 | echo ' --git-url ' 20 | echo ' --org-name ' 21 | echo ' --delete-if-exist ' 22 | echo -e '\033[1;35m' 23 | echo 'DESCRIPTION :' 24 | echo ' --help Help page (optional)' 25 | echo ' --user User name (require)' 26 | echo ' --token Personal access token (require)' 27 | echo ' --clone-depth How deep your clone should go (optional)' 28 | echo ' --clone-folder Folder path to clone all repositories to (optional)' 29 | echo ' Default to current working directory path' 30 | echo ' --git-url Git URL (optional)' 31 | echo " Default to 'https://api.github.com'" 32 | echo ' --org-name Organization name (optional)' 33 | echo ' --delete-if-exist Delete git repository if exist' 34 | echo " Default to 'false'" 35 | echo -e '\033[1;36m' 36 | echo 'EXAMPLES :' 37 | echo " ./${scriptName} --help" 38 | echo " ./${scriptName} --user 'user-name' --token 'a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9'" 39 | echo " ./${scriptName} --user 'user-name' --token 'a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9' --clone-folder '/path/to/folder'" 40 | echo " ./${scriptName} --user 'user-name' --token 'a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9' --clone-folder '/path/to/folder' --clone-depth '1' --org-name 'my-org' --delete-if-exist 'true'" 41 | echo " ./${scriptName} --user 'user-name' --token 'a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9' --clone-folder '/path/to/folder' --org-name 'my-org' --git-url 'https://my.git.com/api/v3'" 42 | 43 | echo -e '\033[0m' 44 | 45 | exit "${1}" 46 | } 47 | 48 | function cloneAllRepositories() 49 | { 50 | local -r user="${1}" 51 | local -r token="${2}" 52 | local -r cloneDepth="${3}" 53 | local -r cloneFolder="${4}" 54 | local -r gitURL="${5}" 55 | local -r orgName="${6}" 56 | local -r kind="${7}" 57 | local -r deleteIfExist="${8}" 58 | 59 | # Validation 60 | 61 | checkNonEmptyString "${user}" 'undefined user' 62 | checkNonEmptyString "${token}" 'undefined token' 63 | checkExistFolder "${cloneFolder}" 64 | 65 | # Get User Details 66 | 67 | local -r gitUserPrimaryEmail="$(getGitUserPrimaryEmail "${user}" "${token}" "${gitURL}")" 68 | local -r gitUserName="$(getGitUserName "${user}" "${token}" "${gitURL}")" 69 | 70 | checkNonEmptyString "${gitUserPrimaryEmail}" 'undefined git user primary email' 71 | checkNonEmptyString "${gitUserName}" 'undefined git user name' 72 | 73 | # Create Root Folder 74 | 75 | if [[ "$(isEmptyString "${orgName}")" = 'true' ]] 76 | then 77 | local -r rootRepository="${cloneFolder}/$(tr '[:upper:]' '[:lower:]' <<< "${user}")/${kind}" 78 | else 79 | local -r rootRepository="${cloneFolder}/$(tr '[:upper:]' '[:lower:]' <<< "${orgName}")/${kind}" 80 | fi 81 | 82 | mkdir -p "${rootRepository}" 83 | 84 | # Each Repository 85 | 86 | if [[ "${kind}" = 'public' ]] 87 | then 88 | local -r repositorySSHURLs=($(getGitPublicRepositorySSHURL "${user}" "${token}" "${orgName}" "${gitURL}")) 89 | elif [[ "${kind}" = 'private' ]] 90 | then 91 | local -r repositorySSHURLs=($(getGitPrivateRepositorySSHURL "${user}" "${token}" "${orgName}" "${gitURL}")) 92 | else 93 | local -r repositorySSHURLs=() 94 | fi 95 | 96 | local repositorySSHURL='' 97 | 98 | for repositorySSHURL in "${repositorySSHURLs[@]}" 99 | do 100 | header "CLONING '${repositorySSHURL}' IN '${rootRepository}'" 101 | 102 | local gitRepositoryName='' 103 | gitRepositoryName="$(getGitRepositoryNameFromCloneURL "${repositorySSHURL}")" 104 | 105 | # Clone Repository 106 | 107 | cd "${rootRepository}" 108 | 109 | if [[ "${deleteIfExist}" = 'true' ]] 110 | then 111 | rm -f -r "${gitRepositoryName}" 112 | fi 113 | 114 | if [[ "$(isEmptyString "${cloneDepth}")" = 'true' ]] 115 | then 116 | git clone "${repositorySSHURL}" 117 | else 118 | checkPositiveInteger "${cloneDepth}" 119 | git clone --depth "${cloneDepth}" "${repositorySSHURL}" 120 | fi 121 | 122 | # Config Git 123 | 124 | cd "${gitRepositoryName}" 125 | 126 | if [[ "$(isEmptyString "${gitUserPrimaryEmail}")" = 'false' ]] 127 | then 128 | git config user.email "${gitUserPrimaryEmail}" 129 | fi 130 | 131 | if [[ "$(isEmptyString "${gitUserName}")" = 'false' ]] 132 | then 133 | git config user.name "${gitUserName}" 134 | fi 135 | 136 | info "\n$(git config --list)" 137 | done 138 | } 139 | 140 | ######## 141 | # MAIN # 142 | ######## 143 | 144 | function main() 145 | { 146 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/git.bash" 147 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 148 | 149 | # Parsing Command Arguments 150 | 151 | local -r optCount="${#}" 152 | 153 | while [[ "${#}" -gt '0' ]] 154 | do 155 | case "${1}" in 156 | --help) 157 | displayUsage 0 158 | ;; 159 | 160 | --user) 161 | shift 162 | 163 | if [[ "${#}" -gt '0' ]] 164 | then 165 | local user="${1}" 166 | fi 167 | 168 | ;; 169 | 170 | --token) 171 | shift 172 | 173 | if [[ "${#}" -gt '0' ]] 174 | then 175 | local token="${1}" 176 | fi 177 | 178 | ;; 179 | 180 | --clone-depth) 181 | shift 182 | 183 | if [[ "${#}" -gt '0' ]] 184 | then 185 | local cloneDepth="${1}" 186 | fi 187 | 188 | ;; 189 | 190 | --clone-folder) 191 | shift 192 | 193 | if [[ "${#}" -gt '0' ]] 194 | then 195 | local cloneFolder="${1}" 196 | fi 197 | 198 | ;; 199 | 200 | --git-url) 201 | shift 202 | 203 | if [[ "${#}" -gt '0' ]] 204 | then 205 | local gitURL="${1}" 206 | fi 207 | 208 | ;; 209 | 210 | --org-name) 211 | shift 212 | 213 | if [[ "${#}" -gt '0' ]] 214 | then 215 | local orgName="${1}" 216 | fi 217 | 218 | ;; 219 | 220 | --delete-if-exist) 221 | shift 222 | 223 | if [[ "${#}" -gt '0' ]] 224 | then 225 | local deleteIfExist="${1}" 226 | fi 227 | 228 | ;; 229 | 230 | *) 231 | shift 232 | ;; 233 | esac 234 | done 235 | 236 | # Validate Opt 237 | 238 | if [[ "${optCount}" -lt '1' ]] 239 | then 240 | displayUsage 0 241 | fi 242 | 243 | # Default Values 244 | 245 | if [[ "$(isEmptyString "${cloneFolder}")" = 'true' ]] 246 | then 247 | cloneFolder="$(pwd)" 248 | fi 249 | 250 | if [[ "$(isEmptyString "${deleteIfExist}")" = 'true' ]] 251 | then 252 | deleteIfExist='false' 253 | fi 254 | 255 | # Clone Repositories 256 | 257 | cloneAllRepositories "${user}" "${token}" "${cloneDepth}" "${cloneFolder}" "${gitURL}" "${orgName}" 'private' "${deleteIfExist}" 258 | cloneAllRepositories "${user}" "${token}" "${cloneDepth}" "${cloneFolder}" "${gitURL}" "${orgName}" 'public' "${deleteIfExist}" 259 | } 260 | 261 | main "${@}" -------------------------------------------------------------------------------- /tools/delete-old-logs.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 6 | 7 | checkRequireLinuxSystem 8 | checkRequireRootUser 9 | 10 | deleteOldLogs "${@}" 11 | } 12 | 13 | main "${@}" -------------------------------------------------------------------------------- /tools/flush-firewall.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 6 | 7 | checkRequireLinuxSystem 8 | checkRequireRootUser 9 | 10 | flushFirewall 11 | } 12 | 13 | main "${@}" -------------------------------------------------------------------------------- /tools/import-certificates.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############# 4 | # CONSTANTS # 5 | ############# 6 | 7 | DEFAULT_CA_TRUST_ANCHORS='/etc/pki/ca-trust/source/anchors' 8 | DEFAULT_JAVA_HOME='/opt/jdk' 9 | 10 | ################## 11 | # IMPLEMENTATION # 12 | ################## 13 | 14 | function displayUsage() 15 | { 16 | local -r scriptName="$(basename "${BASH_SOURCE[0]}")" 17 | 18 | echo -e '\033[1;33m' 19 | echo 'SYNOPSIS :' 20 | echo " ${scriptName}" 21 | echo ' --help' 22 | echo ' --import-certificate ' 23 | echo ' --ca-trust-anchors ' 24 | echo ' --java-home ' 25 | echo ' --store-password ' 26 | echo -e '\033[1;35m' 27 | echo 'DESCRIPTION :' 28 | echo ' --help Help page (optional)' 29 | echo ' --import-certificate Path to source certificate folder path (require)' 30 | echo ' --store-password Store password (require)' 31 | echo ' --ca-trust-anchors Path to destination CA-Trust Anchors folder path (optional)' 32 | echo " Default to '${DEFAULT_CA_TRUST_ANCHORS}'" 33 | echo ' --java-home Path to destination Java Home folder path (optional)' 34 | echo " Default to '${DEFAULT_JAVA_HOME}'" 35 | echo -e '\033[1;36m' 36 | echo 'EXAMPLES :' 37 | echo " ./${scriptName} --help" 38 | echo " ./${scriptName} --import-certificate '/downloads/ssl' --store-password 'abc123'" 39 | echo " ./${scriptName} --import-certificate '/downloads/ssl' --store-password 'abc123' --java-home '/opt/jre'" 40 | echo " ./${scriptName} --import-certificate '/downloads/ssl' --store-password 'abc123' --ca-trust-anchors '/path/anchors' --java-home '/opt/jre'" 41 | echo -e '\033[0m' 42 | 43 | exit "${1}" 44 | } 45 | 46 | function importCertificates() 47 | { 48 | local -r importCertificate="${1}" 49 | local -r caTrustAnchors="${2}" 50 | local -r javaHome="${3}" 51 | local -r storePassword="${4}" 52 | 53 | local -r oldIFS="${IFS}" 54 | IFS=$'\n' 55 | 56 | local certificateFilePath='' 57 | 58 | for certificateFilePath in $(find -L "${importCertificate}" -type f -name '*.crt' | sort -f) 59 | do 60 | local certificateName="$(getFileName "${certificateFilePath}")" 61 | 62 | keytool \ 63 | -delete \ 64 | -noprompt \ 65 | -trustcacerts \ 66 | -alias "${certificateName}" \ 67 | -keystore "${javaHome}/lib/security/cacerts" \ 68 | -storepass "${storePassword}" || true 69 | 70 | keytool \ 71 | -import \ 72 | -noprompt \ 73 | -trustcacerts \ 74 | -alias "${certificateName}" \ 75 | -file "${certificateFilePath}" \ 76 | -keystore "${javaHome}/lib/security/cacerts" \ 77 | -storepass "${storePassword}" 78 | 79 | cp -f "${certificateFilePath}" "${caTrustAnchors}" 80 | done 81 | 82 | IFS="${oldIFS}" 83 | 84 | update-ca-trust enable 85 | update-ca-trust extract 86 | } 87 | 88 | ######## 89 | # MAIN # 90 | ######## 91 | 92 | function main() 93 | { 94 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 95 | 96 | # Parsing Command Arguments 97 | 98 | local -r optCount="${#}" 99 | 100 | while [[ "${#}" -gt '0' ]] 101 | do 102 | case "${1}" in 103 | --help) 104 | displayUsage 0 105 | ;; 106 | 107 | --import-certificate) 108 | shift 109 | 110 | if [[ "${#}" -gt '0' ]] 111 | then 112 | local importCertificate='' 113 | importCertificate="$(formatPath ${1})" 114 | fi 115 | 116 | ;; 117 | 118 | --ca-trust-anchors) 119 | shift 120 | 121 | if [[ "${#}" -gt '0' ]] 122 | then 123 | local caTrustAnchors='' 124 | caTrustAnchors="$(formatPath ${1})" 125 | fi 126 | 127 | ;; 128 | 129 | --java-home) 130 | shift 131 | 132 | if [[ "${#}" -gt '0' ]] 133 | then 134 | local javaHome='' 135 | javaHome="$(formatPath ${1})" 136 | fi 137 | 138 | ;; 139 | 140 | --store-password) 141 | shift 142 | 143 | if [[ "${#}" -gt '0' ]] 144 | then 145 | local storePassword="${1}" 146 | fi 147 | 148 | ;; 149 | 150 | *) 151 | shift 152 | ;; 153 | esac 154 | done 155 | 156 | # Validate Opt 157 | 158 | if [[ "${optCount}" -lt '1' ]] 159 | then 160 | displayUsage 0 161 | fi 162 | 163 | # Default Values 164 | 165 | if [[ "$(isEmptyString "${caTrustAnchors}")" = 'true' ]] 166 | then 167 | caTrustAnchors="${DEFAULT_CA_TRUST_ANCHORS}" 168 | fi 169 | 170 | if [[ "$(isEmptyString "${javaHome}")" = 'true' ]] 171 | then 172 | javaHome="${DEFAULT_JAVA_HOME}" 173 | fi 174 | 175 | # Validation 176 | 177 | checkExistFolder "${importCertificate}" 178 | checkExistFolder "${caTrustAnchors}" 179 | checkExistFolder "${javaHome}" 180 | 181 | checkNonEmptyString "${storePassword}" 'undefined store password' 182 | 183 | # Start Importing 184 | 185 | importCertificates "${importCertificate}" "${caTrustAnchors}" "${javaHome}" "${storePassword}" 186 | } 187 | 188 | main "${@}" -------------------------------------------------------------------------------- /tools/install-build-essential.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 6 | 7 | checkRequireLinuxSystem 8 | checkRequireRootUser 9 | 10 | installBuildEssential 11 | } 12 | 13 | main "${@}" -------------------------------------------------------------------------------- /tools/reset-logs.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 6 | 7 | checkRequireLinuxSystem 8 | checkRequireRootUser 9 | 10 | resetLogs "${@}" 11 | } 12 | 13 | main "${@}" -------------------------------------------------------------------------------- /tools/run-remote-command.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ############# 4 | # CONSTANTS # 5 | ############# 6 | 7 | SSH_CONNECTION_ATTEMPTS='3' 8 | SSH_CONNECTION_TIMEOUT_IN_SECONDS='5' 9 | 10 | ################## 11 | # IMPLEMENTATION # 12 | ################## 13 | 14 | function displayUsage() 15 | { 16 | local -r scriptName="$(basename "${BASH_SOURCE[0]}")" 17 | 18 | echo -e '\033[1;33m' 19 | echo 'SYNOPSIS :' 20 | echo " ${scriptName}" 21 | echo ' --help' 22 | echo ' --identity-file ' 23 | echo ' --login-name ' 24 | echo ' --address
' 25 | echo ' --command ' 26 | echo -e '\033[1;35m' 27 | echo 'DESCRIPTION :' 28 | echo ' --help Help page (optional)' 29 | echo ' --identity-file Path to identity file (optional)' 30 | echo ' --login-name Login name (optional)' 31 | echo ' --address List of server addresses seperated by spaces or commas (require)' 32 | echo ' --command Command that will be run in remote servers (require)' 33 | echo -e '\033[1;36m' 34 | echo 'EXAMPLES :' 35 | echo " ./${scriptName} --help" 36 | echo " ./${scriptName} --address '1.2.3.4, 5.6.7.8' --command 'date'" 37 | echo " ./${scriptName} --identity-file '/path/key.pem' --login-name 'ec2-user' --address '1.2.3.4, 5.6.7.8' --command 'ntpstat'" 38 | echo " ./${scriptName} --identity-file '/path/key.pem' --login-name 'ec2-user' --address '1.2.3.4, 5.6.7.8' --command 'chronyc tracking'" 39 | echo -e '\033[0m' 40 | 41 | exit "${1}" 42 | } 43 | 44 | function runCommand() 45 | { 46 | local -r identityFile="${1}" 47 | local -r loginName="${2}" 48 | local -r command="${3}" 49 | local -r addresses=($(sortUniqArray "${@:4}")) 50 | 51 | # Built Prompt 52 | 53 | local -r prompt='echo -e "\033[1;36m<\033[31m$(whoami)\033[34m@\033[33m$(hostname)\033[36m><\033[35m$(pwd)\033[36m>\033[0m"' 54 | 55 | # Get Identity File Option 56 | 57 | local identityOption=() 58 | 59 | if [[ "$(isEmptyString "${identityFile}")" = 'false' && -f "${identityFile}" ]] 60 | then 61 | identityOption=('-i' "${identityFile}") 62 | fi 63 | 64 | # Address Walker 65 | 66 | local address='' 67 | 68 | for address in "${addresses[@]}" 69 | do 70 | if [[ "$(isEmptyString "${address}")" = 'false' ]] 71 | then 72 | header "${address}" 73 | 74 | if [[ "$(isEmptyString "${loginName}")" = 'true' ]] 75 | then 76 | ssh "${identityOption[@]}" \ 77 | -o 'IdentitiesOnly yes' \ 78 | -o "ConnectionAttempts ${SSH_CONNECTION_ATTEMPTS}" \ 79 | -o "ConnectTimeout ${SSH_CONNECTION_TIMEOUT_IN_SECONDS}" \ 80 | -n "${address}" "${prompt} && ${command}" || true 81 | else 82 | ssh "${identityOption[@]}" \ 83 | -o 'IdentitiesOnly yes' \ 84 | -o "ConnectionAttempts ${SSH_CONNECTION_ATTEMPTS}" \ 85 | -o "ConnectTimeout ${SSH_CONNECTION_TIMEOUT_IN_SECONDS}" \ 86 | -n "${loginName}@${address}" "${prompt} && ${command}" || true 87 | fi 88 | fi 89 | done 90 | } 91 | 92 | ######## 93 | # MAIN # 94 | ######## 95 | 96 | function main() 97 | { 98 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 99 | 100 | # Parsing Command Arguments 101 | 102 | local -r optCount="${#}" 103 | 104 | while [[ "${#}" -gt '0' ]] 105 | do 106 | case "${1}" in 107 | --help) 108 | displayUsage 0 109 | ;; 110 | 111 | --identity-file) 112 | shift 113 | 114 | if [[ "${#}" -gt '0' ]] 115 | then 116 | local identityFile='' 117 | identityFile="$(formatPath ${1})" 118 | fi 119 | 120 | ;; 121 | 122 | --login-name) 123 | shift 124 | 125 | if [[ "${#}" -gt '0' ]] 126 | then 127 | local loginName="${1}" 128 | fi 129 | 130 | ;; 131 | 132 | --address) 133 | shift 134 | 135 | if [[ "${#}" -gt '0' ]] 136 | then 137 | local address='' 138 | address="$(replaceString "${1}" ',' ' ')" 139 | fi 140 | 141 | ;; 142 | 143 | --command) 144 | shift 145 | 146 | if [[ "${#}" -gt '0' ]] 147 | then 148 | local command='' 149 | command="$(trimString "${1}")" 150 | fi 151 | 152 | ;; 153 | 154 | *) 155 | shift 156 | ;; 157 | esac 158 | done 159 | 160 | # Validate Opt 161 | 162 | if [[ "${optCount}" -lt '1' ]] 163 | then 164 | displayUsage 0 165 | fi 166 | 167 | # Validate Arguments 168 | 169 | checkNonEmptyString "${address}" 'undefined address' 170 | checkNonEmptyString "${command}" 'undefined command' 171 | 172 | # Start Run Remote Command 173 | 174 | runCommand "${identityFile}" "${loginName}" "${command}" "${address}" 175 | } 176 | 177 | main "${@}" -------------------------------------------------------------------------------- /tools/start-http-server.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ################## 4 | # IMPLEMENTATION # 5 | ################## 6 | 7 | function displayUsage() 8 | { 9 | local -r scriptName="$(basename "${BASH_SOURCE[0]}")" 10 | 11 | echo -e '\033[1;33m' 12 | echo 'SYNOPSIS :' 13 | echo " ${scriptName}" 14 | echo ' --help' 15 | echo ' --port ' 16 | echo -e '\033[1;35m' 17 | echo 'DESCRIPTION :' 18 | echo ' --help Help page (optional)' 19 | echo ' --port Port number of server (require)' 20 | echo -e '\033[1;36m' 21 | echo 'EXAMPLES :' 22 | echo " ./${scriptName} --help" 23 | echo " ./${scriptName} --port '8080'" 24 | echo -e '\033[0m' 25 | 26 | exit "${1}" 27 | } 28 | 29 | function startHTTPServer() 30 | { 31 | local -r port="${1}" 32 | 33 | python -m 'SimpleHTTPServer' "${port}" 34 | } 35 | 36 | ######## 37 | # MAIN # 38 | ######## 39 | 40 | function main() 41 | { 42 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 43 | 44 | # Parsing Command Arguments 45 | 46 | local -r optCount="${#}" 47 | 48 | while [[ "${#}" -gt '0' ]] 49 | do 50 | case "${1}" in 51 | --help) 52 | displayUsage 0 53 | ;; 54 | 55 | --port) 56 | shift 57 | 58 | if [[ "${#}" -gt '0' ]] 59 | then 60 | local port="${1}" 61 | fi 62 | 63 | ;; 64 | 65 | *) 66 | shift 67 | ;; 68 | esac 69 | done 70 | 71 | # Validate Opt 72 | 73 | if [[ "${optCount}" -lt '1' ]] 74 | then 75 | displayUsage 0 76 | fi 77 | 78 | # Validate Port 79 | 80 | checkNaturalNumber "${port}" 81 | 82 | # Start Cleaning 83 | 84 | startHTTPServer "${port}" 85 | } 86 | 87 | main "${@}" -------------------------------------------------------------------------------- /tools/upgrade.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | function main() 4 | { 5 | source "$(dirname "${BASH_SOURCE[0]}")/../libraries/util.bash" 6 | 7 | checkRequireLinuxSystem 8 | checkRequireRootUser 9 | 10 | runUpgrade 11 | 12 | "$(dirname "${BASH_SOURCE[0]}")/clean-up.bash" 13 | } 14 | 15 | main "${@}" --------------------------------------------------------------------------------