diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4218d07 --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +.PHONY: docker docker-compose rvm rbenv nvm postgresql-12 postgresql-14 mysql-5.7 mysql-8.0 +.DEFAULT_GOAL := no-choice + +docker: + @echo 'Installing Docker' + sudo bash ./scripts/docker.sh + +docker-compose: + @echo 'Installing Docker-compose' + sudo bash ./scripts/docker-compose.sh + +rvm: + @echo 'Installing RVM' + bash ./scripts/rvm.sh + +rbenv: + @echo 'Installing RBENV' + bash ./scripts/rbenv.sh + +nvm: + @echo 'Installing NVM' + bash ./scripts/nvm.sh + +postgresql-12: + @echo 'Installing Postgresql 12' + sudo bash ./scripts/postgresql-12.sh + +postgresql-14: + @echo 'Installing Postgresql 14' + sudo bash ./scripts/postgresql-14.sh + +mysql-5.7: + @echo 'Installing Mysql 5.7' + sudo bash ./scripts/mysql-5.7.sh + +mysql-8.0: + @echo 'Installing Mysql 8.0' + sudo bash ./scripts/mysql-8.0.sh + +no-choice: + @echo 'Необходимо указать хотя бы один из предложенных параметров:' + @echo 'docker docker-compose rvm rbenv nvm postgresql-12 postgresql-14 mysql-5.7 mysql-8.0' diff --git a/README.md b/README.md deleted file mode 100644 index 8199e55..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# scripts \ No newline at end of file diff --git a/main.sh b/main.sh new file mode 100644 index 0000000..592851b --- /dev/null +++ b/main.sh @@ -0,0 +1,192 @@ +#!/bin/bash + +clear +PS3='Выберите необходимую программу: ' + +select Programm in "Docker" "Docker-compose" "RVM" "RBENV" "NVM" "Postgresql" "Mysql" "Выбрать несколько" +do + break +done + +case $Programm in + "Docker") + echo "Installing $Programm" + sudo bash ./scripts/docker.sh + ;; + "Docker-compose") + echo "Installing $Programm" + sudo bash ./scripts/docker-compose.sh + ;; + "RVM") + echo "Installing $Programm" + bash ./scripts/rvm.sh + exec bash + ;; + "RBENV") + echo "Installing $Programm" + bash ./scripts/rbenv.sh + exec bash + ;; + "NVM") + echo "Installing $Programm" + bash ./scripts/nvm.sh + exec bash + ;; + "Postgresql") + clear + PS3='Выберите необходимую версию Postgresql: ' + select Version in "12" "14" + do + break + done + case $Version in + "12") + echo "Installing $Programm $Version" + sudo bash ./scripts/postgresql-12.sh + ;; + "14") + echo "Installing $Programm $Version" + sudo bash ./scripts/postgresql-14.sh + ;; + *) + echo "Вы указали неверное значение." + ;; + esac + ;; + "Mysql") + clear + PS3='Выберите необходимую версию Mysql: ' + select Version in "5.7" "8.0" + do + break + done + case $Version in + "5.7") + echo "Installing $Programm $Version" + sudo bash ./scripts/mysql-5.7.sh + ;; + "8.0") + echo "Installing $Programm $Version" + sudo bash ./scripts/mysql-8.0.sh + ;; + *) + echo "Вы указали неверное значение." + ;; + esac + ;; + "Выбрать несколько") + ans6_1="false" + ans6_2="false" + ans7_1="false" + ans7_2="false" + clear + echo "Установить Docker? [y/n] " + read ans1 + echo "Установить Docker-compose? [y/n] " + read ans2 + echo "Установить RVM? [y/n] " + read ans3 + echo "Установить RBENV? [y/n] " + read ans4 + echo "Установить NVM? [y/n] " + read ans5 + echo "Установить Postgresql? [y/n] " + read ans6 + + if [ "$ans6" = "y" ] + then + PS3='Выберите необходимую версию Postgresql: ' + select Version in "12" "14" + do + break + done + case $Version in + "12") + ans6_1="true" + ;; + "14") + ans6_2="true" + ;; + *) + echo "Вы указали неверное значение." + ;; + esac + fi + echo "Установить Mysql? [y/n] " + read ans7 + + if [ "$ans7" = "y" ] + then + PS3='Выберите необходимую версию Mysql: ' + select Version in "5.7" "8.0" + do + break + done + case $Version in + "5.7") + ans7_1="true" + ;; + "8.0") + ans7_2="true" + ;; + *) + echo "Вы указали неверное значение." + ;; + esac + fi + + if [ "$ans1" = "y" ] + then + echo "Installing Docker" + sudo bash ./scripts/docker.sh + fi + if [ "$ans2" = "y" ] + then + echo "Installing Docker-compose" + sudo bash ./scripts/docker-compose.sh + fi + if [ "$ans3" = "y" ] + then + echo "Installing RVM" + bash ./scripts/rvm.sh + fi + if [ "$ans4" = "y" ] + then + echo "Installing RBENV" + bash ./scripts/rbenv.sh + fi + if [ "$ans5" = "y" ] + then + echo "Installing NVM" + bash ./scripts/nvm.sh + fi + if [ "$ans6" = "y" ] + then + if [ $ans6_1 = "true" ] + then + echo "Installing Postgresql 12" + sudo bash ./scripts/postgresql-12.sh + elif [ $ans6_2 = "true" ] + then + echo "Installing Postgresql 14" + sudo bash ./scripts/postgresql-14.sh + fi + fi + if [ "$ans7" = "y" ] + then + if [ $ans7_1 = "true" ] + then + echo "Installing Mysql 5.7" + sudo bash ./scripts/mysql-5.7.sh + elif [ $ans7_2 = "true" ] + then + echo "Installing Mysql 8.0" + sudo bash ./scripts/mysql-8.0.sh + fi + fi + exec bash + ;; + *) + echo "Вы указали неверное значение." + ;; +esac \ No newline at end of file diff --git a/scripts/docker-compose.sh b/scripts/docker-compose.sh new file mode 100644 index 0000000..37c1ee7 --- /dev/null +++ b/scripts/docker-compose.sh @@ -0,0 +1,17 @@ +#!/bin/bash +declare -a arr=("ubuntu" "cpe:/o:centos:centos:7" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" cat /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done + +if [ "$os" == "ubuntu" ] || [ "$os" == "cpe:/o:centos:centos:7" ] || [ "$os" == "cpe:/o:centos:centos:8" ]; +then + sudo curl -L "https://github.com/docker/compose/releases/download/v2.4.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose +fi \ No newline at end of file diff --git a/scripts/docker.sh b/scripts/docker.sh new file mode 100644 index 0000000..7a8ef1f --- /dev/null +++ b/scripts/docker.sh @@ -0,0 +1,41 @@ +#!/bin/bash +declare -a arr=("ubuntu" "cpe:/o:centos:centos:7" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" cat /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done + +if [ "$os" == "ubuntu" ]; +then + sudo apt update && sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io + sudo usermod -aG docker ${USER} + sudo chmod 666 /var/run/docker.sock + sudo systemctl start docker && sudo systemctl enable docker +fi + +if [ "$os" == "cpe:/o:centos:centos:7" ]; +then + sudo yum install -y curl + curl -fsSL https://get.docker.com/ | sh + sudo usermod -aG docker $(whoami) + sudo systemctl start docker && sudo systemctl enable docker + sudo chmod 666 /var/run/docker.sock +fi + +if [ "$os" == "cpe:/o:centos:centos:8" ]; +then + yum -y install yum-utils gcc gcc-c++ + yum-config-manager \ + --add-repo \ + https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo + yum -y install docker-ce docker-ce-cli containerd.io --allowerasing + sudo systemctl start docker && sudo systemctl enable docker +fi \ No newline at end of file diff --git a/scripts/mysql-5.7.sh b/scripts/mysql-5.7.sh new file mode 100644 index 0000000..0b946b2 --- /dev/null +++ b/scripts/mysql-5.7.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +declare -a arr=("cpe:/o:centos:centos:7" "ubuntu" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done +if [ "$os" == "ubuntu" ]; +then + sudo apt update && sudo apt install -y software-properties-common ca-certificates + sudo sh -c 'echo "deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-apt-config + deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7 + deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools + #deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools-preview + deb-src http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7" > /etc/apt/sources.list.d/mysql.list' + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29 + sudo apt update + sudo apt install -y -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7* +fi + +if [ "$os" == "cpe:/o:centos:centos:7" ]; +then + sudo yum install -y curl + curl -sSLO https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm + sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm + sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 + sudo yum install -y mysql-server + sudo systemctl start mysqld && sudo systemctl enable mysqld + sudo grep 'temporary password' /var/log/mysqld.log +fi + +if [ "$os" == "cpe:/o:centos:centos:8" ]; +then + sudo touch /etc/yum.repos.d/mysql-community.repo + sudo sh -c 'echo "[mysql-connectors-community] + name=MySQL Connectors Community + baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/\$basearch/ + enabled=1 + gpgcheck=0 + + [mysql-tools-community] + name=MySQL Tools Community + baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/\$basearch/ + enabled=1 + gpgcheck=0 + + [mysql57-community] + name=MySQL 5.7 Community Server + baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/\$basearch/ + enabled=1 + gpgcheck=0" > /etc/yum.repos.d/mysql-community.repo' + sudo dnf module disable -y mysql + sudo dnf config-manager --enable mysql57-community + sudo yum install -y mysql-server + sudo systemctl start mysqld && sudo systemctl enable mysqld + sudo grep 'temporary password' /var/log/mysqld.log +fi diff --git a/scripts/mysql-8.0.sh b/scripts/mysql-8.0.sh new file mode 100644 index 0000000..404a9bb --- /dev/null +++ b/scripts/mysql-8.0.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +declare -a arr=("cpe:/o:centos:centos:7" "ubuntu" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done +if [ "$os" == "ubuntu" ]; +then + sudo apt update -y && sudo apt install mysql-server mysql-client +fi + +if [ "$os" == "cpe:/o:centos:centos:7" ]; +then + sudo yum install -y curl + curl -sSLO https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm + sudo rpm -ivh mysql80-community-release-el7-5.noarch.rpm + sudo yum install -y mysql-server + sudo systemctl start mysqld && sudo systemctl enable mysqld + sudo grep 'temporary password' /var/log/mysqld.log +fi + +if [ "$os" == "cpe:/o:centos:centos:8" ]; +then + sudo dnf install -y mysql-server + sudo systemctl start mysqld && sudo systemctl enable mysqld +fi diff --git a/scripts/nvm.sh b/scripts/nvm.sh new file mode 100644 index 0000000..f80fe03 --- /dev/null +++ b/scripts/nvm.sh @@ -0,0 +1,23 @@ +#!/bin/bash +declare -a arr=("ubuntu" "cpe:/o:centos:centos:7" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" cat /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done + +if [ "$os" == "ubuntu" ]; +then + sudo apt update -y && sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash +fi + +if [ "$os" == "cpe:/o:centos:centos:7" ] || [ "$os" == "cpe:/o:centos:centos:8" ]; +then + sudo yum install -y curl + curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash +fi \ No newline at end of file diff --git a/scripts/postgresql-12.sh b/scripts/postgresql-12.sh new file mode 100644 index 0000000..65f93eb --- /dev/null +++ b/scripts/postgresql-12.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +declare -a arr=("cpe:/o:centos:centos:7" "ubuntu" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done +if [ "$os" == "ubuntu" ]; +then + sudo apt update -y && sudo apt install -y apt-transport-https ca-certificates wget gnupg-agent software-properties-common + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + sudo apt update -y + sudo apt install -y postgresql-12 +fi + +if [ "$os" == "cpe:/o:centos:centos:7" ]; +then + sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm + sudo yum install -y postgresql12-server + sudo /usr/pgsql-12/bin/postgresql-12-setup initdb + sudo systemctl start postgresql-12 && sudo systemctl enable postgresql-12 +fi + +if [ "$os" == "cpe:/o:centos:centos:8" ]; +then + sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm + sudo dnf -qy module disable postgresql + sudo dnf install -y postgresql12-server + sudo /usr/pgsql-12/bin/postgresql-12-setup initdb + sudo systemctl enable postgresql-12 && sudo systemctl start postgresql-12 +fi diff --git a/scripts/postgresql-14.sh b/scripts/postgresql-14.sh new file mode 100644 index 0000000..cffeee3 --- /dev/null +++ b/scripts/postgresql-14.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +declare -a arr=("cpe:/o:centos:centos:7" "ubuntu" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done +if [ "$os" == "ubuntu" ]; +then + sudo apt update -y && sudo apt install -y apt-transport-https ca-certificates wget gnupg-agent software-properties-common + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + sudo apt update -y + sudo apt install -y postgresql-14 +fi + +if [ "$os" == "cpe:/o:centos:centos:7" ]; +then + sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm + sudo yum install -y postgresql14-server + sudo /usr/pgsql-14/bin/postgresql-14-setup initdb + sudo systemctl start postgresql-14 && sudo systemctl enable postgresql-14 +fi + +if [ "$os" == "cpe:/o:centos:centos:8" ]; +then + sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm + sudo dnf -qy module disable postgresql + sudo dnf install -y postgresql14-server + sudo /usr/pgsql-14/bin/postgresql-14-setup initdb + sudo systemctl enable postgresql-14 && sudo systemctl start postgresql-14 +fi diff --git a/scripts/rbenv.sh b/scripts/rbenv.sh new file mode 100644 index 0000000..ed3cfee --- /dev/null +++ b/scripts/rbenv.sh @@ -0,0 +1,27 @@ +#!/bin/bash +declare -a arr=("ubuntu" "cpe:/o:centos:centos:7" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" cat /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done + +if [ "$os" == "ubuntu" ]; +then + sudo apt update -y && sudo apt install -y apt-transport-https ca-certificates git curl gnupg-agent software-properties-common libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev + curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc + echo 'eval "$(rbenv init -)"' >> ~/.bashrc +fi + +if [ "$os" == "cpe:/o:centos:centos:7" ] || [ "$os" == "cpe:/o:centos:centos:8" ]; +then + sudo yum install -y git-core curl + curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc + echo 'eval "$(rbenv init -)"' >> ~/.bashrc +fi \ No newline at end of file diff --git a/scripts/rvm.sh b/scripts/rvm.sh new file mode 100644 index 0000000..428a159 --- /dev/null +++ b/scripts/rvm.sh @@ -0,0 +1,24 @@ +#!/bin/bash +declare -a arr=("ubuntu" "cpe:/o:centos:centos:7" "cpe:/o:centos:centos:8") + +for i in ${arr[@]}; +do +if grep -q "$i" cat /etc/*release > /dev/null 2>&1 +then + os=$i +break +fi +done + +if [ "$os" == "ubuntu" ]; +then + sudo apt update -y && sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common + gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + curl -sSL https://get.rvm.io | bash -s +fi + +if [ "$os" == "cpe:/o:centos:centos:7" ] || [ "$os" == "cpe:/o:centos:centos:8" ]; +then + sudo yum install -y curl tar + curl -L get.rvm.io | bash -s +fi \ No newline at end of file