mirror of
https://github.com/YunoHost-Apps/movim_ynh.git
synced 2024-09-03 19:46:19 +02:00
107 lines
3.5 KiB
Bash
107 lines
3.5 KiB
Bash
#!/bin/bash
|
|
#
|
|
|
|
# Retrieve arguments
|
|
path=$(sudo yunohost app setting movim path)
|
|
domain=$(sudo yunohost app setting movim domain)
|
|
port=$(sudo yunohost app setting movim port)
|
|
public_site=$(sudo yunohost app setting movim public_site)
|
|
ssoenabled=$(sudo yunohost app setting movim ssoenabled)
|
|
timezone=`cat /etc/timezone`
|
|
|
|
# Check timezone
|
|
if [[ -z "$timezone" ]]; then
|
|
printf "Could not detect Timezone, please check /etc/timezone. Installation aborted"
|
|
exit 1
|
|
else
|
|
printf "Detected Timezone $timezone \n"
|
|
fi
|
|
|
|
# Install Movim files
|
|
final_path=/var/www/movim
|
|
sudo cp -a ../sources/* $final_path
|
|
|
|
# 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
|
|
|
|
# Update PHP dependencies
|
|
# Not necessary anymore, shipped with movim_ynh
|
|
#sudo su -c "cd $final_path && rm composer.lock"
|
|
#sudo su -c "cd $final_path && php composer.phar config --global discard-changes true" movim
|
|
#sudo su -c "cd $final_path && php composer.phar install -n" movim
|
|
|
|
# Movim configuration
|
|
sudo sed -i "s@/ws/@$path/ws/@g" $final_path/app/assets/js/movim_websocket.js
|
|
|
|
# Upgrade db if necessary
|
|
sudo su -c "cd $final_path && php mud.php db set" movim
|
|
|
|
# Reset SSO parameters
|
|
sudo yunohost app setting movim protected_uris -d
|
|
sudo yunohost app setting movim skipped_uris -d
|
|
sudo yunohost app clearaccess movim
|
|
|
|
# Replace old public_site variable (if exists) by ssoenabled
|
|
if [ ! -z "$public_site" ] && [ $public_site = "Yes" ];
|
|
then
|
|
sudo yunohost app setting movim public_site -d
|
|
sudo yunohost app setting movim ssoenabled -v "No"
|
|
elif [ ! -z "$public_site" ] && [ $public_site = "No" ];
|
|
then
|
|
sudo yunohost app setting movim public_site -d
|
|
sudo yunohost app setting movim ssoenabled -v "Yes"
|
|
fi
|
|
|
|
# SSOwat Configuration
|
|
if [ $ssoenabled = "No" ];
|
|
then
|
|
sudo yunohost app setting movim skipped_uris -v "/"
|
|
sudo yunohost app ssowatconf
|
|
sudo su -c "cd $final_path && php mud.php config xmppwhitelist:$domain" movim
|
|
else
|
|
sudo yunohost app setting movim unprotected_uris -v "/"
|
|
# Next line is to avoid SSO to auto-connect just after disconnect
|
|
sudo sed -i "s@redirect('login')@redirect('')@g" $final_path/app/controllers/DisconnectController.php
|
|
sudo yunohost app ssowatconf
|
|
fi
|
|
|
|
# Update init scripts
|
|
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}
|
|
initcheck=`pgrep -ox systemd`
|
|
if [ "$initcheck" = "1" ];
|
|
then
|
|
sudo rm -f /lib/systemd/system/movim.service
|
|
sudo cp ../conf/movim.service /etc/systemd/system/
|
|
sudo systemctl daemon-reload
|
|
else
|
|
sudo /etc/init.d/movim stop
|
|
sudo cp ../conf/movim.init /etc/init.d/movim
|
|
sudo chmod 755 /etc/init.d/movim
|
|
sudo update-rc.d movim defaults
|
|
sudo /etc/init.d/movim start
|
|
fi
|
|
|
|
# Update php-fpm configuration
|
|
sed -i "s@YHTZ@$timezone@g" ../conf/php-fpm.conf
|
|
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
|
|
|
|
# Reload
|
|
sudo service movim restart
|
|
sudo service php5-fpm restart
|
|
sudo service nginx reload
|