Commit 9c13f89a77f6a39c565133ead23a251044d1dc64

Authored by Alexis Gavoty
1 parent 9a9e201d4a
Exists in master

Update install

Showing 1 changed file with 2 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 admin_passwd=$3 6 admin_passwd=$3
7 7
8 if [ "$admin_passwd" = "" ]; then 8 if [ "$admin_passwd" = "" ]; then
9 echo "Wrong password" 9 echo "Wrong password"
10 exit 1 10 exit 1
11 fi 11 fi
12 12
13 # Check domain/path availability 13 # Check domain/path availability
14 sudo yunohost app checkurl $domain$path -a owncloud 14 sudo yunohost app checkurl $domain$path -a owncloud
15 if [[ ! $? -eq 0 ]]; then 15 if [[ ! $? -eq 0 ]]; then
16 exit 1 16 exit 1
17 fi 17 fi
18 18
19 # Generate random password 19 # Generate random password
20 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') 20 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')
21 21
22 # Use 'owncloud' as database name and user 22 # Use 'owncloud' as database name and user
23 db_user=owncloud 23 db_user=owncloud
24 24
25 # Initialize database and store mysql password for upgrade 25 # Initialize database and store mysql password for upgrade
26 sudo yunohost app initdb $db_user -p $db_pwd 26 sudo yunohost app initdb $db_user -p $db_pwd
27 sudo yunohost app setting owncloud mysqlpwd -v $db_pwd 27 sudo yunohost app setting owncloud mysqlpwd -v $db_pwd
28 28
29 # Create owncloud user 29 # Create owncloud user
30 sudo useradd -d /var/www/owncloud owncloud 30 sudo useradd -d /var/www/owncloud owncloud
31 31
32 # Copy files to the right place 32 # Copy files to the right place
33 final_path=/var/www/owncloud 33 final_path=/var/www/owncloud
34 sudo mkdir -p $final_path 34 sudo mkdir -p $final_path
35 sudo cp -a ../sources/* $final_path 35 sudo cp -a ../sources/* $final_path
36 sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/owncloud.conf 36 sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/owncloud.conf
37 sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/owncloud.conf 37 sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/owncloud.conf
38 sudo cp ../conf/php-fpm.ini /etc/php5/fpm/conf.d/20-owncloud.ini 38 sudo cp ../conf/php-fpm.ini /etc/php5/fpm/conf.d/20-owncloud.ini
39 39
40 # Change variables in Owncloud configuration 40 # Change variables in Owncloud configuration
41 sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 41 sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
42 sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 42 sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
43 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 43 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
44 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/php5/fpm/pool.d/owncloud.conf 44 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/php5/fpm/pool.d/owncloud.conf
45 45
46 # Set permissions to owncloud directory and /home directories 46 # Set permissions to owncloud directory and /home directories
47 sudo chown -hR owncloud: $final_path 47 sudo chown -hR owncloud: $final_path
48 for i in $(ls /home) 48 for i in $(ls /home)
49 do 49 do
50 if [[ ! $i == yunohost.* ]]; 50 if [[ ! $i == yunohost.* ]];
51 then 51 then
52 sudo setfacl -m g:owncloud:rwx /home/$i 52 sudo setfacl -m g:owncloud:rwx /home/$i
53 fi 53 fi
54 done 54 done
55 55
56 # Reload Nginx and regenerate SSOwat conf 56 # Reload Nginx and regenerate SSOwat conf
57 sudo service php5-fpm restart 57 sudo service php5-fpm restart
58 sudo service nginx reload 58 sudo service nginx reload
59 sudo yunohost app setting owncloud skipped_uris -v "/" 59 sudo yunohost app setting owncloud unprotected_uris -v "/"
60 sudo yunohost app setting owncloud skipped_uris -v "/public.php"
60 sudo yunohost app ssowatconf 61 sudo yunohost app ssowatconf
61 62
62 # Owncloud installation via curl 63 # Owncloud installation via curl
63 echo "127.0.0.1 $domain #yunoowncloud" | sudo tee -a /etc/hosts 64 echo "127.0.0.1 $domain #yunoowncloud" | sudo tee -a /etc/hosts
64 sleep 1 65 sleep 1
65 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 66 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
66 67
67 # Check if the Mysql database is initialized & running 68 # Check if the Mysql database is initialized & running
68 sleep 5 69 sleep 5
69 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1 70 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
70 curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=user_ldap" -u "admin:$admin_passwd" 71 curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=user_ldap" -u "admin:$admin_passwd"
71 result=$? 72 result=$?
72 loop_number=1 73 loop_number=1
73 while [ $result != 0 ] && [ $loop_number -lt 5 ]; 74 while [ $result != 0 ] && [ $loop_number -lt 5 ];
74 do 75 do
75 sleep 5 76 sleep 5
76 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1 77 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
77 let result=$? 78 let result=$?
78 let loop_number++ 79 let loop_number++
79 done 80 done
80 81
81 sudo yunohost app setting owncloud skipped_uris -v "/public.php"
82 sudo yunohost app ssowatconf
83 mysql -u $db_user -p$db_pwd $db_user < ../conf/ldap_config.sql 82 mysql -u $db_user -p$db_pwd $db_user < ../conf/ldap_config.sql
84 83
85 # Remove temporary entry in /etc/hosts 84 # Remove temporary entry in /etc/hosts
86 sudo sed -i '/yunoowncloud/d' /etc/hosts 85 sudo sed -i '/yunoowncloud/d' /etc/hosts