zvoase (owner)

Revisions

gist: 42768 Download_button fork
public
Description:
djcontribunlink.sh - Remove a djcontriblinked module from the Django contrib directory.
Public Clone URL: git://gist.github.com/42768.git
Embed All Files: show embed
djcontribunlink.sh #
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
#!/bin/bash
# djcontribunlink.sh - Remove a djcontriblinked module from the Django contrib directory.
# See http://gist.github.com/42768 for updates.
# You may also want to see djcontriblink at http://gist.github.com/42767.
 
# Check that an argument has been given. If not, print usage string.
 
if [ -z $1 ]
then
echo "Usage: `basename $0` <link_name>"
    exit
fi
 
# If there is not already a SITE_PACKAGES environment variable, then get it
# from Python.
if [ -z $SITE_PACKAGES || ! -d $SITE_PACKAGES ]
then
SITE_PACKAGES=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`
fi
 
if [ ! -d $SITE_PACKAGES/django/contrib ]
then
echo "Django contrib directory not found. Exiting."
    exit 1
fi
 
# If given name is a symbolic link in $SITE_PACKAGES/django/contrib
if [ -h $SITE_PACKAGES/django/contrib/`basename $1` ]; then
    # Remove it
    rm -Rf $SITE_PACKAGES/django/contrib/`basename $1`
else
    # Signal an error.
    echo "Error: link `basename $1` not found in Django contrib directory."
    exit 2
fi