-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
executable file
·91 lines (73 loc) · 2.39 KB
/
install.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
#
# This script will install dependencies for the teachercom app
#
# must be run as root
if [ `whoami` != "root" ]; then
echo "This installation must be run as root."
exit 1
fi
INSTALL_DIR=`pwd`
LOG=$INSTALL_DIR/install.log
echo -n "" > $LOG
# install software requirements
echo -e "\nInstall required software? (y/n)"
read YN
if [ "$YN" == "y" ]; then
echo -e "\nInstalling required packages with 'apt' and 'pip'"
apt-get install -q -y openssh-server python2.7 python-pip sqlite3 &>> $LOG
pip install -r requirements.txt &>> $LOG
fi
read_or_none() {
read A
if [ "x$A" == "x" ]; then
A="None"
else
A="'$A'"
fi
echo "$A"
}
configure_django() {
if [ -z "$1" ]; then
return 1
fi
BASE_URL="http://www.teachercom.org/"
TWILIO_ENABLED="True"
echo -e "\nEnter your Twilio credentials (you can leave these blank to use the test account)"
echo -en "\nPlease enter your Twilio Account SID: "
ACCOUNT_SID=$(read_or_none)
echo -en "\nPlease enter your Twilio Account Auth Token: "
ACCOUNT_AUTH=$(read_or_none)
echo -en "\nPlease enter your Twilio SMS phone number in the form \"(ddd) ddd-dddd\": "
PHONE=$(read_or_none)
echo -en "\nPlease enter a username for the django admin: "
read USERNAME
echo -en "\nPlease enter an email address for the django admin: "
read EMAIL
LOCAL="$1/py/teachercom/teachercom/local_settings.py"
echo "ADMINS = (" > $LOCAL
echo " ('$USERNAME', '$EMAIL')," >> $LOCAL
echo ")" >> $LOCAL
echo "" >> $LOCAL
echo "BASE_URL = '$BASE_URL'" >> $LOCAL
echo "TWILIO_ENABLED = $TWILIO_ENABLED" >> $LOCAL
echo "TWILIO_ACCOUNT_SID = $ACCOUNT_SID" >> $LOCAL
echo "TWILIO_AUTH_TOKEN = $ACCOUNT_AUTH" >> $LOCAL
echo "TWILIO_PHONE = $PHONE" >> $LOCAL
echo "" >> $LOCAL
echo "MANAGERS = ADMINS" >> $LOCAL
echo "" >> $LOCAL
echo "MEDIA_ROOT = '$1/py/teachercom/teachercomapp/media/'" >> $LOCAL
echo "" >> $LOCAL
echo "STATIC_ROOT = '$1/py/teachercom/teachercomapp/static/'" >> $LOCAL
echo "" >> $LOCAL
echo "SECRET_KEY = '8pw%s3$@2&6lm1k&2!&!^c8w@4h0b#ae-7-$!04b24=1-b(554'" >> $LOCAL
echo "" >> $LOCAL
echo "TEMPLATE_DIRS = (" >> $LOCAL
echo " '$1/py/teachercom/templates/'" >> $LOCAL
echo ")" >> $LOCAL
echo "" >> $LOCAL
echo "STAGING = False" >> $LOCAL
return 0
}
configure_django $INSTALL_DIR