forked from roundware/roundware-server
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·148 lines (114 loc) · 4.81 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# Installer for Roundware Server (http://www.roundware.org/)
# Tested with Ubuntu 12.04 LTS 64 bit
# Enable exit on error
set -e
set -v
# Default MySQL root user password (Change this on a production system!)
MYSQL_ROOT="password"
# Store the script start path
SOURCE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Check if we are installing via vagrant (assuming standard Vagrant /vagrant share)
if [ -d "/vagrant" ]; then
echo "Found Vagrant."
FOUND_VAGRANT=true
fi
# Default user name.
USERNAME="roundware"
# Use vagrant username/directories used when available.
if [ "$FOUND_VAGRANT" = true ]; then
# Change the user to the vagrant default.
USERNAME="vagrant"
# Create a symbolic link in the user's directory to the code
ln -sfn /vagrant /home/$USERNAME/roundware-server
fi
# Set paths/directories
HOME_PATH="/home/$USERNAME"
DEV_CODE_PATH="$HOME_PATH/roundware-server"
WWW_PATH="/var/www/roundware"
CODE_PATH="$WWW_PATH/source"
STATIC_PATH="$WWW_PATH/static"
MEDIA_PATH="$WWW_PATH/rwmedia"
VENV_PATH="$WWW_PATH"
SITE_PACKAGES_PATH="$VENV_PATH/lib/python2.7/site-packages"
# If not vagrant, create user and copy files.
if [ ! "$FOUND_VAGRANT" = true ]; then
# If user home doesn't exist, create the user.
if [ ! -d "/home/$USERNAME" ]; then
useradd $USERNAME -s /bin/bash -m -d $HOME_PATH
fi
# If source and dev code paths are different, copy source to code.
if [ $SOURCE_PATH != $DEV_CODE_PATH ]; then
rm -rf $DEV_CODE_PATH
mkdir -p $DEV_CODE_PATH
cp -R $SOURCE_PATH/. $DEV_CODE_PATH
fi
fi
# Replace the user's .profile
cp $SOURCE_PATH/files/home-user-profile /home/$USERNAME/.profile
# Add a script to start the manage.py runserver development server
cp $SOURCE_PATH/files/home-user-runserver.sh /home/$USERNAME/runserver.sh
chmod 700 /home/$USERNAME/runserver.sh
chown $USERNAME:$USERNAME /home/$USERNAME/runserver.sh
# Create a symbolic link to the main roundware directory
ln -sfn $WWW_PATH /home/$USERNAME/www
# Install python-software-properties to add add-apt-repository
DEBIAN_FRONTEND=noninteractive apt-get install -y python-software-properties
# Add the REAL ffmpeg
add-apt-repository -y ppa:jon-severinsson/ffmpeg
apt-get update
# Set MySQL root password
echo "mysql-server mysql-server/root_password password $MYSQL_ROOT" | debconf-set-selections
echo "mysql-server mysql-server/root_password_again password $MYSQL_ROOT" | debconf-set-selections
# Install required packages non-interactive
DEBIAN_FRONTEND=noninteractive apt-get install -y python-mysqldb python-configobj mysql-server \
icecast2 ffmpeg apache2 pacpl python-dbus libapache2-mod-wsgi python-gst0.10 \
gstreamer0.10-ffmpeg gstreamer0.10-plugins-base gstreamer0.10-plugins-bad \
gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly libavcodec-extra-53 \
python-pip gstreamer-tools python-profiler libmagic1 python-lxml \
python-dev mediainfo
# Install/upgrade virtualenv
pip install -U virtualenv
# Create the virtual environment
virtualenv --system-site-packages $VENV_PATH
# Activate the environment
source $VENV_PATH/bin/activate
# Set python path to use production code
export PYTHONPATH=$CODE_PATH
# Setup MySQL database
echo "create database IF NOT EXISTS roundware;" | mysql -uroot -p$MYSQL_ROOT
echo "grant all privileges on roundware.* to 'round'@'localhost' identified by 'round';" | mysql -uroot -p$MYSQL_ROOT
# File/directory configurations
mkdir -p $MEDIA_PATH
mkdir -p $STATIC_PATH
# copy test audio file to media storage
cp $SOURCE_PATH/files/rw_test_audio1.wav $MEDIA_PATH
# Setup apache
a2enmod rewrite
a2enmod wsgi
a2enmod headers
a2dissite 000-default
# Run the production upgrade/deployment script
$SOURCE_PATH/deploy.sh
# Setup roundware in Apache
rm -f /etc/apache2/sites-available/roundware
sed s/USERNAME/$USERNAME/g $CODE_PATH/files/etc-apache2-sites-available-roundware > /etc/apache2/sites-available/roundware
a2ensite roundware
# Setup roundware log and logrotate
touch /var/log/roundware
chown $USERNAME:$USERNAME /var/log/roundware
sed s/USERNAME/$USERNAME/g $CODE_PATH/files/etc-logrotate-d-roundware > /etc/logrotate.d/roundware
# install correct shout2send gstreamer plugin
mv /usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstshout2.so /usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstshout2.so.old
cp $CODE_PATH/files/64-bit/libgstshout2.so /usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstshout2.so
# Set $USERNAME to own all files
chown $USERNAME:$USERNAME -R $HOME_PATH
# Initialize database with syncdb and default_auth_data.json
$CODE_PATH/roundware/manage.py loaddata $CODE_PATH/roundware/fixtures/default_auth_data.json
mysql -uroot -p$MYSQL_ROOT roundware < $CODE_PATH/files/rw_base.sql
service apache2 restart
# Setup icecast
cp $CODE_PATH/files/etc-default-icecast2 /etc/default/icecast2
cp $CODE_PATH/files/etc-icecast2-icecast.xml /etc/icecast2/icecast.xml
service icecast2 restart
echo "Install Complete"