Commit a87b65ea93795c341dd67681813eb84844a1f5e9

Authored by Alexis Gavoty
1 parent 0f328c9443
Exists in master

Update install

Showing 1 changed file with 1 additions and 3 deletions Inline Diff

1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Retrieve arguments 3 # Retrieve arguments
4 domain=$1 4 domain=$1
5 path=$2 5 path=$2
6 user=$3 6 user=$3
7 7
8 # Check user parameter 8 # Check user parameter
9 ls /home | grep $user 9 ls /home | grep $user
10 if [[ ! $? -eq 0 ]]; then 10 if [[ ! $? -eq 0 ]]; then
11 echo "Wrong user" 11 echo "Wrong user"
12 exit 1 12 exit 1
13 fi 13 fi
14 sudo yunohost app setting owncloud admin_user -v $user 14 sudo yunohost app setting owncloud admin_user -v $user
15 15
16 # Check domain/path availability 16 # Check domain/path availability
17 sudo yunohost app checkurl $domain$path -a owncloud 17 sudo yunohost app checkurl $domain$path -a owncloud
18 if [[ ! $? -eq 0 ]]; then 18 if [[ ! $? -eq 0 ]]; then
19 exit 1 19 exit 1
20 fi 20 fi
21 21
22 # Install dependencies 22 # Install dependencies
23 sudo apt-get install acl smbclient -y -qq 23 sudo apt-get install acl smbclient -y -qq
24 24
25 # Generate random password 25 # Generate random password
26 db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') 26 db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
27 27
28 # Use 'owncloud' as database name and user 28 # Use 'owncloud' as database name and user
29 db_user=owncloud 29 db_user=owncloud
30 30
31 # Initialize database and store mysql password for upgrade 31 # Initialize database and store mysql password for upgrade
32 sudo yunohost app initdb $db_user -p $db_pwd 32 sudo yunohost app initdb $db_user -p $db_pwd
33 sudo yunohost app setting owncloud mysqlpwd -v $db_pwd 33 sudo yunohost app setting owncloud mysqlpwd -v $db_pwd
34 34
35 # Create owncloud user 35 # Create owncloud user
36 sudo useradd -d /var/www/owncloud owncloud 36 sudo useradd -d /var/www/owncloud owncloud
37 37
38 # Copy files to the right place 38 # Copy files to the right place
39 final_path=/var/www/owncloud 39 final_path=/var/www/owncloud
40 data_path=/home/yunohost.app/owncloud/data 40 data_path=/home/yunohost.app/owncloud/data
41 sudo mkdir -p $final_path 41 sudo mkdir -p $final_path
42 sudo mkdir -p $data_path 42 sudo mkdir -p $data_path
43 sudo cp -a ../sources/* $final_path 43 sudo cp -a ../sources/* $final_path
44 sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/owncloud.conf 44 sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/owncloud.conf
45 sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/owncloud.conf 45 sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/owncloud.conf
46 sudo cp ../conf/php-fpm.ini /etc/php5/fpm/conf.d/20-owncloud.ini 46 sudo cp ../conf/php-fpm.ini /etc/php5/fpm/conf.d/20-owncloud.ini
47 sudo cp ../conf/mount.json $data_path 47 sudo cp ../conf/mount.json $data_path
48 sudo chown -hR owncloud:www-data $final_path 48 sudo chown -hR owncloud:www-data $final_path
49 sudo chown -hR owncloud:www-data $data_path 49 sudo chown -hR owncloud:www-data $data_path
50 sudo chmod 755 /home/yunohost.app
50 sudo chmod -R 775 $final_path 51 sudo chmod -R 775 $final_path
51 sudo chmod -R 775 $data_path 52 sudo chmod -R 775 $data_path
52 53
53 # Change variables in Owncloud configuration 54 # Change variables in Owncloud configuration
54 sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 55 sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
55 sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 56 sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
56 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 57 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
57 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/php5/fpm/pool.d/owncloud.conf 58 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/php5/fpm/pool.d/owncloud.conf
58 59
59 # Set permissions to owncloud directories and /home directories + add Home external storage 60 # Set permissions to owncloud directories and /home directories + add Home external storage
60 for i in $(ls /home) 61 for i in $(ls /home)
61 do 62 do
62 if [[ ! $i == yunohost.* ]]; 63 if [[ ! $i == yunohost.* ]];
63 then 64 then
64 sudo setfacl -m g:owncloud:rwx /home/$i 65 sudo setfacl -m g:owncloud:rwx /home/$i
65 sudo mkdir $data_path/$i 66 sudo mkdir $data_path/$i
66 fi 67 fi
67 done 68 done
68 sudo chmod 755 /home/yunohost.app
69 sudo chown -hR owncloud: $final_path
70 sudo chown -hR owncloud: $data_path
71 69
72 # Reload Nginx and regenerate SSOwat conf 70 # Reload Nginx and regenerate SSOwat conf
73 sudo service php5-fpm restart 71 sudo service php5-fpm restart
74 sudo service nginx reload 72 sudo service nginx reload
75 sudo yunohost app setting owncloud skipped_uris -v "/" 73 sudo yunohost app setting owncloud skipped_uris -v "/"
76 sudo yunohost app ssowatconf 74 sudo yunohost app ssowatconf
77 75
78 # Owncloud installation via curl 76 # Owncloud installation via curl
79 echo "127.0.0.1 $domain #yunoowncloud" | sudo tee -a /etc/hosts 77 echo "127.0.0.1 $domain #yunoowncloud" | sudo tee -a /etc/hosts
80 sleep 1 78 sleep 1
81 curl -kL -X POST https://$domain$path/index.php --data "install=true&adminlogin=admin&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 79 curl -kL -X POST https://$domain$path/index.php --data "install=true&adminlogin=admin&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
82 80
83 # Enable plugins 81 # Enable plugins
84 sleep 5 82 sleep 5
85 curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=files_external" -u "admin:$db_pwd" > /dev/null 2>&1 83 curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=files_external" -u "admin:$db_pwd" > /dev/null 2>&1
86 curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=user_ldap" -u "admin:$db_pwd" > /dev/null 2>&1 84 curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=user_ldap" -u "admin:$db_pwd" > /dev/null 2>&1
87 85
88 # Check if the Mysql database is initialized & running 86 # Check if the Mysql database is initialized & running
89 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1 87 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
90 result=$? 88 result=$?
91 loop_number=1 89 loop_number=1
92 while [ $result != 0 ] && [ $loop_number -lt 5 ]; 90 while [ $result != 0 ] && [ $loop_number -lt 5 ];
93 do 91 do
94 sleep 5 92 sleep 5
95 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1 93 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
96 let result=$? 94 let result=$?
97 if [ $loop_number -eq 4 ]; 95 if [ $loop_number -eq 4 ];
98 then 96 then
99 print "Web installation failed" 97 print "Web installation failed"
100 exit 1 98 exit 1
101 fi 99 fi
102 let loop_number++ 100 let loop_number++
103 done 101 done
104 102
105 # Configure LDAP plugin 103 # Configure LDAP plugin
106 mysql -u $db_user -p$db_pwd $db_user < ../conf/ldap_config.sql 104 mysql -u $db_user -p$db_pwd $db_user < ../conf/ldap_config.sql
107 105
108 # Make an LDAP user as admin 106 # Make an LDAP user as admin
109 mysql -u $db_user -p$db_pwd $db_user -e "INSERT INTO oc_group_user VALUES ('admin','$user');" 107 mysql -u $db_user -p$db_pwd $db_user -e "INSERT INTO oc_group_user VALUES ('admin','$user');"
110 108
111 # Unprotect URIs 109 # Unprotect URIs
112 sudo yunohost app setting owncloud skipped_uris -v "/public.php,/core,/apps/files,/index.php/apps/files" 110 sudo yunohost app setting owncloud skipped_uris -v "/public.php,/core,/apps/files,/index.php/apps/files"
113 sudo yunohost app setting owncloud unprotected_uris -v "/remote.php,/cron.php,/status.php" 111 sudo yunohost app setting owncloud unprotected_uris -v "/remote.php,/cron.php,/status.php"
114 sudo yunohost app ssowatconf 112 sudo yunohost app ssowatconf
115 113
116 # Remove temporary entry in /etc/hosts 114 # Remove temporary entry in /etc/hosts
117 sudo sed -i '/yunoowncloud/d' /etc/hosts 115 sudo sed -i '/yunoowncloud/d' /etc/hosts