1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/framagames_ynh.git synced 2024-09-03 18:36:28 +02:00
framagames_ynh/scripts/install
2015-06-18 22:47:52 +01:00

67 lines
1.7 KiB
Bash

#!/bin/bash
# Retrieve arguments
app=framagames
domain=$1
path=$2
is_public=$3
sudo yunohost app setting $app path -v $path
if [ $path = "/" ]
then
sitename="root"
else
# sitename == path without any "/"
sitename=$(echo $path | cut -d '/' -f 2)
# Removal of trailing /
# path can be null but not really an issue for the remaining commands
path=${path%/}
fi
final_path=/var/www/$app
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
sudo yunohost app setting $app final_path -v $final_path
#sudo yunohost app setting $app domain -v $domain
sudo yunohost app setting $app sitename -v $sitename
# Creation of folder
sudo rm -rf $final_path
sudo mkdir -p $final_path
# Copy of sources
sudo cp -a ../sources/* $final_path/
# Set permissions
sudo chmod 775 -R $final_path
sudo chown -hR www-data:www-data $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
sed -i "s@FOLDERTOCHANGE@$final_path/@g" ../conf/nginx.conf
sed -i "s@NAMETOCHANGE@$sitename@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$sitename.conf
sed -i "s@NAMETOCHANGE@$sitename@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf
# Make app public if necessary
sudo yunohost app setting $app is_public -v "$is_public"
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting $app skipped_uris -v "/"
fi
# Reload Nginx and regenerate SSOwat conf
sudo service php5-fpm restart
sudo service nginx reload
sudo yunohost app ssowatconf