2015-08-11 12:26:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
path=$(sudo yunohost app setting movim path)
|
2015-08-19 14:08:24 +02:00
|
|
|
domain=$(sudo yunohost app setting movim domain)
|
|
|
|
port=$(sudo yunohost app setting movim port)
|
2015-08-21 18:12:22 +02:00
|
|
|
public_site=$(sudo yunohost app setting movim public_site)
|
2015-08-31 16:30:44 +02:00
|
|
|
timezone=`cat /etc/timezone`
|
2015-08-11 12:26:57 +02:00
|
|
|
|
2015-08-31 16:39:08 +02:00
|
|
|
# Check timezone
|
|
|
|
if [[ -z "$timezone" ]]; then
|
|
|
|
printf "Could not detect Timezone, please check /etc/timezone. Installation aborted"
|
|
|
|
exit 1
|
|
|
|
else
|
2015-09-01 11:14:19 +02:00
|
|
|
printf "Detected Timezone $timezone \n"
|
2015-08-31 16:39:08 +02:00
|
|
|
fi
|
|
|
|
|
2015-08-11 12:26:57 +02:00
|
|
|
# Install Movim files
|
|
|
|
final_path=/var/www/movim
|
|
|
|
sudo cp -a ../sources/* $final_path
|
2015-08-21 18:12:22 +02:00
|
|
|
|
|
|
|
# Create movim user if not exists and set permissions
|
|
|
|
if grep -q movim /etc/passwd; then
|
|
|
|
sudo chown -R movim:www-data $final_path
|
|
|
|
sudo chmod -R 750 $final_path
|
|
|
|
else
|
|
|
|
sudo useradd -s /bin/sh -d $final_path movim
|
|
|
|
sudo chown -R movim:www-data $final_path
|
|
|
|
sudo chmod -R 750 $final_path
|
|
|
|
fi
|
2015-08-11 12:26:57 +02:00
|
|
|
|
2015-08-19 11:25:29 +02:00
|
|
|
# Update PHP dependencies
|
2015-08-31 14:53:47 +02:00
|
|
|
sudo su -c "cd $final_path && php composer.phar update" movim
|
2015-08-11 12:26:57 +02:00
|
|
|
|
|
|
|
# Movim configuration
|
|
|
|
sudo sed -i "s@/ws/@$path/ws/@g" $final_path/app/assets/js/movim_websocket.js
|
|
|
|
|
2015-08-21 18:12:22 +02:00
|
|
|
# Update xmppwhitelist if private
|
|
|
|
if [ $public_site = "No" ];
|
|
|
|
then
|
|
|
|
sudo su -c "cd $final_path && php mud.php config xmppwhitelist:$domain" movim
|
|
|
|
fi
|
|
|
|
|
2015-08-21 18:20:35 +02:00
|
|
|
# Delete obsolete SSO conf
|
|
|
|
sudo yunohost app setting movim protected_uris -d
|
|
|
|
|
2015-08-19 11:25:29 +02:00
|
|
|
# Update init scripts
|
2015-08-19 14:08:24 +02:00
|
|
|
sudo sed -i "s@YHURL@$domain$path@g" ../conf/movim.{service,init}
|
|
|
|
sudo sed -i "s@YHDIR@$final_path@g" ../conf/movim.{service,init}
|
|
|
|
sudo sed -i "s@YHPORT@$port@g" ../conf/movim.{service,init}
|
2015-08-19 11:25:29 +02:00
|
|
|
initcheck=`pgrep -ox systemd`
|
|
|
|
if [ "$initcheck" = "1" ];
|
|
|
|
then
|
2015-09-10 16:37:25 +02:00
|
|
|
sudo rm -f /lib/systemd/system/movim.service
|
|
|
|
sudo cp ../conf/movim.service /etc/systemd/system/
|
2015-08-31 14:52:30 +02:00
|
|
|
sudo systemctl daemon-reload
|
2015-08-19 11:25:29 +02:00
|
|
|
else
|
|
|
|
sudo /etc/init.d/movim stop
|
|
|
|
sudo cp ../conf/movim.init /etc/init.d/movim
|
|
|
|
sudo chmod 755 /etc/init.d/movim
|
2015-09-10 16:19:54 +02:00
|
|
|
sudo update-rc.d movim defaults
|
2015-08-19 11:25:29 +02:00
|
|
|
sudo /etc/init.d/movim start
|
|
|
|
fi
|
|
|
|
|
2015-08-21 18:12:22 +02:00
|
|
|
# Update php-fpm configuration
|
2015-08-31 16:30:44 +02:00
|
|
|
sed -i "s@YHTZ@$timezone@g" ../conf/php-fpm.conf
|
2015-08-21 18:12:22 +02:00
|
|
|
sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/movim.conf
|
|
|
|
|
|
|
|
# Nginx configuration
|
|
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@YHPORT@$port@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@//ws/@/ws/@g" ../conf/nginx.conf # Avoid duplicate /
|
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf
|
|
|
|
|
2015-08-11 12:26:57 +02:00
|
|
|
# Reload
|
|
|
|
sudo yunohost app ssowatconf
|
2015-08-19 14:00:16 +02:00
|
|
|
sudo service movim restart
|
2015-08-21 18:12:22 +02:00
|
|
|
sudo service php5-fpm restart
|
|
|
|
sudo service nginx reload
|