2015-08-22 20:24:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$(sudo yunohost app setting shout domain)
|
|
|
|
path=$(sudo yunohost app setting shout path)
|
|
|
|
is_public=$(sudo yunohost app setting shout is_public)
|
|
|
|
final_path=/var/www/shout
|
|
|
|
|
|
|
|
# Remove trailing "/" from the path
|
|
|
|
path=${path%/}
|
|
|
|
|
2015-08-22 22:22:45 +02:00
|
|
|
# HACK: Change the socket.io path in the sources
|
|
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../sources/client/js/shout.js
|
|
|
|
|
2015-08-22 20:24:46 +02:00
|
|
|
# Copy files to the right place
|
|
|
|
sudo mkdir -p $final_path/.shout/users
|
2015-08-22 21:46:26 +02:00
|
|
|
sed -i "s@PATHTOCHANGE@$path/@g" ../conf/config.js
|
|
|
|
sudo cp ../conf/config.js $final_path/.shout/
|
2015-08-22 20:24:46 +02:00
|
|
|
sudo cp -a ../sources/* $final_path/
|
|
|
|
|
|
|
|
# Set permissions
|
|
|
|
sudo chown -hR shout $final_path
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
sudo su -c "cd $final_path && /usr/bin/npm install --production" shout
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
if [[ "$path" == "" ]]; then
|
|
|
|
sed -i "s@LOCATIONTOCHANGE@/@g" ../conf/nginx.conf
|
|
|
|
else
|
|
|
|
sed -i "s@LOCATIONTOCHANGE@$path@g" ../conf/nginx.conf
|
|
|
|
fi
|
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/shout.conf
|
|
|
|
|
|
|
|
# Copy systemd service
|
|
|
|
sudo cp ../conf/systemd.service /etc/systemd/system/shout.service
|
|
|
|
|
|
|
|
# Add YunoHost service
|
|
|
|
sudo yunohost service add shout -l /var/log/syslog \
|
|
|
|
|| echo "Service already exist"
|
|
|
|
|
|
|
|
# Make app public if necessary
|
|
|
|
sudo yunohost app setting shout is_public -v "$is_public"
|
|
|
|
if [ "$is_public" = "Yes" ];
|
|
|
|
then
|
|
|
|
sudo yunohost app setting shout unprotected_uris -v "/"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Reload Nginx, shout and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo systemctl enable shout
|
2015-08-22 22:44:49 +02:00
|
|
|
sudo systemctl restart shout || sudo systemctl start shout
|
2015-08-22 20:24:46 +02:00
|
|
|
sudo yunohost app ssowatconf
|