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

55 lines
1.6 KiB
Bash

#!/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%/}
# HACK: Change the socket.io path in the sources
sed -i "s@PATHTOCHANGE@$path@g" ../sources/client/js/shout.js
# Copy files to the right place
sudo mkdir -p $final_path/.shout/users
sed -i "s@PATHTOCHANGE@$path/@g" ../conf/config.js
sudo cp ../conf/config.js $final_path/.shout/
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
sudo systemctl restart shout || sudo systemctl start shout
sudo yunohost app ssowatconf