LEMPy_lib

by cicloid
3 deployments · 0 still active · last rev. 5 years ago

Based on Rnolen work

Compatible with: No distros currently supported
						#!/bin/bash

function groundwork {
  lempy_system_update_aptitude                            
  hostname `get_rdns_primary_ip`
  verygoodstuff                                           
  postfix_install_loopback_only
}

#################################
# system update   #
#################################

function lempy_system_update_aptitude {

#set console encoding so user isn't prompted. this was needed for the 8.04 SS and I won't remove it since it doesn't hurt anything.
  echo "console-setup console-setup/charmap select UTF-8" | debconf-set-selections

#i prefer aptitude. you may not.
  aptitude update
  aptitude -y full-upgrade #only sissies use safe-upgrade. ARE YOU A SISSY?

#need wget.
  aptitude install -y wget
  aptitude install -y sudo
  system_update
}

function lempy_rvm {
  groupadd wheel
  cp /etc/sudoers /etc/sudoers.tmp
  chmod 0640 /etc/sudoers.tmp
  echo "%wheel ALL = (ALL) ALL" >> /etc/sudoers.tmp
  chmod 0440 /etc/sudoers.tmp
  mv /etc/sudoers.tmp /etc/sudoers

  useradd -m -s /bin/bash -G wheel "$ADMIN_LOGIN"
  echo "${ADMIN_LOGIN}:${ADMIN_PASSWORD}" | chpasswd

  export rvm_group_name="$GROUP_NAME"
  aptitude -y install curl bison build-essential zlib1g-dev libssl-dev libreadline5-dev libxml2-dev git-core
  bash < <( curl -L http://bit.ly/rvm-install-system-wide )

  usermod -a -G "$GROUP_NAME" "$ADMIN_LOGIN"
}

#################################
# mysql install   #
#################################

function lempy_mysql_install {
  echo "mysql-server-5.1 mysql-server/root_password password $DB_PASSWORD" | debconf-set-selections
  echo "mysql-server-5.1 mysql-server/root_password_again password $DB_PASSWORD" | debconf-set-selections
  aptitude -y install mysql-server

}

#################################
# PHP-FPM     #
#################################

function lempy_phpfpm {

  aptitude -y install python-software-properties php5-fpm php-apc php5-cgi php5-cli php5-mysql php5-common php-pear php5-curl php5-suhosin php5-gd php5-imagick imagemagick

  echo "apc.shm_size = 64" >> /etc/php5/conf.d/apc.ini
  echo "apc.rfc1867 = on" >> /etc/php5/conf.d/apc.ini
  sed -i'.original' 's/^# configuration for php imagick module/; configuration for php imagick module/' /etc/php5/conf.d/imagick.ini

#have /etc/init.d/php-fpm run on boot
  update-rc.d php5-fpm defaults

#php5-fpm conf

#sockets > ports. Using the 127.0.0.1:9000 stuff needlessly introduces TCP/IP overhead.
  sed -i 's/listen = 127.0.0.1:9000/listen = \/var\/run\/php5-fpm.sock/' /etc/php5/fpm/pool.d/www.conf
#
#nice strict permissions
  sed -i 's/;listen.owner = www-data/listen.owner = www-data/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/;listen.group = www-data/listen.group = www-data/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/;listen.mode = 0666/listen.mode = 0600/' /etc/php5/fpm/pool.d/www.conf
#
#these settings are fairly conservative and can probably be increased without things melting
  sed -i 's/pm.max_children = 50/pm.max_children = 12/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/pm.start_servers = 20/pm.start_servers = 4/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/pm.min_spare_servers = 5/pm.min_spare_servers = 2/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/pm.max_spare_servers = 35/pm.max_spare_servers = 4/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/pm.max_requests = 0/pm.max_requests = 500/' /etc/php5/fpm/pool.d/www.conf
#


#Engage.
  /etc/init.d/php5-fpm start

}


#################################
# nginx     #
#################################

function lempy_nginx {
  #install it.
  aptitude install nginx
  # consensus of nginx mailing list seems to be children should be a multiple of available processors. considering nginx's asynchronous nature, 4 is plenty.
  sed -i 's/worker_processes\ \ 1/worker_processes\ 4/' /etc/nginx/nginx.conf
  #Make it so.
  /etc/init.d/nginx start
}

#################################
# very good stuff     #
#################################


function verygoodstuff {
  # Installs the REAL vim, wget, less, and enables color root prompt and the "ll" list long alias

  apt-get -y install wget vim less git-core git-svn subversion zsh wget build-essential autoconf2.13 python-software-properties
  wget http://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
  sed -i 's/robbyrussell/xiong-chiamiov/' /root/.zshrc
  
  cat > /root/.oh-my-zsh/custom/fix-delete.zsh << EOF

# Ignore commands from history that are preceeded by a whitespace
setopt hist_ignore_space
bindkey    "^[[3~"          delete-char
bindkey    "^[3;5~"         delete-char
EOF

}