Commit 2716cff3441f336ef0878d45d9189b484f34a425

Authored by Alexis Gavoty
1 parent d98caeab8a
Exists in master

Update install

Showing 1 changed file with 1 additions and 0 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 38
39 # Change variables in Owncloud configuration 39 # Change variables in Owncloud configuration
40 sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 40 sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
41 sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 41 sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
42 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/nginx/conf.d/$domain.d/owncloud.conf 42 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/nginx/conf.d/$domain.d/owncloud.conf
43 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/php5/fpm/pool.d/owncloud.conf 43 sudo sed -i "s@NAMETOCHANGE@owncloud@g" /etc/php5/fpm/pool.d/owncloud.conf
44 44
45 # Set permissions to owncloud directory and /home directories 45 # Set permissions to owncloud directory and /home directories
46 sudo chown -hR owncloud: $final_path 46 sudo chown -hR owncloud: $final_path
47 for i in $(ls /home) 47 for i in $(ls /home)
48 do 48 do
49 if [[ ! $i == yunohost.* ]]; 49 if [[ ! $i == yunohost.* ]];
50 then 50 then
51 sudo setfacl -m g:owncloud:rwx /home/$i 51 sudo setfacl -m g:owncloud:rwx /home/$i
52 fi 52 fi
53 done 53 done
54 54
55 # Reload Nginx and regenerate SSOwat conf 55 # Reload Nginx and regenerate SSOwat conf
56 sudo service php5-fpm restart 56 sudo service php5-fpm restart
57 sudo service nginx reload 57 sudo service nginx reload
58 sudo yunohost app setting owncloud skipped_uris -v "/" 58 sudo yunohost app setting owncloud skipped_uris -v "/"
59 sudo yunohost app ssowatconf 59 sudo yunohost app ssowatconf
60 60
61 # Owncloud installation via curl 61 # Owncloud installation via curl
62 echo "127.0.0.1 $domain #yunoowncloud" | sudo tee -a /etc/hosts 62 echo "127.0.0.1 $domain #yunoowncloud" | sudo tee -a /etc/hosts
63 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 63 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
64 64
65 # Check if the Mysql database is initialized & running 65 # Check if the Mysql database is initialized & running
66 sleep 5 66 sleep 5
67 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1 67 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
68 curl -kL -X POST https://$domain$path/index.php/settings/ajax/enableapp.php --data "appid=user_ldap" -u "admin:$admin_passwd"
68 result=$? 69 result=$?
69 loop_number=1 70 loop_number=1
70 while [ $result != 0 ] && [ $loop_number -lt 5 ]; 71 while [ $result != 0 ] && [ $loop_number -lt 5 ];
71 do 72 do
72 sleep 5 73 sleep 5
73 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1 74 mysql -u $db_user -p$db_pwd $db_user -e "select * from oc_appconfig;" > /dev/null 2>&1
74 let result=$? 75 let result=$?
75 let loop_number++ 76 let loop_number++
76 done 77 done
77 78
78 sudo yunohost app setting owncloud skipped_uris -v "/public.php" 79 sudo yunohost app setting owncloud skipped_uris -v "/public.php"
79 sudo yunohost app ssowatconf 80 sudo yunohost app ssowatconf
80 mysql -u $db_user -p$db_pwd $db_user < ../conf/ldap_config.sql 81 mysql -u $db_user -p$db_pwd $db_user < ../conf/ldap_config.sql
81 82
82 # Remove temporary entry in /etc/hosts 83 # Remove temporary entry in /etc/hosts
83 sudo sed -i '/yunoowncloud/d' /etc/hosts 84 sudo sed -i '/yunoowncloud/d' /etc/hosts
84 85