Commit 035b88fdeb706a49fa2a7affdef397e05e50e2d6

Authored by Kload
1 parent 8173dbb68d
Exists in master

Try local external sharing (yo dawg)

Showing 3 changed files with 36 additions and 17 deletions Side-by-side Diff

conf/ldap_config.sql
... ... @@ -12,11 +12,11 @@ INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'l
12 12 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember');
13 13 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_login_filter', 'uid=%uid');
14 14 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_quota_attr', 'mailQuota');
15   -INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_quota_def', '500MB');
  15 +INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_quota_def', '');
16 16 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_email_attr', 'mail');
17 17 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_cache_ttl', '600');
18 18 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_configuration_active', '1');
19   -INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'home_folder_naming_rule', 'attr:homeDirectory');
  19 +INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'home_folder_naming_rule', '');
20 20 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_backup_host', '');
21 21 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_dn', '');
22 22 INSERT INTO oc_appconfig (appid, configkey, configvalue) VALUES ('user_ldap', 'ldap_agent_password', '');
... ... @@ -29,10 +29,11 @@
29 29 "default": "/owncloud"
30 30 },
31 31 {
32   - "name": "admin_passwd",
  32 + "name": "admin",
33 33 "ask": {
34   - "en": "Choose a password for Owncloud administrator"
35   - }
  34 + "en": "Choose the Owncloud administrator (must be an existing YunoHost user)",
  35 + },
  36 + "example": "homer"
36 37 }
37 38 ]
38 39 }
... ... @@ -3,10 +3,12 @@
3 3 # Retrieve arguments
4 4 domain=$1
5 5 path=$2
6   -admin_passwd=$3
  6 +user=$3
7 7  
8   -if [ "$admin_passwd" = "" ]; then
9   - echo "Wrong password"
  8 +# Check user parameter
  9 +ls /home | grep $user
  10 +if [[ ! $? -eq 0 ]]; then
  11 + echo "Wrong user"
10 12 exit 1
11 13 fi
12 14  
... ... @@ -34,7 +36,9 @@ sudo useradd -d /var/www/owncloud owncloud
34 36  
35 37 # Copy files to the right place
36 38 final_path=/var/www/owncloud
  39 +data_path=/home/yunohost.app/owncloud/data
37 40 sudo mkdir -p $final_path
  41 +sudo mkdir -p $data_path
38 42 sudo cp -a ../sources/* $final_path
39 43 sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/owncloud.conf
40 44 sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/owncloud.conf
... ... @@ -46,15 +50,18 @@ sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/ownclou
46 50 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
47 51 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/php5/fpm/pool.d/owncloud.conf
48 52  
49   -# Set permissions to owncloud directory and /home directories
50   -sudo chown -hR owncloud: $final_path
  53 +# Set permissions to owncloud directories and /home directories + add Home external storage
51 54 for i in $(ls /home)
52 55 do
53 56 if [[ ! $i == yunohost.* ]];
54 57 then
55 58 sudo setfacl -m g:owncloud:rwx /home/$i
  59 + mkdir $data_path/$i
  60 + echo "{\"user\":{\"$i\":{\"/\$user/files/Home\":{\"class\":\"\\OC\\Files\\Storage\\Local\",\"options\":{\"datadir\":\"/home/$i\"}}}}}" > $data_path/$i/mount.json
56 61 fi
57 62 done
  63 +sudo chown -hR owncloud: $final_path
  64 +sudo chown -hR owncloud: $data_path
58 65  
59 66 # Reload Nginx and regenerate SSOwat conf
60 67 sudo service php5-fpm restart
... ... @@ -65,23 +72,34 @@ sudo yunohost app ssowatconf
65 72 # Owncloud installation via curl
66 73 echo "127.0.0.1 $domain #yunoowncloud" | sudo tee -a /etc/hosts
67 74 sleep 1
68   -curl -kL -X POST https://$domain$path/index.php --data "install=true&adminlogin=admin&adminpass=$admin_passwd&directory=/var/www/owncloud/data&dbtype=mysql&dbuser=$db_user&dbpass=$db_pwd&dbname=$db_user&dbhost=localhost" > /dev/null 2>&1
  75 +curl -kL -X POST https://$domain$path/index.php --data "install=true&adminlogin=$user&adminpass=$db_pwd&directory=/home/yunohost.app/owncloud/data&dbtype=mysql&dbuser=$db_user&dbpass=$db_pwd&dbname=$db_user&dbhost=localhost" > /dev/null 2>&1
69 76  
70   -# Check if the Mysql database is initialized & running
  77 +# Enable plugins
71 78 sleep 5
  79 +curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=files_external" -u "$user:$db_pwd" > /dev/null 2>&1
  80 +curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=user_ldap" -u "$user:$db_pwd" > /dev/null 2>&1
  81 +
  82 +# Check if the Mysql database is initialized & running
72 83 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
73   -curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=user_ldap" -u "admin:$admin_passwd" > /dev/null 2>&1
74 84 result=$?
75 85 loop_number=1
76 86 while [ $result != 0 ] && [ $loop_number -lt 5 ];
77 87 do
78   - sleep 5
79   - mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
80   - let result=$?
81   - let loop_number++
  88 + sleep 5
  89 + mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
  90 + let result=$?
  91 + if [ $loop_number -eq 4 ];
  92 + then
  93 + print "Web installation failed"
  94 + exit 1
  95 + fi
  96 + let loop_number++
82 97 done
83 98  
  99 +# Configure LDAP plugin
84 100 mysql -u $db_user -p$db_pwd $db_user < ../conf/ldap_config.sql
  101 +
  102 +# Unprotect URIs
85 103 sudo yunohost app setting owncloud skipped_uris -v "/public.php,/core,/apps/files,/index.php/apps/files"
86 104 sudo yunohost app setting owncloud unprotected_uris -v "/remote.php,/cron.php,/status.php"
87 105 sudo yunohost app ssowatconf