2015-08-03 11:35:01 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
2015-08-03 15:37:44 +02:00
|
|
|
admin=$3
|
2015-08-10 16:45:03 +02:00
|
|
|
password=$4
|
2015-08-10 15:52:45 +02:00
|
|
|
language=$5
|
2015-08-10 16:45:03 +02:00
|
|
|
public_site=$6
|
2015-08-10 17:28:11 +02:00
|
|
|
port=$7
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
# Check domain/path availability
|
|
|
|
sudo yunohost app checkurl $domain$path -a movim
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2015-08-21 15:46:56 +02:00
|
|
|
exit 1
|
2015-08-03 11:35:01 +02:00
|
|
|
fi
|
|
|
|
|
2015-08-10 17:34:50 +02:00
|
|
|
# Check port availability
|
2015-08-12 14:35:47 +02:00
|
|
|
sudo yunohost app checkport $port
|
2015-08-10 17:34:50 +02:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2015-08-21 15:46:56 +02:00
|
|
|
exit 1
|
2015-08-10 17:34:50 +02:00
|
|
|
fi
|
|
|
|
|
2015-08-12 14:35:47 +02:00
|
|
|
# Check user availability
|
|
|
|
sudo yunohost user info $admin
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check password not empty
|
|
|
|
if [[ -z "$password" ]]; then
|
2015-08-12 14:47:36 +02:00
|
|
|
printf "Error empty admin password, aborting"
|
2015-08-21 15:46:56 +02:00
|
|
|
exit 1
|
2015-08-12 14:35:47 +02:00
|
|
|
fi
|
|
|
|
|
2015-08-03 15:37:44 +02:00
|
|
|
sudo yunohost app setting movim admin -v $admin
|
2015-08-03 12:05:52 +02:00
|
|
|
sudo yunohost app setting movim public_site -v $public_site
|
2015-08-11 12:26:57 +02:00
|
|
|
sudo yunohost app setting movim port -v $port
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
# Generate random password
|
2015-08-21 15:52:33 +02:00
|
|
|
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[[:alnum:]]' | sed -n 's/\(.\{24\}\).*/\1/p')
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
# Use 'movim' as database name and user
|
|
|
|
db_user=movim
|
|
|
|
|
|
|
|
# Initialize database and store mysql password for upgrade
|
|
|
|
sudo yunohost app initdb $db_user -p $db_pwd
|
|
|
|
sudo yunohost app setting movim mysqlpwd -v $db_pwd
|
|
|
|
|
2015-08-03 12:05:52 +02:00
|
|
|
# Install packages
|
2015-08-12 10:36:56 +02:00
|
|
|
sudo apt-get install php5-gd php5-curl php5-imagick php5-cli -y
|
2015-08-03 11:35:01 +02:00
|
|
|
|
2015-08-03 12:05:52 +02:00
|
|
|
# Install Movim files
|
2015-08-03 11:35:01 +02:00
|
|
|
final_path=/var/www/movim
|
|
|
|
sudo mkdir -p $final_path
|
|
|
|
sudo cp -a ../sources/* $final_path
|
2015-08-19 11:13:00 +02:00
|
|
|
|
2015-08-19 11:17:10 +02:00
|
|
|
# Create movim system user and set permissions
|
2015-08-21 16:18:30 +02:00
|
|
|
sudo chown -R www-data: $final_path
|
|
|
|
sudo chmod -R 750 $final_path
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
# Install PHP dependencies
|
2015-08-21 16:18:30 +02:00
|
|
|
sudo su -c "curl -sS https://getcomposer.org/installer | php -- --install-dir=$final_path" -s /bin/sh www-data
|
|
|
|
sudo su -c "cd $final_path && php composer.phar install" -s /bin/sh www-data
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
# Movim configuration
|
2015-08-03 12:05:52 +02:00
|
|
|
sudo cp $final_path/config/db.example.inc.php $final_path/config/db.inc.php
|
2015-08-11 09:39:22 +02:00
|
|
|
sudo sed -i "s@'username' => 'username'@'username' => '$db_user'@g" $final_path/config/db.inc.php
|
2015-08-11 09:41:32 +02:00
|
|
|
sudo sed -i "s@'password' => 'password'@'password' => '$db_pwd'@g" $final_path/config/db.inc.php
|
2015-08-10 23:44:45 +02:00
|
|
|
sudo sed -i "s@/ws/@$path/ws/@g" $final_path/app/assets/js/movim_websocket.js
|
2015-08-21 16:18:30 +02:00
|
|
|
sudo su -c "cd $final_path && php mud.php db set" -s /bin/sh www-data
|
|
|
|
sudo su -c "cd $final_path && php mud.php config locale:$language" -s /bin/sh www-data
|
|
|
|
sudo su -c "cd $final_path && php mud.php config loglevel:1" -s /bin/sh www-data
|
|
|
|
sudo su -c "cd $final_path && php mud.php config environment:production" -s /bin/sh www-data
|
|
|
|
sudo su -c "cd $final_path && php mud.php config timezone:`cat /etc/timezone`" -s /bin/sh www-data
|
|
|
|
sudo su -c "cd $final_path && php mud.php config username:$admin" -s /bin/sh www-data
|
|
|
|
sudo su -c "cd $final_path && php mud.php config password:`echo -n $password | sha1sum | awk '{print $1}'`" -s /bin/sh www-data
|
2015-08-21 14:33:58 +02:00
|
|
|
if [ $public_site = "No" ];
|
|
|
|
then
|
2015-08-21 16:18:30 +02:00
|
|
|
sudo su -c "cd $final_path && php mud.php config xmppwhitelist:$domain" -s /bin/sh www-data
|
2015-08-21 14:33:58 +02:00
|
|
|
fi
|
2015-08-03 15:37:44 +02:00
|
|
|
sudo yunohost app addaccess movim -u $admin
|
2015-08-03 11:35:01 +02:00
|
|
|
|
2015-08-04 10:50:43 +02:00
|
|
|
# Copy init script or systemd service
|
|
|
|
sudo sed -i "s@YHURL@$domain$path@g" ../conf/movim.{service,init}
|
|
|
|
sudo sed -i "s@YHDIR@$final_path@g" ../conf/movim.{service,init}
|
2015-08-10 17:28:11 +02:00
|
|
|
sudo sed -i "s@YHPORT@$port@g" ../conf/movim.{service,init}
|
2015-08-12 10:58:06 +02:00
|
|
|
initcheck=`pgrep -ox systemd`
|
|
|
|
if [ "$initcheck" = "1" ];
|
2015-08-04 10:50:43 +02:00
|
|
|
then
|
2015-08-04 11:12:13 +02:00
|
|
|
sudo cp ../conf/movim.service /lib/systemd/system/
|
2015-08-04 10:50:43 +02:00
|
|
|
sudo systemctl enable movim.service
|
|
|
|
sudo systemctl start movim.service
|
|
|
|
else
|
|
|
|
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
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
# Nginx configuration
|
|
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
2015-08-10 17:28:11 +02:00
|
|
|
sed -i "s@YHPORT@$port@g" ../conf/nginx.conf
|
2015-08-21 16:18:30 +02:00
|
|
|
sed -i "s@//ws/@/ws/@g" ../conf/nginx.conf # Avoid duplicate /
|
2015-08-03 12:05:52 +02:00
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf
|
2015-08-03 11:35:01 +02:00
|
|
|
|
2015-08-03 12:05:52 +02:00
|
|
|
# SSOwat Configuration
|
|
|
|
sudo yunohost app setting movim skipped_uris -v "/"
|
2015-08-03 11:35:01 +02:00
|
|
|
sudo yunohost app ssowatconf
|
2015-08-03 12:05:52 +02:00
|
|
|
|
|
|
|
# Start Movim
|
2015-08-03 22:34:19 +02:00
|
|
|
sudo service nginx reload
|
2015-08-10 15:32:20 +02:00
|
|
|
sudo service php5-fpm restart
|