From 32cb33d5531565ae7cf0aacf355cb48dbef743df Mon Sep 17 00:00:00 2001 From: Elie Date: Tue, 12 Aug 2014 21:21:47 -0400 Subject: [PATCH] Ldap config Former-commit-id: cb3c99de608bb14b5ed61676b8096118ed5124a5 --- conf/nginx.conf | 5 ++++- manifest.json | 16 ++++------------ scripts/install | 26 +++++++++++++++++++++++--- scripts/remove | 5 ++++- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b4307ad..5b39173 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -5,11 +5,12 @@ location PATHTOCHANGE { } client_max_body_size 10G; - fastcgi_pass 127.0.0.1:SEAHUB_PORT; + include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; + fastcgi_param REMOTE_USER $remote_user; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; @@ -20,6 +21,8 @@ location PATHTOCHANGE { fastcgi_param SERVER_NAME $server_name; fastcgi_param HTTPS on; + access_log /var/log/nginx/seahub.access.log; + error_log /var/log/nginx/seahub.error.log; } location ~* ^PATHTOCHANGE/media/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt|woff|ttf))$ { diff --git a/manifest.json b/manifest.json index d93b1aa..474d5ab 100644 --- a/manifest.json +++ b/manifest.json @@ -38,20 +38,12 @@ "default": "Seafile" }, { - "name": "admin_email", + "name": "admin", "ask": { - "en": "Choose an email" + "en": "Choose a user" }, - "example": "admin@domain.com", - "default": "admin@domain.com" - }, - { - "name": "admin_password", - "ask": { - "en": "Choose a password" - }, - "example": "123456", - "default": "123456" + "example": "homer", + "default": "elie" } ] } diff --git a/scripts/install b/scripts/install index 154b5b2..efd842c 100644 --- a/scripts/install +++ b/scripts/install @@ -2,8 +2,8 @@ domain=$1 path=$2 server_name=$3 -admin_email=$4 -admin_password=$5 +admin=$4 +admin_password=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') final_path=/var/www/seafile seafile_data=$final_path/seafile-data seafile_version=3.1.1 @@ -14,6 +14,14 @@ if [[ ! $? -eq 0 ]]; then exit 1 fi +# Check if admin exists +sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" +if [[ ! $? -eq 0 ]]; then + echo "Wrong admin" + exit 1 +fi +sudo yunohost app setting seafile admin -v $admin + # Check dependencies sudo apt-get install -y python2.7 python-setuptools python-simplejson python-imaging python-mysqldb sqlite3 @@ -48,7 +56,7 @@ 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 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_EMAIL/$admin/g" ../sources/check_init_admin.py sed -i "s/ADMIN_PASSWORD/$admin_password/g" ../sources/check_init_admin.py # Run install script @@ -64,6 +72,13 @@ 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 +# 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 +echo 'LOGIN_ATTR = uid' | sudo tee -a $final_path/ccnet/ccnet.conf + + # 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 @@ -91,3 +106,8 @@ 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 + + +# Open port +#sudo yunohost firewall allow $ccnet_port +#sudo yunohost firewall allow $seafile_port diff --git a/scripts/remove b/scripts/remove index 8d26573..f3ef6ac 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,4 +8,7 @@ sudo ./seahub.sh stop sudo rm -rf /var/www/seafile sudo rm -f /etc/nginx/conf.d/$domain.d/seafile.conf sudo rm -f /etc/init.d/seafile-server -sudo rm -f /etc/init/seafile-server.conf \ No newline at end of file +sudo rm -f /etc/init/seafile-server.conf + +#sudo yunohost firewall deny $ccnet_port +#sudo yunohost firewall deny $seafile_port