2014-06-02 13:38:03 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2016-02-03 12:59:58 +01:00
|
|
|
|
app=linuxdash
|
|
|
|
|
|
2014-06-02 13:38:03 +02:00
|
|
|
|
# Retrieve arguments
|
|
|
|
|
domain=$1
|
|
|
|
|
path=$2
|
2016-02-03 16:30:57 +01:00
|
|
|
|
user=$3
|
2014-06-02 13:38:03 +02:00
|
|
|
|
|
|
|
|
|
# Check domain/path availability
|
2016-02-03 12:59:58 +01:00
|
|
|
|
sudo yunohost app checkurl $domain$path -a $app
|
2014-06-02 13:38:03 +02:00
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2016-02-03 16:41:20 +01:00
|
|
|
|
# Check port availability
|
|
|
|
|
sudo yunohost app checkport 8081
|
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2014-06-02 13:38:03 +02:00
|
|
|
|
# Copy files to the right place
|
2016-02-03 12:59:58 +01:00
|
|
|
|
final_path=/var/www/$app
|
2014-06-02 13:38:03 +02:00
|
|
|
|
sudo mkdir -p $final_path
|
|
|
|
|
sudo cp -a ../sources/* $final_path
|
|
|
|
|
|
2014-06-02 14:22:42 +02:00
|
|
|
|
# Set permissions
|
|
|
|
|
sudo chown -R www-data: $final_path
|
2014-06-02 13:38:03 +02:00
|
|
|
|
|
2016-02-03 16:23:33 +01:00
|
|
|
|
# Set as a service with supervisor
|
|
|
|
|
sudo apt-get -y -qq install supervisor
|
|
|
|
|
sudo cp ../conf/supervisor.conf /etc/supervisor/conf.d/$app.conf
|
|
|
|
|
sudo supervisorctl update
|
2016-02-03 16:32:56 +01:00
|
|
|
|
sudo supervisorctl start $app
|
2016-02-03 16:23:33 +01:00
|
|
|
|
|
2014-06-02 13:38:03 +02:00
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
2016-02-03 12:59:58 +01:00
|
|
|
|
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
2014-06-02 13:38:03 +02:00
|
|
|
|
sudo cp ../conf/nginx.conf $nginxconf
|
|
|
|
|
sudo chown root: $nginxconf
|
|
|
|
|
sudo chmod 600 $nginxconf
|
|
|
|
|
|
2016-02-03 16:48:44 +01:00
|
|
|
|
# Only give one user access to this app
|
2016-02-03 16:30:57 +01:00
|
|
|
|
sudo yunohost app removeaccess $app
|
|
|
|
|
sudo yunohost app addaccess $app -u $user
|
|
|
|
|
|
2016-02-03 12:59:58 +01:00
|
|
|
|
# Reload web server
|
2014-06-02 13:38:03 +02:00
|
|
|
|
sudo service nginx reload
|