Skip to content

Commit

Permalink
Merge branch 'feature/testvh' of github.com:andrefs/gb-sysmenu into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
andrefs committed Sep 13, 2011
2 parents 9db25b1 + 547a5a1 commit 5b93def
Show file tree
Hide file tree
Showing 30 changed files with 147 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "dirmenu"]
path = dirmenu
url = git://github.com/andrefs/dirmenu.git
1 change: 1 addition & 0 deletions dirmenu
Submodule dirmenu added at 109479
3 changes: 3 additions & 0 deletions gb.b_install.txt
@@ -0,0 +1,3 @@
# title: Install/update
# os: linux
Installs or updates gb-sysmenu
3 changes: 3 additions & 0 deletions gb.m_servinit.txt
@@ -0,0 +1,3 @@
# title: Server initial configurations
# os: all
Initial configuration of SSH, Git, Rails, etc
File renamed without changes.
3 changes: 3 additions & 0 deletions gb.m_servinit/gb.b_amp.txt
@@ -0,0 +1,3 @@
# title: Install an AMP server
#os: linux
Installs Apache2, MySQL, PHP and phpMyAdmin and sets some security rules
File renamed without changes.
4 changes: 4 additions & 0 deletions gb.m_servinit/gb.b_gitolite.txt
@@ -0,0 +1,4 @@
# title: Set up a gitolite server
# os: linux


File renamed without changes.
3 changes: 3 additions & 0 deletions gb.m_servinit/gb.b_rails2.3.8_pass.txt
@@ -0,0 +1,3 @@
# title: Install and configure RoR and Passenger
# os: linux

2 changes: 1 addition & 1 deletion gb.b_root → gb.m_servinit/gb.b_root
Expand Up @@ -280,7 +280,7 @@ sed "s/iface lo inet loopback/iface lo inet loopback\nre-up iptables-restore < \
sudo aptitude update -y
sudo aptitude safe-upgrade -y
sudo aptitude install subversion subversion-tools git-core w3m mlocate sqlite3 screen gcc build-essential htophtop -y
sudo aptitude install subversion subversion-tools git-core w3m mlocate sqlite3 screen gcc build-essential htop -y
echo -e "\nalias si.b_rails=\"si.b_rails2.3.8_pass && exec bash\"\n" >> /home/$UN/.bashrc
SIEND1
Expand Down
3 changes: 3 additions & 0 deletions gb.m_servinit/gb.b_root.txt
@@ -0,0 +1,3 @@
# title: Initial Ubuntu Server configuration
# os: linux
Deactivates root account, creates normal user, gives sudo permition, sets up ssh and iptables and installs utils-menu
3 changes: 3 additions & 0 deletions gb.m_vhmanage.txt
@@ -0,0 +1,3 @@
# title: Manage virtual hosts and applications
# os: all
Gives access to operations such as adding and removing virtual hosts, put existing apps under maintenance, etc
File renamed without changes.
3 changes: 3 additions & 0 deletions gb.m_vhmanage/gb.b_addvh.txt
@@ -0,0 +1,3 @@
# title: Add new virtual host
# os: linux
Adds a new virtual host, optionally clonning a github repository, creating a MySQL database and writing user and pass on config.yml, installing ruby gems.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions gb.m_vhmanage/gb.b_bakvh.txt
@@ -0,0 +1,3 @@
# title: Create backup archive for a VH
# os: all
Presents a list of enabled virtual hosts, and backs up the system and assets folder and the Database for the chosen vh. Resulting archive is stored in ~/backups/
2 changes: 1 addition & 1 deletion gb.b_restvh → gb.m_vhmanage/gb.b_restvh
@@ -1,5 +1,5 @@
#!/bin/bash
# Restore vh from archive file passed as arguntes
# Restore vh from archive file passed as argument

# Check for arguments
if [ -z "$1" ]; then
Expand Down
3 changes: 3 additions & 0 deletions gb.m_vhmanage/gb.b_restvh.txt
@@ -0,0 +1,3 @@
# title: Restore vh from archive file passed as argument
# os: all

2 changes: 1 addition & 1 deletion gb.b_rmvh → gb.m_vhmanage/gb.b_rmvh
@@ -1,5 +1,5 @@
#!/bin/bash
# Create virtual hosts on Apache
# Completely remove vh

set -e

Expand Down
3 changes: 3 additions & 0 deletions gb.m_vhmanage/gb.b_rmvh.txt
@@ -0,0 +1,3 @@
# title: Completely remove vh
# os: all
Remove app directory, apache configuration file, ssl_keys (if any) and backups. Use with caution!
92 changes: 92 additions & 0 deletions gb.m_vhmanage/gb.b_testvh
@@ -0,0 +1,92 @@
#!/bin/bash
# Test a vh with ab


# $GBSYSMENUPATH must be defined
if [ -z "$GBSYSMENUPATH" ]; then
echo "It appears that you don't have the \$GBSYSMENUPATH environmental variable set."
echo 'This script requires that $GBSYSMENUPATH is defined in order to execute.'
echo
echo 'Please run the gb.b_install script or manually set $GBSYSMENUPATH.'
exit 1
fi

# Find out site corresponding to current directory (if any)
CURSITE=$("$GBSYSMENUPATH/gb.a_location")

echo "Here's the list of sites in your public_html directory:"

# Calculate the list of sites in public_html and their state
for site in $(ls -1 "$HOME/public_html"); do
[ "$site" == "$CURSITE" ] && continue
site="$site\n"
sitelist=(${sitelist[@]-} "$site")
done

# Repeat until valid choice
CHOICE="NO"
while [ "$CHOICE" == "NO" ]; do
# If $CURSITE is defined, present it at the top of the list
if [ -n "$CURSITE" ]; then
# Calculate the list of sites and their states
echo -e "${sitelist[@]}" |\
nl |\
perl -plne 's/^\s+(\d+)\s+/ [$1]\t/g' |\
cat <(echo -e "[Enter] $CURSITE\n") - |\
cat - <(echo "[X] Cancel") |\
column -t
else
# Calculate the list of sites and their states
echo -e "${sitelist[@]}" |\
nl |\
perl -plne 's/^\s+(\d+)\s+/ [$1]\t/g' |\
cat - <(echo "[X] Cancel") |\
column -t
fi
read -p "Choose a site to test: " -e NUMBER

case $NUMBER in
X|x) # Cancel and exit
exit 1
;;
[0-9]|[0-9][0-9]) # Number with one or two digits.
if [ -z "$CURSITE" ]; then
SITE=$(ls -1 "$HOME/public_html" | head -$NUMBER | tail -1)
else
CURSITE=$("$GBSYSMENUPATH/gb.a_location")
SITE=$(ls -1 "$HOME/public_html" | grep -v "$CURSITE" | head -$NUMBER | tail -1)
fi
testsite $SITE
CHOICE='YES'
;;
'')
if [ -z "$CURSITE" ]; then
echo "Undefined option!"
CHOICE='NO'
else
CURSITE=$("$GBSYSMENUPATH/gb.a_location")
testsite $SITE
CHOICE='YES'
fi
;;
*)
echo "Undefined option '$NUMBER'!"
CHOICE='NO'
;;
esac
done

function testsite {
SITE="$1"
read -p "Number of total requests: [1000]" -e TOTALREQS
if [ -z "$TOTALREQS" ]; then
REQS=1000
fi
read -p "Number of simultaneous requests: [5]" -e SIMREQS
if [ -z "$TOTALREQS" ]; then
SIMREQS=5
fi
ab -n $TOTALREQS -c$SIMREQS http://$SITE
}

exit 0
4 changes: 4 additions & 0 deletions gb.m_vhmanage/gb.b_testvh.txt
@@ -0,0 +1,4 @@
# title: Test a vh with ab (Apache Benchmarking tool)
# os: all
Uses ab to test a given vh. More info:
man ab
File renamed without changes.
3 changes: 3 additions & 0 deletions gb.m_vhmanage/gb.b_vhdom.txt
@@ -0,0 +1,3 @@
# title: Change domain of a vh
# os: all

File renamed without changes.
4 changes: 4 additions & 0 deletions gb.m_vhmanage/gb.b_vhmaint.txt
@@ -0,0 +1,4 @@
# title: Add/remove maintenance warning to vh
# os: all
Replaces a given vh site with a "site under maintenance" static warning.

File renamed without changes.
3 changes: 3 additions & 0 deletions gbsysmenurc
@@ -0,0 +1,3 @@
export GBSYSMENUPATH='/home/andrefs/Projects/groupbuddies/gb-sysmenu'
export GBSITESDIR='/home/andrefs/public_html'
PATH="$PATH:$GBSYSMENUPATH"

0 comments on commit 5b93def

Please sign in to comment.