Скрипт установки для Debian 8

Описание

Автоматическая установка и обновление зависимых пакетов

Автоматическая устанока и настройка серверов GIT, PHP 5.6, PHP-FPM, Nginx, Redis, MySQL (mariadb), RabbitMQ, Exim4

Автоматическое конфигурирование пакетов

Установка автоматического бекапа БД MySQL (https://github.com/Mirocow/mysql_utils.git)

Устанока скрипта для создания сайта (https://github.com/Mirocow/site-create)

Установка

# nano debian-install.sh # bash ./debian-install.sh

В debian-install.sh вставляем ниже следующий текст и нащимаем Ctrl-x, затем y (сохраняем и выходим)

#!/bin/sh distrib="jessie" hostname="" promptyn () { while true; do read -p "$1" yn case $yn in [Yy]* ) return 0;; [Nn]* ) return 1;; * ) echo "Please answer yes or no.";; esac done } installpkg() { for pkg in $@ do if [ $(dpkg-query -W -f='${Status}' $pkg 2>/dev/null | grep -c "ok installed") -eq 0 ]; then echo "Install $pkg ..." apt-get install -y $pkg; fi done } replacetext() { sed -ie "s/$1/$2/" $3 } apt-get update && apt-get upgrade -y installpkg apt apt-utils wget chkconfig sudo nano rename debconf-utils while read -p 'Enter the Internet domain name (e.g. nixcraft.com) : ' hostname && [[ -z "$hostname" ]] ; do echo "No, please, no blank hostname!" done if promptyn "Do you wish to install default programs? " ; then echo -e "Install default programs"; installpkg mc git mercurial bash-completion bzip2 numactl -y fi if promptyn "Do you wish to install developers programs? "; then echo -e "Install development soft"; installpkg checkinstall gcc build-essential g++ libboost-dev libboost-program-options-dev libboost-all-dev libevent-dev uuid-dev -y fi if promptyn "Do you wish to install system monitors? "; then echo -e "Install system monitors"; installpkg htop iptraf jnettop iftop -y fi if promptyn "Do you wish to uninstall systemd and install systemv? "; then installpkg sysvinit-core sysvinit-utils -y cp /usr/share/sysvinit/inittab /etc/inittab fi if promptyn "Do you wish to install MySql? "; then if promptyn "Do you wish to install MySql (Percona) (y) or Mariadb (n)?"; then installpkg software-properties-common apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db echo " # Percona #deb http://repo.percona.com/apt ${distrib} testing #deb-src http://repo.percona.com/apt ${distrib} testing " > etc/apt/sources.list.d/mysql.list apt-get update echo -e "Install MySQL (Percona)" installpkg percona-server-server-5.7 percona-server-client-5.7 percona-server-common-5.7 percona-toolkit -y chkconfig mysql on else installpkg software-properties-common apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db echo " # MariaDB 10.1 repository list - created 2016-08-05 19:23 UTC # http://downloads.mariadb.org/mariadb/repositories/ deb [arch=amd64,i386] http://mirror.timeweb.ru/mariadb/repo/10.1/debian ${distrib} main deb-src http://mirror.timeweb.ru/mariadb/repo/10.1/debian ${distrib} main " > etc/apt/sources.list.d/mysql.list apt-get update echo -e "Install MySQL (Mariadb)" installpkg mariadb-server mariadb-client mariadb-common mytop -y chkconfig mysql on fi fi if promptyn "Do you wish to install Nginx? "; then wget -q http://nginx.org/keys/nginx_signing.key -O- | apt-key add - echo " # nginx deb http://nginx.org/packages/debian ${distrib} nginx deb-src http://nginx.org/packages/debian ${distrib} nginx " > etc/apt/sources.list.d/nginx.list apt-get update echo -e "Install Nginx" installpkg nginx -y chkconfig nginx on fi if promptyn "Do you wish to install PHP-FPM? "; then wget -q http://www.dotdeb.org/dotdeb.gpg -O- | apt-key add - echo " # php-fpm dotdeb deb http://packages.dotdeb.org ${distrib} all deb-src http://packages.dotdeb.org ${distrib} all " > etc/apt/sources.list.d/php-fpm.list apt-get update echo -e "Install PHP-FPM" installpkg -u -t stable php5 php5-dev php5-sqlite php5-mcrypt php5-xsl php5-cli php5-common php5-mysql php5-gd php5-fpm \ php5-cgi php-pear php5-curl php5-xcache php5-redis -y echo "cgi.fix_pathinfo = 0" >> /etc/php5/fpm/php.ini chkconfig php5-fpm on fi if promptyn "Do you wish to install RabbitMQ? "; then wget -q http://packages.erlang-solutions.com/debian/erlang_solutions.asc -O- | apt-key add - wget -q https://www.rabbitmq.com/rabbitmq-signing-key-public.asc -O- | apt-key add - echo " # Erlang deb http://packages.erlang-solutions.com/debian ${distrib} contrib # RabbitMq deb http://www.rabbitmq.com/debian/ testing main " > etc/apt/sources.list.d/rabbitmq.list apt-get update echo -e "Install RabbitMQ" installpkg rabbitmq-server -y chkconfig rabbitmq-server on fi if promptyn "Do you wish to install Redis server? "; then echo -e "Install Redis" installpkg redis-server -y chkconfig redis-server on fi if promptyn "Do you wish to install DNS server? "; then echo -e "Install DNS Server" if promptyn "Do you wish to install bind (y) or pdns (n) server?"; then installpkg bind9 bind9utils bind9-libs -y else installpkg pdns-server pdns-backend-mysql pdns-recursor -y fi fi if promptyn "Do you wish to install Shorewall? "; then installpkg shorewall -y fi if promptyn "Do you wish to install fail2ban? "; then installpkg fail2ban -y fi if promptyn "Do you wish to install Mysql backup system? "; then echo -e "Install MySql backup system"; apt-get update installpkg git -y git clone https://github.com/Mirocow/mysql_utils.git /root/mysql_utils echo ' # Run MySql backup system 25 6 * * * root /bin/bash ~/mysql_utils/backup.sh --dir="/var/backups/mysql" --compress=bzip2 --exclude="mysql" --lifetime="3 day ago" ' >> /etc/crontab fi if promptyn "Do you wish to install create site script? "; then echo -e "Install create site scriptm"; wget https://raw.githubusercontent.com/Mirocow/site-create/master/site-create.sh -O /root/site-create.sh fi rm /var/cache/apt/archives/*.deb -f if promptyn "Do you wish to set default shell settings? "; then #echo -e "## Install DNS Server ##" #apt-get install bind9 bind9utils bind9-libs -y #apt-get install pdns-server pdns-backend-mysql pdns-recursor -y #echo " *Clearing downloaded packages after install!*" #rm /var/cache/apt/archives/*.deb -f echo -e "Base system configure" echo ' # # My config # alias nano="nano -u -w " alias ls="ls --color=always" alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' HISTSIZE=50000 HISTFILESIZE=50000 export HISTCONTROL=ignoreboth shopt -s cmdhist shopt -s histappend shopt -s checkwinsize shopt -s extglob ulimit -c 0 # # Functions # #----------------------------------- # Функции работы с историей комманд #----------------------------------- function h(){ history| grep "$@"; } # Включение магии bash if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi ' >> ~/.bashrc source ~/.bashrc echo ' set tabsize "2" ' >> ~/.nanorc fi apt-get update apt-get upgrade