1
#!/bin/bash
2
# Simple post-update script for many sites with git repositories
3
#    Copyright (C) 2009  Marcin Karpezo
4
#
5
#    This program is free software: you can redistribute it and/or modify
6
#    it under the terms of the GNU General Public License as published by
7
#    the Free Software Foundation, either version 3 of the License, or
8
#    (at your option) any later version.
9
#
10
#    This program is distributed in the hope that it will be useful,
11
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
#    GNU General Public License for more details.
14
#
15
#    You should have received a copy of the GNU General Public License
16
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
SITE_NAME="$1"
19
SITE_DIR="$HOME"/www/"$SITE_NAME"
20
SCRITPT_NAME="$2"
21
check() {
22
    if [ "$?" == "0" ]; then
23
        echo -e "[OK!]"
24
    else
25
        echo -e "[ERROR]"
26
        exit 255
27
    fi
28
}
29
30
unset GIT_DIR
31
echo -e "git-post-update  Copyright (C) 2009  Marcin Karpezo
32
This program comes with ABSOLUTELY NO WARRANTY.
33
This is free software, and you are welcome to redistribute it
34
under certain conditions; read COPYING file for details.\n"
35
36
if [ "$SITE_NAME" == "help" ]; then
37
    echo -e "USAGE:
38
    \t$0 name_of_website_catalog name_of_website_(fcgi)script"
39
    exit 0
40
else
41
    echo "Entering $SITE_NAME directory..."
42
    cd "$SITE_DIR"
43
    check
44
    echo "Getting new files..."
45
    git pull origin master
46
    check
47
    echo "Restarting $SITE_NAME..."
48
    sh "$HOME"/"$SCRITPT_NAME"
49
    check
50
fi