2014-11-12 22:22:53 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
app=pluxml
|
|
|
|
|
|
|
|
#retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
|
|
|
admin=$3
|
2014-11-13 21:54:54 +01:00
|
|
|
password=$4
|
|
|
|
is_public=$5
|
2014-11-13 22:06:51 +01:00
|
|
|
default_lang=$6
|
2014-11-12 22:22:53 +01:00
|
|
|
|
|
|
|
# Check domain/path availability
|
|
|
|
sudo yunohost app checkurl $domain$path -a $app
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2014-11-17 14:04:17 +01:00
|
|
|
exit 1
|
2014-11-12 22:22:53 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check user
|
|
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2014-11-17 14:04:17 +01:00
|
|
|
echo "Wrong user"
|
|
|
|
exit 1
|
2014-11-12 22:22:53 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Save app settings
|
|
|
|
sudo yunohost app setting $app admin -v "$admin"
|
|
|
|
sudo yunohost app setting $app is_public -v "$is_public"
|
2014-11-12 22:42:09 +01:00
|
|
|
sudo yunohost app setting $app domain -v "$domain"
|
|
|
|
sudo yunohost app setting $app path -v "$path"
|
2014-11-12 22:22:53 +01:00
|
|
|
|
|
|
|
#create path for copying
|
|
|
|
final_path=/var/www/$app
|
|
|
|
sudo mkdir -p $final_path
|
|
|
|
|
|
|
|
#copy files to final folder and set permissions
|
2014-11-12 22:42:09 +01:00
|
|
|
sudo cp -R ../sources/* $final_path/
|
2014-11-17 14:14:56 +01:00
|
|
|
sudo chown -R root: $final_path
|
|
|
|
sudo chown -R www-data: $final_path/data
|
|
|
|
sudo find $final_path -type f | xargs sudo chmod 644
|
|
|
|
sudo find $final_path -type d | xargs sudo chmod 755
|
2014-11-12 22:22:53 +01:00
|
|
|
|
|
|
|
#configure nginx settings
|
|
|
|
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
|
2014-11-12 22:29:05 +01:00
|
|
|
sudo sed -i "s@YNH_EXAMPLE_ALIAS@$final_path@g" ../conf/nginx.conf
|
2014-11-12 22:22:53 +01:00
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
|
2014-11-13 19:34:55 +01:00
|
|
|
#temporal set public acessible
|
2014-11-12 22:42:09 +01:00
|
|
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
2014-11-13 19:34:55 +01:00
|
|
|
|
2014-11-13 21:50:18 +01:00
|
|
|
# Restart services
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|
|
|
|
|
2014-11-13 19:34:55 +01:00
|
|
|
#make request to install app
|
2014-11-12 22:42:09 +01:00
|
|
|
#get the html page
|
2014-11-13 22:19:08 +01:00
|
|
|
sudo curl -kL -o install_page.html https://$domain/$path/install.php >/dev/null 2>&1
|
2014-11-12 22:42:09 +01:00
|
|
|
#get the token for form validation
|
2014-11-13 22:19:08 +01:00
|
|
|
token=$(sudo cat install_page.html | grep "input" | grep "token" | tail -1 | cut -d' ' -f3 | cut -d'"' -f2)
|
2014-11-12 22:42:09 +01:00
|
|
|
#send http POST values
|
2014-11-13 22:19:08 +01:00
|
|
|
sudo curl -k -X POST --data "default_lang=$default_lang&install=Installer&name=$admin&login=$admin&pwd=$password&pwd2=$password&token=$token" https://$domain/$path/install.php >/dev/null 2>&1
|
2014-11-13 19:34:55 +01:00
|
|
|
|
|
|
|
# If app is private, remove url to SSOWat conf from skipped_uris
|
|
|
|
if [ "$is_public" = "No" ];
|
|
|
|
then
|
2014-11-17 14:04:17 +01:00
|
|
|
sudo yunohost app setting $app unprotected_uris -d
|
2014-11-12 22:22:53 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
#adding admin to the allowed users
|
2014-11-12 22:26:17 +01:00
|
|
|
sudo yunohost app addaccess $app -u $admin
|
2014-11-12 22:22:53 +01:00
|
|
|
|
2014-11-13 21:58:38 +01:00
|
|
|
sudo rm -f $final_path/install.php
|
2014-11-12 22:22:53 +01:00
|
|
|
# Restart services
|
|
|
|
sudo service nginx reload
|
2014-11-17 13:56:51 +01:00
|
|
|
sudo yunohost app ssowatconf
|