2010-12-02 03:32:06 +00:00
|
|
|
#!/bin/sh
|
2010-12-22 15:15:49 +00:00
|
|
|
#fails in bootstrap
|
2012-03-30 14:57:07 +00:00
|
|
|
apt-get -y install ipython ntp
|
2010-12-22 15:15:49 +00:00
|
|
|
|
2012-04-19 12:43:54 +00:00
|
|
|
#ffmpeg installed as apt package
|
|
|
|
#wget http://firefogg.org/nightly/ffmpeg.linux -O /usr/local/bin/ffmpeg
|
|
|
|
#chmod 755 /usr/local/bin/ffmpeg
|
|
|
|
#wget http://firefogg.org/nightly/ffmpeg2theora.linux -O /usr/local/bin/ffmpeg2theora
|
|
|
|
#chmod 755 /usr/local/bin/ffmpeg2theora
|
2010-12-02 03:32:06 +00:00
|
|
|
|
|
|
|
#postgresql
|
2012-03-23 20:57:43 +00:00
|
|
|
apt-get -y install postgresql postgresql-contrib
|
2010-12-02 03:32:06 +00:00
|
|
|
sudo -u postgres createuser -S -D -R pandora
|
2011-11-08 17:05:26 +00:00
|
|
|
sudo -u postgres createdb -T template0 --locale=C --encoding=UTF8 -O pandora pandora
|
2012-03-30 14:57:07 +00:00
|
|
|
echo "CREATE EXTENSION pg_trgm;" | sudo -u postgres psql pandora
|
2010-12-02 03:32:06 +00:00
|
|
|
|
|
|
|
#rabbitmq
|
|
|
|
RABBITPWD=$(pwgen -n 16 -1)
|
|
|
|
rabbitmqctl add_user pandora $RABBITPWD
|
|
|
|
rabbitmqctl add_vhost /pandora
|
|
|
|
rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
|
|
|
|
|
|
|
#pandora
|
2012-03-23 20:57:43 +00:00
|
|
|
HOST=$(hostname -s)
|
2012-04-20 10:22:32 +00:00
|
|
|
HOST_CONFIG="/srv/pandora/pandora/config.$HOST.jsonc"
|
|
|
|
SITE_CONFIG="/srv/pandora/pandora/config.jsonc"
|
|
|
|
test -e $HOST_CONFIG && cp $HOST_CONFIG $SITE_CONFIG
|
|
|
|
test -e $SITE_CONFIG || cp /srv/pandora/pandora/config.pandora.jsonc $SITE_CONFIG
|
|
|
|
|
2010-12-02 03:32:06 +00:00
|
|
|
cat > /srv/pandora/pandora/local_settings.py << EOF
|
2011-11-08 17:05:26 +00:00
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'NAME': 'pandora',
|
|
|
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
|
|
'USER': 'pandora',
|
|
|
|
'PASSWORD': '',
|
|
|
|
}
|
|
|
|
}
|
2010-12-02 03:32:06 +00:00
|
|
|
BROKER_PASSWORD = "$RABBITPWD"
|
|
|
|
XACCELREDIRECT = True
|
2012-03-30 14:57:07 +00:00
|
|
|
DB_GIN_TRGM = True
|
2012-04-20 10:22:32 +00:00
|
|
|
|
|
|
|
DEBUG = False
|
|
|
|
TEMPLATE_DEBUG = DEBUG
|
|
|
|
JSON_DEBUG = False
|
2010-12-02 03:32:06 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
cd /srv/pandora/pandora
|
2012-03-21 14:11:12 +00:00
|
|
|
sudo -u pandora python manage.py syncdb --noinput
|
2012-03-30 14:57:07 +00:00
|
|
|
sudo -u pandora python manage.py sqlfindindex | sudo -u pandora python manage.py dbshell
|
2012-03-21 14:11:12 +00:00
|
|
|
echo "UPDATE django_site SET domain = '$HOST.local', name = '$HOST.local' WHERE 1=1;" | sudo -u pandora python manage.py dbshell
|
2010-12-02 03:32:06 +00:00
|
|
|
|
2011-11-08 17:05:26 +00:00
|
|
|
|
2010-12-02 03:32:06 +00:00
|
|
|
mkdir /srv/pandora/data
|
|
|
|
chown -R pandora:pandora /srv/pandora
|
2011-12-16 14:13:37 +00:00
|
|
|
sudo -u pandora python manage.py update_static
|
2010-12-02 03:32:06 +00:00
|
|
|
|
|
|
|
cp /srv/pandora/etc/init/* /etc/init/
|
|
|
|
|
|
|
|
service pandora-encoding start
|
|
|
|
service pandora-tasks start
|
|
|
|
service pandora start
|
|
|
|
|
|
|
|
#nginx
|
2011-11-08 17:05:26 +00:00
|
|
|
sed "s/__PREFIX__/\/srv\/pandora/g" "/srv/pandora/etc/nginx/vhost.in" > "/etc/nginx/sites-available/default"
|
2010-12-02 03:32:06 +00:00
|
|
|
service nginx restart
|
|
|
|
|
2012-03-30 14:57:07 +00:00
|
|
|
cat > /usr/local/bin/fixtime <<EOF
|
|
|
|
#!/bin/bash
|
|
|
|
while [ 1 ]; do
|
|
|
|
/usr/sbin/ntpdate pool.ntp.org >/dev/null
|
|
|
|
sleep 600
|
|
|
|
done
|
|
|
|
EOF
|
|
|
|
chmod +x /usr/local/bin/fixtime
|
|
|
|
cat > /usr/local/bin/genissue <<EOF
|
|
|
|
#!/bin/bash
|
|
|
|
HOST=\$(rgrep .local /var/log/syslog | grep "Host name is" | tail -n 1 | awk '{print \$12}' | sed 's/\.$//')
|
|
|
|
echo Welcome to pan.do/ra - connect via one of those urls:
|
|
|
|
echo
|
|
|
|
echo " http://\$HOST/"
|
|
|
|
for ip in \$(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print \$1 }'); do
|
|
|
|
echo " http://\$ip/"
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
EOF
|
|
|
|
chmod +x /usr/local/bin/genissue
|
|
|
|
|
|
|
|
cat > /etc/rc.local << EOF
|
|
|
|
#!/bin/sh -e
|
|
|
|
#vm has one network interface and that might change, make it not persistent
|
|
|
|
rm -f /etc/udev/rules.d/70-persistent-net.rules
|
|
|
|
|
|
|
|
#vm can be suspended, this help to keep the time in sync
|
|
|
|
/usr/local/bin/fixtime &
|
|
|
|
|
|
|
|
#update issue
|
|
|
|
/usr/local/bin/genissue > /etc/issue
|
|
|
|
EOF
|
|
|
|
chmod +x /etc/rc.local
|