-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f60ecb7
commit 8f6c199
Showing
11 changed files
with
179 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo 'you really got me' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
destroy |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
# from: http://jetpackweb.com/blog/2009/07/20/bash-script-to-create-mysql-database-and-user/ | ||
EXPECTED_ARGS=3 | ||
E_BADARGS=65 | ||
MYSQL=`which mysql` | ||
|
||
Q1="CREATE DATABASE IF NOT EXISTS $1;" | ||
Q2="GRANT ALL ON $1.* TO '$2'@'localhost' IDENTIFIED BY '$3';" | ||
Q3="FLUSH PRIVILEGES;" | ||
SQL="${Q1}${Q2}${Q3}" | ||
|
||
if [ $# -ne $EXPECTED_ARGS ] | ||
then | ||
echo "Usage: $0 dbname dbuser dbpass" | ||
exit $E_BADARGS | ||
fi | ||
|
||
$MYSQL -uroot -p -e "$SQL" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Nginx - new server block | ||
# Based on this post: http://clubmate.fi/how-to-make-an-nginx-server-block-manually-or-with-a-shell-script/ | ||
|
||
# Functions | ||
ok() { echo -e '\e[32m'$1'\e[m'; } # Green | ||
die() { echo -e '\e[1;31m'$1'\e[m'; exit 1; } | ||
|
||
# Variables | ||
NGINX_AVAILABLE_VHOSTS='/etc/nginx/sites-available' | ||
NGINX_ENABLED_VHOSTS='/etc/nginx/sites-enabled' | ||
WEB_DIR='/var/www' | ||
WEB_USER='www-data' | ||
NGINX_SCHEME='$scheme' | ||
NGINX_REQUEST_URI='$request_uri' | ||
URI='$uri' | ||
ARGS='$args' | ||
DOCUMENT_ROOT='$document_root' | ||
FASTCGI_SCRIPT_NAME='$fastcgi_script_name' | ||
|
||
# Sanity check | ||
[ $(id -g) != "0" ] && die "Script must be run as root." | ||
[ $# != "1" ] && die "Usage: $(basename $0) domainName" | ||
|
||
# Create nginx config file | ||
cat > $NGINX_AVAILABLE_VHOSTS/$1 <<EOF | ||
server { | ||
listen 80; | ||
listen [::]:80; | ||
root /var/www/$1/htdocs; | ||
index index.php index.html index.htm; | ||
server_name $1 www.$1; | ||
location / { | ||
try_files $URI $URI/ /index.php?q=$URI&$ARGS; | ||
} | ||
error_page 404 /404.html; | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
location ~ \.php$ { | ||
try_files $URI =404; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass unix:/var/run/php5-fpm.sock; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$FASTCGI_SCRIPT_NAME; | ||
include fastcgi_params; | ||
} | ||
# Logs | ||
access_log $WEB_DIR/$1/logs/access.log; | ||
error_log $WEB_DIR/$1/logs/error.log; | ||
} | ||
EOF | ||
|
||
# Creating {public,log} directories | ||
mkdir -p $WEB_DIR/$1/htdocs | ||
mkdir -p $WEB_DIR/$1/htdocs/logs | ||
touch $WEB_DIR/$1/logs/access.log | ||
touch $WEB_DIR/$1/logs/error.log | ||
|
||
# Creating index.html file | ||
cat > $WEB_DIR/$1/htdocs/index.html <<EOF | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>$1</title> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body class="container"> | ||
<header><h1>$1<h1></header> | ||
<div id="wrapper"> | ||
Hello World | ||
</div> | ||
<footer>© $(date +%Y)</footer> | ||
</body> | ||
</html> | ||
EOF | ||
|
||
# Changing permissions | ||
chown -R $USER:$WEB_USER $WEB_DIR/$1 | ||
|
||
# Enable site by creating symbolic link | ||
ln -s $NGINX_AVAILABLE_VHOSTS/$1 $NGINX_ENABLED_VHOSTS/$1 | ||
|
||
# Restart | ||
echo "Do you wish to restart nginx?" | ||
select yn in "Yes" "No"; do | ||
case $yn in | ||
Yes ) /etc/init.d/nginx restart ; break;; | ||
No ) exit;; | ||
esac | ||
done | ||
|
||
ok "Site Created for $1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Nginx - delete block | ||
# Based on this post: http://clubmate.fi/how-to-make-an-nginx-server-block-manually-or-with-a-shell-script/ | ||
|
||
# Functions | ||
ok() { echo -e '\e[32m'$1'\e[m'; } # Green | ||
die() { echo -e '\e[1;31m'$1'\e[m'; exit 1; } | ||
|
||
# Variables | ||
NGINX_AVAILABLE_VHOSTS='/etc/nginx/sites-available' | ||
NGINX_ENABLED_VHOSTS='/etc/nginx/sites-enabled' | ||
WEB_DIR='/var/www' | ||
CURRENT_TIME=$(date "+%Y%m%d-%H%M%S") | ||
ARCHIVE_NAME=$CURRENT_TIME'.zip' | ||
|
||
# Sanity check | ||
[ $(id -g) != "0" ] && die "Script must be run as root." | ||
[ $# != "1" ] && die "Usage: $(basename $0) domainName" | ||
|
||
# Zip up and backup to archive site | ||
echo "Archiving site $1" | ||
mkdir -p $WEB_DIR/archive/$1 | ||
zip -r $WEB_DIR/archive/$1/$ARCHIVE_NAME $WEB_DIR/$1 | ||
|
||
# Delete serverblock directories | ||
rm -rf $WEB_DIR/$1 | ||
|
||
# Remove site and symbolic link | ||
rm -f $NGINX_ENABLED_VHOSTS/$1 | ||
rm -f $NGINX_AVAILABLE_VHOSTS/$1 | ||
|
||
# Restart | ||
echo "Do you wish to restart nginx?" | ||
select yn in "Yes" "No"; do | ||
case $yn in | ||
Yes ) /etc/init.d/nginx restart ; break;; | ||
No ) exit;; | ||
esac | ||
done | ||
|
||
ok "Site Removed for $1" |
Empty file.
Empty file.