Fixes on deployment

This commit is contained in:
Marc Aymerich 2015-10-03 11:12:51 +00:00
parent 93974ef989
commit bea5cb7e7e
3 changed files with 49 additions and 44 deletions

View File

@ -50,10 +50,9 @@ pip3 install -r http://git.io/orchestra-requirements.txt
orchestra-admin startproject panel
python3 panel/manage.py migrate
python3 panel/manage.py runserver
# Browse to http://127.0.0.1:8000/admin/
```
Now you can see the web interface on http://localhost:8000/admin
Now you can see the web interface on http://localhost:8000/admin/
Checkout the steps for other deployments: [development](INSTALLDEV.md), [production](INSTALL.md)

View File

@ -60,6 +60,10 @@ check_root () {
export -f check_root
verlt () {
[ "$1" = "$2" ] && return 1 || verlte $1 $2
}
get_orchestra_dir () {
if ! $(echo "import orchestra" | $PYTHON_BIN 2> /dev/null); then
echo -e "\norchestra not installed.\n" >&2
@ -109,6 +113,13 @@ function install_requirements () {
check_root || true
ORCHESTRA_PATH=$(get_orchestra_dir) || true
# Make sure locales are in place before installing postgres
if [[ $({ perl --help > /dev/null; } 2>&1|grep 'locale failed') ]]; then
run sed -i "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen
run locale-gen
update-locale LANG=en_US.UTF-8
fi
# lxml: libxml2-dev, libxslt1-dev, zlib1g-dev
APT="bind9utils \
ca-certificates \
@ -123,44 +134,11 @@ function install_requirements () {
wget \
xvfb \
zlib1g-dev"
# cracklib and lxml are excluded on the requirements.txt because they need unconvinient system dependencies
PIP="$(wget http://git.io/orchestra-requirements.txt -O - | tr '\n' ' ') \
cracklib \
lxml==3.3.5"
if $testing; then
APT="${APT} \
git \
iceweasel \
dnsutils"
PIP="${PIP} \
selenium \
xvfbwrapper \
freezegun \
coverage \
flake8 \
django-debug-toolbar==1.3.0 \
django-nose==1.4 \
sqlparse \
pyinotify \
PyMySQL"
fi
# Install a more recent version of wkhtmltopdf (0.12.2) (PDF page number support)
if [[ $(dpkg --list | grep wkhtmltox | awk {'print $3'}) != "0.12.2.1" ]]; then
wkhtmltox=$(mktemp)
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb -O ${wkhtmltox}
dpkg -i ${wkhtmltox} || { echo "Installing missing dependencies for wkhtmltox..." && apt-get -f -y install; }
fi
# Make sure locales are in place before installing postgres
if [[ $({ perl --help > /dev/null; } 2>&1|grep 'locale failed') ]]; then
run sed -i "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen
run locale-gen
update-locale LANG=en_US.UTF-8
fi
run apt-get update
run apt-get install -y $APT
@ -174,7 +152,35 @@ function install_requirements () {
update-ca-certificates
fi
# cracklib and lxml are excluded on the requirements.txt because they need unconvinient system dependencies
PIP="$(wget http://git.io/orchestra-requirements.txt -O - | tr '\n' ' ') \
cracklib \
lxml==3.3.5"
if $testing; then
PIP="${PIP} \
selenium \
xvfbwrapper \
freezegun \
coverage \
flake8 \
django-debug-toolbar==1.3.0 \
django-nose==1.4 \
sqlparse \
pyinotify \
PyMySQL"
fi
run pip3 install $PIP
# Install a more recent version of wkhtmltopdf (0.12.2) (PDF page number support)
wkhtmltox_version=$(dpkg --list | grep wkhtmltox | awk {'print $3'})
if [[ ! $wkhtmltox_version || verlt $wkhtmltox_version 0.12.2.1 ]]; then
wkhtmltox=$(mktemp)
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb -O ${wkhtmltox}
dpkg -i ${wkhtmltox} || { echo "Installing missing dependencies for wkhtmltox..." && apt-get -f -y install; }
fi
}
export -f install_requirements

View File

@ -17,7 +17,7 @@ function test_orchestra () {
echo
echo ${bold}
echo "> Checking if Orchestra is serving on https://${ip_addr}/admin/ ..."
if [[ $noinput == '--noinput' ]]; then
if [[ $noinput ]]; then
echo " - username: $user"
echo " - password: orchestra${normal}"
fi
@ -90,7 +90,7 @@ function setup_database () {
/etc/postgresql/${pg_version}/main/postgresql.conf
fi
run sudo service postgresql start
if [[ $noinput == '--noinput' ]]; then
if [[ $noinput ]]; then
db_password=$(ps aux | sha256sum | base64 | head -c 10)
run sudo python3 -W ignore manage.py setuppostgres --noinput --db_password $db_password
else
@ -190,7 +190,7 @@ function main () {
unset OPTIND
unset opt
if [[ $noinput == '' ]]; then
if [[ ! $noinput ]]; then
if [[ $(whoami) == 'root' ]]; then
echo -e "\nErr. Interactive script should run as a regular user\n" >&2
exit 2
@ -213,10 +213,10 @@ function main () {
exit 5
fi
if [[ $noinput == '' && $bproject_name == false ]]; then
if [[ ! $noinput && $bproject_name == false ]]; then
while true; do
read -p "Enter a project name [panel]: " project_name
if [[ "$project_name" == "" ]]; then
if [[ ! "$project_name" ]]; then
project_name="panel"
break
elif [[ ! $(echo "$project_name" | grep '^[_a-zA-Z]\w*$') ]]; then
@ -233,7 +233,7 @@ function main () {
fi
task=cronbeat
if [[ $noinput == '' ]]; then
if [[ ! $noinput ]]; then
while true; do
read -p "Do you want to use celery or cronbeat (orchestra.contrib.tasks) for task execution [cronbeat]? " task
case $task in
@ -253,7 +253,7 @@ function main () {
cd $project_name
setup_database $dev "$noinput"
if [[ $noinput == '--noinput' ]]; then
if [[ $noinput ]]; then
create_orchestra_superuser $user $user@localhost orchestra
fi
@ -276,8 +276,8 @@ function main () {
ip_addr=$(ip addr show eth0 | grep 'inet ' | sed -r "s/.*inet ([^\s]*).*/\1/" | cut -d'/' -f1)
if [[ $ip_addr == '' ]]; then
ip_addr='127.0.0.1'
if [[ ! $ip_addr ]]; then
ip_addr=127.0.0.1
fi
# Configure settings file into debug mode