Commit 348d91c95f000c9cc79238e5701b8a8a07153e3a

Authored by Alexis Gavoty
1 parent 3eccc7aef2
Exists in master

Update install

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