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