Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
echo "Enter the name of the domain you wish to create"
read a
echo "Create DocumentRoot directory..."
if [ ! -d /var/www/$a ]; then
mkdir -p /var/www/$a/public_html
mkdir -p /var/www/$a/logs
@ahmadsoe
ahmadsoe / backup_mysql.sh
Created December 24, 2013 21:14
Backup MySQL database(s) to local or remote server.
#!/bin/bash
# Backup MySQL database(s) to local and/or remote server.
# databases=( 'DB_1' 'DB_2' 'DB_3')
databases=( )
db_host="localhost"
db_user=""
db_pass=""
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
sudo su - postgres -c "service postgresql stop"
sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"'
@ahmadsoe
ahmadsoe / setup-postgresql-ubuntu.sh
Created May 6, 2014 06:38
Setup postgresql 9.3 on ubuntu 12.04
#!/bin/bash
#
REPO_FILE=/etc/apt/sources.list.d/pgdg.list
UBUNTU_VERSION=$(lsb_release -sr)
if [[ $UBUNTU_VERSION -eq '12.04' ]]; then
echo ' * Using defaults for 12.04 (Precise)'
UBUNTU_VERSION='precise'
elif [[ $UBUNTU_VERSION -eq '10.04' ]]; then
@ahmadsoe
ahmadsoe / ubuntu-posgresql-redis.sh
Created May 6, 2014 08:50
Install postgresql 9.3, latest redis on ubuntu 12.04
#!/bin/sh
# Update System
echo "System Update"
sudo apt-get -y update
echo "Update completed"
# Dependency Package Install
sudo apt-get -y install libssl-dev build-essential pkg-config git
sudo apt-get -y install python-software-properties python
@ahmadsoe
ahmadsoe / posgresql-tuning
Created May 6, 2014 10:30
Posgresql 9.3 Tuning
## Posgresql 9.3 Tuning
# RAM = 8GB
# http://pgtune.leopard.in.ua/
max_connections = 200
shared_buffers = 2GB
effective_cache_size = 6GB
work_mem = 10485kB
maintenance_work_mem = 512MB
checkpoint_segments = 32
@ahmadsoe
ahmadsoe / hardenUbuntu.sh
Last active April 11, 2020 20:00 — forked from lrobert/hardenUbuntu.sh
Ubuntu Installation script
#!/bin/bash
#
# Lee Robert's Base Ubuntu Installation script for use on Digital Ocean (Or any other ubuntu install really.)
# Made and tested with Ubuntu 13.04 64bit
#
# USAGE: bash hardenUbuntu.sh
#
# Steps:
# 01. Secure Root User
# 02. Make .bashrc print out pretty colors (and root's prompt will be red)
@ahmadsoe
ahmadsoe / upgrade_kernel_ubuntu.sh
Created May 8, 2014 12:47
ubuntu kernel update
apt-get -y install linux-image-generic-lts-raring linux-headers-generic-lts-raring
reboot
@ahmadsoe
ahmadsoe / docker-remove.sh
Created May 25, 2014 21:24
Stop & remove all docker containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@ahmadsoe
ahmadsoe / haproxy_restart.sh
Created May 29, 2014 00:25
Restart haproxy
#!/bin/bash
echo "Gracefully reloading haproxy..."
sudo haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)
echo "[done]"