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

71 lines
1.7 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-19 00:51:32 +01:00
is_public=$3
path="/SOGo"
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
2016-03-18 21:01:32 +01:00
#sudo echo "deb http://inverse.ca/debian $codename $codename" > sogo.list
2016-03-18 18:38:54 +01:00
#Add Repository Key
2016-03-18 21:01:32 +01:00
#sudo apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4
2016-03-18 18:38:54 +01:00
#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
2016-03-18 20:36:22 +01:00
#Configure Nginx
sudo sed -i "s@VARPATH@$path@g" ../conf/nginx.conf
2016-03-18 18:38:54 +01:00
#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