mirror of
https://github.com/YunoHost-Apps/pydio_ynh.git
synced 2024-09-03 20:16:05 +02:00
102 lines
3.2 KiB
Bash
102 lines
3.2 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$1
|
|
path=$2
|
|
admin=$3
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a pydio
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
# Check that admin user is an existing account
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
|
if [[ ! $? -eq 0 ]]; then
|
|
echo "Error : the chosen admin user does not exist"
|
|
exit 1
|
|
fi
|
|
|
|
# Install dependencies
|
|
sudo apt-get install acl -y -qq
|
|
|
|
mkdir ../upstream
|
|
version=$(cat version)
|
|
wget -O ../upstream/pydio-core.tar.gz http://sourceforge.net/projects/ajaxplorer/files/pydio/dev-channel/$version/pydio-core-$version.tar.gz
|
|
tar xzf ../upstream/pydio-core.tar.gz -C ../upstream
|
|
|
|
# Copy files to the right place
|
|
final_path=/var/www/pydio
|
|
data_path=/home/yunohost.app/pydio
|
|
|
|
# Create owncloud user
|
|
sudo useradd -d /var/www/pydio pydio
|
|
|
|
sudo mkdir -p $final_path
|
|
sudo cp -ar ../upstream/pydio-core-$version/* $final_path
|
|
|
|
sudo mkdir -p $data_path
|
|
sudo mv $final_path/data $data_path
|
|
|
|
# Database
|
|
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')
|
|
db_user=pydio
|
|
sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../conf/create.mysql)
|
|
sudo yunohost app setting pydio mysqlpwd -v $db_pwd
|
|
|
|
sudo cp ../conf/bootstrap_context.php $final_path/conf
|
|
sudo cp ../conf/bootstrap_repositories.php $final_path/conf
|
|
|
|
sed -i "s@YNH_MYSQL_PWD@$db_pwd@g" ../conf/bootstrap.json
|
|
sed -i "s@YNH_ADMIN@$admin@g" ../conf/bootstrap.json
|
|
sudo mkdir -p $data_path/data/plugins/boot.conf
|
|
sudo cp ../conf/bootstrap.json $data_path/data/plugins/boot.conf/bootstrap.json
|
|
sudo yunohost app setting pydio admin -v $admin
|
|
|
|
sudo touch $data_path/data/cache/admin_counted
|
|
sudo touch $data_path/data/cache/first_run_passed
|
|
sudo touch $data_path/data/cache/diag_result.php
|
|
|
|
# let's rename the "Common Files" repository mount to common_files
|
|
# also, "files" mount is useless now since we map to /home/AJXP_USER directly
|
|
sudo mkdir -p $data_path/data/common_files
|
|
sudo rm -rf $data_path/data/{files,personal}
|
|
|
|
# Fix up permissions
|
|
sudo chown -R root: $final_path
|
|
sudo find $final_path -type f -exec chmod 644 {} \;
|
|
sudo find $final_path -type d -exec chmod 755 {} \;
|
|
|
|
sudo chown -R pydio:pydio $data_path
|
|
sudo find $data_path/data -type f -exec chmod 660 {} \;
|
|
sudo find $data_path/data -type d -exec chmod 770 {} \;
|
|
|
|
# Allow pydio to access user's home
|
|
for i in $(ls /home)
|
|
do
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$i\""
|
|
if [[ $? -eq 0 ]];
|
|
then
|
|
sudo setfacl -m g:pydio:rwx /home/$i
|
|
fi
|
|
done
|
|
|
|
sed -i "s@NAMETOCHANGE@pydio@g" ../conf/php-fpm.conf
|
|
finalphpconf=/etc/php5/fpm/pool.d/pydio.conf
|
|
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
sudo chown root: $finalphpconf
|
|
sudo chmod 644 $finalphpconf
|
|
|
|
# Nginx configuration
|
|
sed -i "s@NAMETOCHANGE@pydio@g" ../conf/nginx.conf
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
|
sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/nginx.conf
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/pydio.conf
|
|
sudo chown root: /etc/nginx/conf.d/$domain.d/pydio.conf
|
|
sudo chmod 600 /etc/nginx/conf.d/$domain.d/pydio.conf
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
sudo service php5-fpm restart
|
|
sudo service nginx reload
|
|
sudo yunohost app ssowatconf
|