1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/thelounge_ynh.git synced 2024-09-03 20:35:54 +02:00
thelounge_ynh/scripts/upgrade
2016-11-24 11:44:51 +01:00

55 lines
1.6 KiB
Bash

#!/bin/bash
set -e
# Retrieve arguments
domain=$(sudo yunohost app setting thelounge domain)
path=$(sudo yunohost app setting thelounge path)
is_public=$(sudo yunohost app setting thelounge is_public)
final_path=/var/www/thelounge
# Remove trailing "/" from the path
path=${path%/}
# HACK: Change the socket.io path in the sources
sed -i "s@PATHTOCHANGE@$path@g" ../sources/client/js/thelounge.js
# Copy files to the right place
sudo mkdir -p $final_path/.thelounge/users
sed -i "s@PATHTOCHANGE@$path/@g" ../conf/config.js
sudo cp ../conf/config.js $final_path/.thelounge/
sudo cp -a ../sources/* $final_path/
# Set permissions
sudo chown -hR thelounge $final_path
# Install dependencies
sudo su -c "cd $final_path && /usr/bin/npm install --production" thelounge
# 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/thelounge.conf
# Copy systemd service
sudo cp ../conf/systemd.service /etc/systemd/system/thelounge.service
# Add YunoHost service
sudo yunohost service add thelounge -l /var/log/syslog \
|| echo "Service already exist"
# Make app public if necessary
sudo yunohost app setting thelounge is_public -v "$is_public"
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting thelounge unprotected_uris -v "/"
fi
# Reload Nginx, thelounge and regenerate SSOwat conf
sudo service nginx reload
sudo systemctl enable thelounge
sudo systemctl restart thelounge || sudo systemctl start thelounge
sudo yunohost app ssowatconf