Commit bd5efccb8976537b4774752809cc0d9dd64b9af6

Authored by Alexis Gavoty
1 parent 6bbc9b2100
Exists in master

Update install

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