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

56 lines
1.6 KiB
Text
Raw Normal View History

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