~ivle-dev/ivle/dev-scripts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash -e

# IVLE Developer Script - ivle-reload
# Author: Matt Giuca, Will Grant
#
# Usage: sudo ivle-reload
#   Optional -v argument to run verbosely. Otherwise, will hide the output
#   from build and install.
#
# Rebuilds and reinstalls IVLE, then restarts the Apache web server.
# Also restarts Usrmgt server, and cleans up Python consoles.
# Must be run as root.

# Note: If any of these fail, the script will stop (due to -e in the shebang).

if [ $UID -ne 0 ]; then
    echo "ivle-reload: Must be root."
    exit 1
fi

VERBOSE=0
if [ "$1" = '-v' ]; then
    VERBOSE=1
fi

# First clean up Python consoles
ps hax --format='pid args' \
       | grep '/usr/bin/python .*/python-console' | grep -v 'grep' \
       | cut -d ' ' -f1 \
       | xargs --no-run-if-empty kill -ALRM

# Rebuild and install IVLE
if [ $VERBOSE -eq 0 ]; then
    # Print the commands out in non-verbose mode (so you can see what's going
    # on)
    echo ./setup.py build
    ./setup.py build > /dev/null
    echo ./setup.py install
    ./setup.py install > /dev/null
else
    ./setup.py build
    ./setup.py install
fi

# Restart Apache and Usrmgt server
/etc/init.d/apache2 stop
/etc/init.d/apache2 start
sudo /etc/init.d/ivle-usrmgt-server restart