2014-01-13 13:50:38 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
2014-01-13 21:36:14 +01:00
|
|
|
admin_user=$3
|
|
|
|
upload_password=$4
|
|
|
|
is_public=$5
|
2014-01-13 13:50:38 +01:00
|
|
|
|
|
|
|
# Check domain/path availability
|
|
|
|
sudo yunohost app checkurl $domain$path -a jirafeau
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-03-07 01:15:09 +01:00
|
|
|
# Check that admin user is an existing account
|
2014-05-29 12:06:12 +02:00
|
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$admin_user\""
|
2014-01-13 21:36:14 +01:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
echo "Error : the chosen admin user does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-03-07 01:37:15 +01:00
|
|
|
# Save specific settings
|
|
|
|
sudo yunohost app setting jirafeau admin_user -v $admin_user
|
|
|
|
sudo yunohost app setting jirafeau upload_password -v $upload_password
|
|
|
|
sudo yunohost app setting jirafeau is_public -v $is_public
|
2014-01-13 13:50:38 +01:00
|
|
|
|
|
|
|
# Copy files to the right place
|
2014-03-07 01:37:15 +01:00
|
|
|
final_path=/var/www/jirafeau
|
|
|
|
var_root=/home/yunohost.app/jirafeau
|
2014-01-13 13:50:38 +01:00
|
|
|
sudo mkdir -p $final_path
|
|
|
|
sudo cp -r ../sources/* $final_path
|
|
|
|
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.local.php
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/config.local.php
|
|
|
|
sed -i "s@YNH_VAR_ROOT@$var_root@g" ../conf/config.local.php
|
2014-01-13 21:36:14 +01:00
|
|
|
sed -i "s@YNH_ADMIN_USER@$admin_user@g" ../conf/config.local.php
|
|
|
|
sed -i "s@YNH_UPLOAD_PASSWORD@$upload_password@g" ../conf/config.local.php
|
2014-01-13 13:50:38 +01:00
|
|
|
sudo cp ../conf/config.local.php $final_path/lib
|
|
|
|
sudo rm $final_path/install.php
|
|
|
|
|
|
|
|
# Files owned by root, www-data can just read
|
|
|
|
sudo find $final_path -type f | xargs sudo chmod 644
|
|
|
|
sudo find $final_path -type d | xargs sudo chmod 755
|
|
|
|
sudo chown -R root: $final_path
|
|
|
|
|
|
|
|
sudo mkdir -p $var_root/{files,links,async,block}
|
|
|
|
sudo chown -R www-data:root $var_root
|
|
|
|
sudo chmod -R 700 $var_root
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
2014-01-13 15:37:49 +01:00
|
|
|
nginxconf=/etc/nginx/conf.d/$domain.d/jirafeau.conf
|
|
|
|
sudo cp ../conf/nginx.conf $nginxconf
|
|
|
|
sudo chown root: $nginxconf
|
|
|
|
sudo chmod 600 $nginxconf
|
2014-01-13 13:50:38 +01:00
|
|
|
|
|
|
|
sed -i "s@NAMETOCHANGE@jirafeau@g" ../conf/php-fpm.conf
|
2014-01-13 15:37:49 +01:00
|
|
|
finalphpconf=/etc/php5/fpm/pool.d/jirafeau.conf
|
|
|
|
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
|
|
sudo chown root: $finalphpconf
|
|
|
|
sudo chmod 644 $finalphpconf
|
|
|
|
|
|
|
|
finalphpini=/etc/php5/fpm/conf.d/20-jirafeau.ini
|
|
|
|
sudo cp ../conf/php-fpm.ini $finalphpini
|
|
|
|
sudo chown root: $finalphpini
|
|
|
|
sudo chmod 644 $finalphpini
|
2014-01-13 13:50:38 +01:00
|
|
|
|
|
|
|
if [ $is_public = "Yes" ];
|
|
|
|
then
|
2014-01-13 21:36:14 +01:00
|
|
|
sudo yunohost app setting jirafeau unprotected_uris -v "/"
|
2014-01-13 13:50:38 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
sudo service php5-fpm restart
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|