1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/sogo_ynh.git synced 2024-09-03 20:26:07 +02:00
sogo_ynh/scripts/install

68 lines
1.6 KiB
Text
Raw Normal View History

2016-03-18 18:38:54 +01:00
#!/bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
app=sogo
# Retrieve arguments
domain=$1
2016-03-18 19:35:13 +01:00
admin=$2
2016-03-18 20:32:32 +01:00
path=$3
is_public=$4
2016-03-18 19:29:27 +01:00
codename=$(lsb_release -c -s)
2016-03-18 18:38:54 +01:00
# Save app settings
sudo yunohost app setting $app admin -v "$admin"
sudo yunohost app setting $app is_public -v "$is_public"
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app \
|| (echo "Path not available: $domain$path" && exit 1)
#Add Repositories
sudo echo "deb http://inverse.ca/debian $codename $codename" > sogo.list
2016-03-18 18:38:54 +01:00
#Add Repository Key
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4
#Update Package Cache
sudo apt-get update
2016-03-18 18:38:54 +01:00
#install Sogo
2016-03-18 19:49:38 +01:00
sudo apt-get install sogo --assume-yes
2016-03-18 18:38:54 +01:00
# If your app use a MySQL database you can use these lines to bootstrap
# a database, an associated user and save the password in app settings
db_pwd=$(openssl rand -hex 15)
sudo yunohost app initdb $app -p $db_pwd
sudo yunohost app setting $app mysqlpwd -v $db_pwd
#Set SOGo Details
sudo sed -i "s@ADMINUSER@$admin@g" ../conf/sogo.conf
sudo sed -i "s@DBUSER@$app@g" ../conf/sogo.conf
sudo sed -i "s@DBPASS@$db_pwd@g" ../conf/sogo.conf
2016-03-18 18:38:54 +01:00
#Copy SOGo config
sudo cp ../conf/sogo.conf /etc/sogo/sogo.conf
#copy Nginx config
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [ "$is_public" = "Yes" ];
then
# unprotected_uris allows SSO credentials to be passed anyway.
sudo yunohost app setting $app unprotected_uris -v "/"
fi
# Restart services
sudo service nginx reload
sudo yunohost app ssowatconf
sudo service sogo restart