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
2016-03-18 21:01:32 +01:00

70 lines
1.7 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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
admin=$2
path=$3
is_public=$4
codename=$(lsb_release -c -s)
# 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
#Add Repository Key
#sudo apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4
#Update Package Cache
sudo apt-get update
#install Sogo
sudo apt-get install sogo --assume-yes
# 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
#Copy SOGo config
sudo cp ../conf/sogo.conf /etc/sogo/sogo.conf
#Configure Nginx
sudo sed -i "s@VARPATH@$path@g" ../conf/nginx.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