Blame view

scripts/install 2.51 KB
03e52840d   Kload   Init
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
  #!/bin/bash
  
  # Retrieve arguments
  domain=$1
  path=$2
  admin_passwd=$3
  
  # Check domain/path availability
  sudo yunohost app checkurl $domain$path -a owncloud
  if [[ ! $? -eq 0 ]]; then
      exit 1
  fi
  
  # 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
  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
  
  # 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 -R owncloud: $final_path
  for i in $(ls /home)
  do
      if [[ ! $i == yunohost.* ]];
      then
          setfacl -m g:owncloud:rwx /home/$i
      fi
  done
  
  # Reload Nginx and regenerate SSOwat conf
82d689175   Alexis Gavoty   Update install
51
  sudo service php5-fpm restart
03e52840d   Kload   Init
52
  sudo service nginx reload
82d689175   Alexis Gavoty   Update install
53
  sudo yunohost app setting owncloud skipped_uris -v "/"
03e52840d   Kload   Init
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  sudo yunohost app ssowatconf
  
  # Owncloud installation via curl
  echo "127.0.0.1 $domain #yunoowncloud" | sudo tee -a /etc/hosts
  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"
  
  # 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
  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
  
  sudo yunohost app setting owncloud skipped_uris -v "/public.php"
  sudo yunohost app ssowatconf
82d689175   Alexis Gavoty   Update install
75
  mysql -u $db_user -p$db_pwd $db_user < ../conf/ldap_config.sql
03e52840d   Kload   Init
76
77
78
  
  # Remove temporary entry in /etc/hosts
  sudo sed -i '/yunoowncloud/d' /etc/hosts