2014-08-07 02:57:24 +02:00
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
2014-08-08 05:16:24 +02:00
|
|
|
server_name=$3
|
2014-08-12 03:18:09 +02:00
|
|
|
admin_email=$4
|
|
|
|
admin_password=$5
|
2014-08-07 04:42:27 +02:00
|
|
|
final_path=/var/www/seafile
|
2014-08-08 05:16:24 +02:00
|
|
|
seafile_data=$final_path/seafile-data
|
2014-08-07 04:42:27 +02:00
|
|
|
seafile_version=3.1.1
|
2014-08-07 02:57:24 +02:00
|
|
|
|
|
|
|
# Check domain/path availability
|
|
|
|
sudo yunohost app checkurl $domain$path -a seafile
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check dependencies
|
2014-08-12 03:18:09 +02:00
|
|
|
sudo apt-get install -y python2.7 python-setuptools python-simplejson python-imaging python-mysqldb sqlite3
|
2014-08-07 02:57:24 +02:00
|
|
|
|
|
|
|
# Copy files to the right place
|
|
|
|
sudo mkdir -p $final_path
|
2014-08-07 05:12:54 +02:00
|
|
|
sudo mkdir -p $final_path/installed
|
2014-08-12 03:18:09 +02:00
|
|
|
sudo mkdir -p $final_path/logs
|
2014-08-07 05:12:54 +02:00
|
|
|
sudo mkdir -p $final_path/seafile-data
|
|
|
|
sudo mkdir -p $final_path/seafile-server-$seafile_version
|
2014-08-12 03:18:09 +02:00
|
|
|
sudo tar xzf ../sources/'seafile-server_'$seafile_version'_x86-64.tar'
|
2014-08-08 02:59:46 +02:00
|
|
|
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
|
2014-08-07 05:12:54 +02:00
|
|
|
sudo mv ../sources/'seafile-server_'$seafile_version'_x86-64.tar' $final_path/installed
|
2014-08-07 04:42:27 +02:00
|
|
|
|
|
|
|
# Set permissions to seafile directory
|
2014-08-07 05:12:54 +02:00
|
|
|
sudo chown -R www-data: $final_path
|
|
|
|
|
2014-08-08 05:16:24 +02:00
|
|
|
# Find available ports
|
|
|
|
ccnet_port=10001
|
|
|
|
seafile_port=12001
|
2014-08-12 03:18:09 +02:00
|
|
|
seafile_fileserver_port=8082
|
|
|
|
seahub_port=8000
|
|
|
|
|
|
|
|
sudo yunohost app checkport $seahub_port
|
|
|
|
sudo yunohost app checkport $seafile_fileserver_port
|
|
|
|
sudo yunohost app checkport $seafile_port
|
|
|
|
sudo yunohost app checkport $ccnet_port
|
2014-08-08 05:16:24 +02:00
|
|
|
|
2014-08-08 02:59:46 +02:00
|
|
|
# Modify install script with parameters
|
2014-08-08 05:16:24 +02:00
|
|
|
sed -i "s@SERVER_NAME@$server_name@g" ../sources/setup-seafile.sh
|
|
|
|
sed -i "s@DOMAIN@$domain@g" ../sources/setup-seafile.sh
|
|
|
|
sed -i "s@CCNET_PORT@$ccnet_port@g" ../sources/setup-seafile.sh
|
|
|
|
sed -i "s@SEAFILE_DATA@$seafile_data@g" ../sources/setup-seafile.sh
|
|
|
|
sed -i "s@SEAFILE_PORT@$seafile_port@g" ../sources/setup-seafile.sh
|
2014-08-12 03:18:09 +02:00
|
|
|
sed -i "s@SEAFILE_FILESERVER_PORT@$seafile_fileserver_port@g" ../sources/setup-seafile.sh
|
|
|
|
sed -i "s/ADMIN_EMAIL/$admin_email/g" ../sources/check_init_admin.py
|
|
|
|
sed -i "s/ADMIN_PASSWORD/$admin_password/g" ../sources/check_init_admin.py
|
2014-08-08 02:59:46 +02:00
|
|
|
|
2014-08-07 05:12:54 +02:00
|
|
|
# Run install script
|
2014-08-12 03:18:09 +02:00
|
|
|
sudo cp ../sources/check_init_admin.py $final_path/seafile-server-$seafile_version
|
2014-08-08 05:16:24 +02:00
|
|
|
sudo cp ../sources/setup-seafile.sh $final_path/seafile-server-$seafile_version
|
|
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/setup-seafile.sh
|
|
|
|
sudo $final_path/seafile-server-$seafile_version/setup-seafile.sh
|
2014-08-07 05:12:54 +02:00
|
|
|
|
2014-08-12 03:18:09 +02:00
|
|
|
# Update config
|
|
|
|
sudo sed -i "s@:8000@$path@g" $final_path/ccnet/ccnet.conf
|
|
|
|
echo 'SERVE_STATIC = False' | sudo tee -a $final_path/seahub_settings.py
|
|
|
|
echo 'MEDIA_URL = "'$path'/media/"' | sudo tee -a $final_path/seahub_settings.py
|
|
|
|
echo 'SITE_ROOT = "'$path'/"' | sudo tee -a $final_path/seahub_settings.py
|
|
|
|
echo 'FILE_SERVER_ROOT = "http://'$domain$path'"' | sudo tee -a $final_path/seahub_settings.py
|
2014-08-07 04:42:27 +02:00
|
|
|
|
2014-08-12 03:18:09 +02:00
|
|
|
# Symlink for media ( because only $path is accessible, not /seahub )
|
|
|
|
sudo ln -s $final_path/seafile-server-$seafile_version/seahub/media/ $final_path/seafile-server-$seafile_version/seafile/media
|
2014-08-07 02:57:24 +02:00
|
|
|
|
2014-08-07 04:42:27 +02:00
|
|
|
# Add Seafile Server to startup
|
2014-08-12 03:18:09 +02:00
|
|
|
sed -i "s@SEAHUB_PORT@$seahub_port@g" ../conf/seafile-server
|
|
|
|
sed -i "s@SEAFILE_DIR@$final_path@g" ../conf/seafile-server
|
|
|
|
sudo cp ../conf/seafile-server /etc/init.d
|
|
|
|
sudo chmod +x /etc/init.d/seafile-server
|
|
|
|
sudo cp ../conf/seafile-server.conf /etc/init
|
|
|
|
sudo update-rc.d seafile-server defaults
|
2014-08-07 02:57:24 +02:00
|
|
|
|
2014-08-12 03:18:09 +02:00
|
|
|
# Start Seafile Server
|
|
|
|
sudo $final_path/seafile-server-$seafile_version/seafile.sh start
|
|
|
|
sudo $final_path/seafile-server-$seafile_version/seahub.sh start-fastcgi $seahub_port
|
2014-08-08 05:16:24 +02:00
|
|
|
|
2014-08-07 02:57:24 +02:00
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
2014-08-12 03:18:09 +02:00
|
|
|
sed -i "s@SEAHUB_PORT@$seahub_port@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@SEAFILE_FILESERVER_PORT@$seafile_fileserver_port@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@SEAFILE_PATH@$final_path@g" ../conf/nginx.conf
|
2014-08-07 02:57:24 +02:00
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf
|
|
|
|
|
|
|
|
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|