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-15 02:22:39 +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
|
|
|
|
2014-08-15 02:22:39 +02:00
|
|
|
port=''
|
|
|
|
findPort () {
|
|
|
|
|
|
|
|
port=$1
|
|
|
|
|
|
|
|
sudo yunohost app checkport $port
|
|
|
|
while [[ ! $? -eq 0 ]]
|
|
|
|
do
|
|
|
|
port=$(($port + 1))
|
|
|
|
sudo yunohost app checkport $port
|
|
|
|
done
|
|
|
|
|
|
|
|
return $port
|
|
|
|
}
|
|
|
|
|
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
|
2014-08-15 02:22:39 +02:00
|
|
|
findPort 10001
|
|
|
|
ccnet_port=$port
|
|
|
|
findPort 12001
|
|
|
|
seafile_port=$port
|
|
|
|
findPort 8082
|
|
|
|
seafile_fileserver_port=$port
|
|
|
|
findPort 8000
|
|
|
|
seahub_port=$port
|
|
|
|
|
|
|
|
sudo yunohost app setting seafile ccnet_port -v $ccnet_port
|
|
|
|
sudo yunohost app setting seafile seafile_port -v $seafile_port
|
|
|
|
sudo yunohost app setting seafile seafile_fileserver_port -v $seafile_fileserver_port
|
|
|
|
sudo yunohost app setting seafile seahub_port -v $seahub_port
|
2014-08-12 03:18:09 +02:00
|
|
|
|
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
|
2014-08-15 02:22:39 +02:00
|
|
|
sed -i "s/ADMIN_EMAIL/$admin_email/g" ../sources/check_init_admin.py
|
2014-08-12 03:18:09 +02:00
|
|
|
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-13 05:14:22 +02:00
|
|
|
|
2014-08-13 03:21:47 +02:00
|
|
|
# LDAP configuration
|
|
|
|
echo '[LDAP]' | sudo tee -a $final_path/ccnet/ccnet.conf
|
|
|
|
echo 'HOST = ldap://localhost:389' | sudo tee -a $final_path/ccnet/ccnet.conf
|
|
|
|
echo 'BASE = ou=users,dc=yunohost,dc=org' | sudo tee -a $final_path/ccnet/ccnet.conf
|
2014-08-15 02:22:39 +02:00
|
|
|
echo 'LOGIN_ATTR = mail' | sudo tee -a $final_path/ccnet/ccnet.conf
|
2014-08-13 03:21:47 +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
|
2014-08-13 03:21:47 +02:00
|
|
|
|
|
|
|
# Open port
|
2014-08-15 02:22:39 +02:00
|
|
|
sudo yunohost firewall allow $ccnet_port
|
|
|
|
sudo yunohost firewall allow $seafile_port
|
|
|
|
sudo yunohost firewall allow $seahub_port
|
|
|
|
|
|
|
|
|