mirror of
https://github.com/YunoHost-Apps/agendav_ynh.git
synced 2024-09-03 20:36:12 +02:00
[enh] Make use of YunoHost helpers and retrieve SSO path on the fly
This commit is contained in:
parent
bbadba63b3
commit
425f47a036
7 changed files with 204 additions and 216 deletions
|
@ -44,7 +44,7 @@ $config['caldav_http_auth_method'] = CURLAUTH_BASIC;
|
|||
* - Apple Calendar Server: https://host/calendars/users/%u/
|
||||
*/
|
||||
|
||||
$config['caldav_principal_url'] = 'YNH_CALDAV_PRINCIPAL_URL';
|
||||
$config['caldav_principal_url'] = '{PRINCIPAL_URL}';
|
||||
|
||||
/*
|
||||
* CalDAV calendars URL template
|
||||
|
@ -59,7 +59,7 @@ $config['caldav_principal_url'] = 'YNH_CALDAV_PRINCIPAL_URL';
|
|||
* - Apple Calendar Server: https://host/calendars/users/%s/
|
||||
*/
|
||||
|
||||
$config['caldav_calendar_url'] = 'YNH_CALDAV_CALENDAR_URL';
|
||||
$config['caldav_calendar_url'] = '{CALENDAR_URL}';
|
||||
|
||||
/*
|
||||
* Public CalDAV URL for calendars
|
||||
|
|
|
@ -20,7 +20,7 @@ require_once('defaults.php');
|
|||
| path to your installation.
|
||||
|
|
||||
*/
|
||||
$config['base_url'] = 'https://YNH_DOMAINYNH_WWW_PATH/';
|
||||
$config['base_url'] = 'https://{DOMAIN}{PATH}/';
|
||||
|
||||
|
||||
/*
|
||||
|
@ -50,7 +50,7 @@ $config['show_in_log']= array('ERROR','INFO','AUTHERR', 'AUTHOK');
|
|||
| Use a full server path with trailing slash.
|
||||
|
|
||||
*/
|
||||
$config['log_path'] = 'YNH_LOG_PATH/';
|
||||
$config['log_path'] = '{LOGDIR}/';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -61,7 +61,7 @@ $config['log_path'] = 'YNH_LOG_PATH/';
|
|||
| MUST set an encryption key. See the user guide for info.
|
||||
|
|
||||
*/
|
||||
$config['encryption_key'] = 'YNH_ENCRYPT_KEY';
|
||||
$config['encryption_key'] = '{ENCRYPTKEY}';
|
||||
|
||||
|
||||
/*
|
||||
|
@ -75,8 +75,8 @@ $config['encryption_key'] = 'YNH_ENCRYPT_KEY';
|
|||
| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists.
|
||||
|
|
||||
*/
|
||||
$config['cookie_prefix'] = "YNH_COOKIE_PREFIX";
|
||||
$config['cookie_domain'] = "YNH_COOKIE_DOMAIN";
|
||||
$config['cookie_prefix'] = "{COOKIE_PREFIX}";
|
||||
$config['cookie_domain'] = "{COOKIE_DOMAIN}";
|
||||
$config['cookie_path'] = "/";
|
||||
$config['cookie_secure'] = TRUE;
|
||||
|
||||
|
@ -131,7 +131,8 @@ $config['footer'] = 'Powered by Yunohost';
|
|||
| Leave empty if you want to redirect to login page
|
||||
|
|
||||
*/
|
||||
$config['logout_redirect_to'] = 'YNH_LOGOUT_REDIRECT_TO';
|
||||
$main_domain = exec('cat /etc/yunohost/current_host');
|
||||
$config['logout_redirect_to'] = 'https://'.$main_domain.'/yunohost/sso/?action=logout';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -166,7 +167,7 @@ $config['show_public_caldav_url'] = FALSE;
|
|||
| than en.
|
||||
|
|
||||
*/
|
||||
$config['default_language'] = 'YNH_LANG';
|
||||
$config['default_language'] = '{LANG}';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -258,7 +259,7 @@ $config['default_first_day'] = 1;
|
|||
| Please, use a valid timezone from http://php.net/timezones
|
||||
*/
|
||||
|
||||
$config['default_timezone'] = 'YNH_TIMEZONE';
|
||||
$config['default_timezone'] = '{TIMEZONE}';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -42,9 +42,9 @@ $active_group = 'default';
|
|||
$active_record = TRUE;
|
||||
|
||||
$db['default']['hostname'] = 'localhost';
|
||||
$db['default']['username'] = 'YNH_DB_USER';
|
||||
$db['default']['password'] = 'YNH_DB_PWD';
|
||||
$db['default']['database'] = 'YNH_DB_NAME';
|
||||
$db['default']['username'] = '{DBUSER}';
|
||||
$db['default']['password'] = '{DBPASS}';
|
||||
$db['default']['database'] = '{DBNAME}';
|
||||
$db['default']['dbdriver'] = 'mysql';
|
||||
$db['default']['dbprefix'] = '';
|
||||
$db['default']['pconnect'] = TRUE;
|
||||
|
@ -59,4 +59,4 @@ $db['default']['stricton'] = FALSE;
|
|||
|
||||
|
||||
/* End of file database.php */
|
||||
/* Location: ./application/config/database.php */
|
||||
/* Location: ./application/config/database.php */
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
location YNH_WWW_PATH {
|
||||
alias YNH_ALIAS/;
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
index index.php;
|
||||
try_files $uri $uri/ index.php;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
location {LOCATION} {
|
||||
alias {DESTDIR}/web/public;
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
index index.php;
|
||||
try_files $uri $uri/ index.php;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
|
167
scripts/install
167
scripts/install
|
@ -1,117 +1,104 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=$2
|
||||
path=${2%/}
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Set app specific variables
|
||||
app="agendav"
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a agendav
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
echo "Error : $domain$path is not available"
|
||||
exit 1
|
||||
fi
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| exit 1
|
||||
|
||||
baikal=0
|
||||
radicale=0
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/${app}"
|
||||
[[ -d "$DESTDIR" ]] && ynh_die \
|
||||
"The destination directory '${DESTDIR}' already exists.\
|
||||
You should safely delete it before installing this app."
|
||||
|
||||
sudo yunohost app list -f baikal --json | grep '"installed": true' && baikal=1
|
||||
sudo yunohost app list -f radicale --json | grep '"installed": true' && radicale=1
|
||||
|
||||
if [ "$baikal" == "1" ] ; then
|
||||
echo "Detected Baikal"
|
||||
baikal=1
|
||||
caldavapp=baikal
|
||||
elif [ "$radicale" == "1" ] ; then
|
||||
echo "Detected Radicale"
|
||||
radicale=1
|
||||
caldavapp=radicale
|
||||
# Check whether Baïkal or Radicale is installed
|
||||
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
||||
caldav_app="baikal"
|
||||
caldav_principal_path="/cal.php/%u/"
|
||||
caldav_calendar_path="/cal.php/calendars/%s/"
|
||||
elif sudo yunohost app list --installed -f radicale | grep -q id ; then
|
||||
caldav_app="radicale"
|
||||
caldav_principal_path="/%u/"
|
||||
caldav_calendar_path="/%s/"
|
||||
else
|
||||
echo "Error : You must install Baikal or Radicale before"
|
||||
exit 1
|
||||
ynh_die "You must install Baïkal or Radicale before"
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
sudo apt-get update
|
||||
sudo apt-get install php5-cli -y
|
||||
ynh_package_is_installed "php5-cli" \
|
||||
|| ynh_package_install "php5-cli"
|
||||
|
||||
# Generate random password
|
||||
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
|
||||
# Generate random password and encryption key
|
||||
dbpass=$(ynh_string_random)
|
||||
encryptkey=$(ynh_string_random 24)
|
||||
|
||||
# Use 'agendav' as database name and user
|
||||
db_user=agendav
|
||||
|
||||
# Initialize database and store mysql password for upgrade
|
||||
sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../sources/sql/mysql.schema.sql)
|
||||
sudo yunohost app setting agendav mysqlpwd -v $db_pwd
|
||||
# Initialize database
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \
|
||||
< "../sources/sql/mysql.schema.sql"
|
||||
|
||||
# Copy files to the right place
|
||||
final_path=/var/www/agendav
|
||||
sudo mkdir -p $final_path
|
||||
sudo cp -r ../sources/* $final_path
|
||||
sudo cp -r ../sources "$DESTDIR"
|
||||
|
||||
sudo chown -R admin: $final_path
|
||||
currentpath=$(pwd)
|
||||
cd $final_path/web/application && ln -s ../config config && cd $currentpath
|
||||
# CalDAV config
|
||||
caldav_domain=$(ynh_app_setting_get "$caldav_app" domain)
|
||||
caldav_path=$(ynh_app_setting_get "$caldav_app" path)
|
||||
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
||||
sed -i "s@{PRINCIPAL_URL}@${caldav_url}${caldav_principal_path}@g" \
|
||||
../conf/caldav.php
|
||||
sed -i "s@{CALENDAR_URL}@${caldav_url}${caldav_calendar_path}@g" \
|
||||
../conf/caldav.php
|
||||
|
||||
# caldav config
|
||||
caldavdomain=$(sudo yunohost app setting $caldavapp domain)
|
||||
caldavpath=$(sudo yunohost app setting $caldavapp path)
|
||||
caldavpath=${caldavpath%/}
|
||||
if [ $baikal -eq 1 ]; then
|
||||
caldav_principal_url="https://$caldavdomain$caldavpath/cal.php/%u/"
|
||||
caldav_calendar_url="https://$caldavdomain$caldavpath/cal.php/calendars/%s/"
|
||||
elif [ $radicale -eq 1 ]; then
|
||||
caldav_principal_url="https://$caldavdomain$caldavpath/%u/"
|
||||
caldav_calendar_url="https://$caldavdomain$caldavpath/%s/"
|
||||
fi
|
||||
echo "----- $caldav_principal_url"
|
||||
sed -i "s@YNH_CALDAV_PRINCIPAL_URL@$caldav_principal_url@g" ../conf/caldav.php
|
||||
sed -i "s@YNH_CALDAV_CALENDAR_URL@$caldav_calendar_url@g" ../conf/caldav.php
|
||||
# Database config
|
||||
sed -i "s/{DBUSER}/${dbuser}/g" ../conf/database.php
|
||||
sed -i "s/{DBPASS}/${dbpass}/g" ../conf/database.php
|
||||
sed -i "s/{DBNAME}/${dbname}/g" ../conf/database.php
|
||||
|
||||
# database config
|
||||
sed -i "s/YNH_DB_USER/$db_user/g" ../conf/database.php
|
||||
sed -i "s/YNH_DB_PWD/$db_pwd/g" ../conf/database.php
|
||||
sed -i "s/YNH_DB_NAME/$db_user/g" ../conf/database.php
|
||||
# Main config
|
||||
LOGDIR=/var/log/agendav
|
||||
lang=${LANG/.*/}
|
||||
sed -i "s@{DOMAIN}@${domain}@g" ../conf/config.php
|
||||
sed -i "s@{PATH}@${path}@g" ../conf/config.php
|
||||
sed -i "s@{LOGDIR}@${LOGDIR}@g" ../conf/config.php
|
||||
sed -i "s/{ENCRYPTKEY}/${encryptkey}/g" ../conf/config.php
|
||||
sed -i "s@{COOKIE_PREFIX}@${path#/}@g" ../conf/config.php
|
||||
sed -i "s@{COOKIE_DOMAIN}@${domain}@g" ../conf/config.php
|
||||
sed -i "s@{LANG}@${lang:-en_EN}@g" ../conf/config.php
|
||||
sed -i "s@{TIMEZONE}@$(cat /etc/timezone)@g" ../conf/config.php
|
||||
|
||||
# main config
|
||||
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.php
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/config.php
|
||||
logdir=/var/log/agendav
|
||||
sudo mkdir -p $logdir
|
||||
sudo chown www-data: $logdir
|
||||
sudo chmod 755 $logdir
|
||||
sed -i "s@YNH_LOG_PATH@$logdir@g" ../conf/config.php
|
||||
encryptkey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
||||
sudo yunohost app setting agendav encryptkey -v $encryptkey
|
||||
sed -i "s/YNH_ENCRYPT_KEY/$encryptkey/g" ../conf/config.php
|
||||
sed -i "s@YNH_COOKIE_PREFIX@${path#/}@g" ../conf/config.php
|
||||
sed -i "s/YNH_COOKIE_DOMAIN/$domain/g" ../conf/config.php
|
||||
logout_redirect="https://$domain/yunohost/sso"
|
||||
sed -i "s@YNH_LOGOUT_REDIRECT_TO@$logout_redirect@g" ../conf/config.php
|
||||
lang=$(sudo bash -c "echo $LANG | cut -d '.' -f 1")
|
||||
sed -i "s@YNH_LANG@$lang@g" ../conf/config.php
|
||||
timezone=$(cat /etc/timezone)
|
||||
sed -i "s@YNH_TIMEZONE@$timezone@g" ../conf/config.php
|
||||
# Copy config files and set permissions
|
||||
sudo cp ../conf/{config,database,caldav}.php "${DESTDIR}/web/config/"
|
||||
(cd "$DESTDIR/web/application" && sudo ln -s ../config config)
|
||||
sudo chown -hR root: "$DESTDIR"
|
||||
|
||||
# copy config files
|
||||
sudo cp ../conf/{config.php,database.php,caldav.php} $final_path/web/config/
|
||||
# Create log directory
|
||||
sudo install -m 750 -o www-data -d "$LOGDIR"
|
||||
|
||||
# execute database shema update
|
||||
# Execute database shema update
|
||||
sudo /var/www/agendav/bin/agendavcli dbupdate
|
||||
|
||||
# Set permissions to agendav directory
|
||||
sudo chown -R root: $final_path
|
||||
sudo find $final_path -type f | xargs sudo chmod 644
|
||||
sudo find $final_path -type d | xargs sudo chmod 755
|
||||
# Save app settings
|
||||
ynh_app_setting_set "$app" encryptkey "$encryptkey"
|
||||
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||
sed -i "s@YNH_ALIAS@$final_path/web/public@g" ../conf/nginx.conf
|
||||
nginxconf=/etc/nginx/conf.d/$domain.d/agendav.conf
|
||||
sudo cp ../conf/nginx.conf $nginxconf
|
||||
sudo chown root: $nginxconf
|
||||
sudo chmod 600 $nginxconf
|
||||
# Copy and set nginx configuration
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sed -i "s@{LOCATION}@${path:-/}@g" ../conf/nginx.conf
|
||||
sed -i "s@{DESTDIR}@${DESTDIR}@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
# Reload services
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
db_user=agendav
|
||||
db_name=agendav
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
domain=$(sudo yunohost app setting agendav domain)
|
||||
# Set app specific variables
|
||||
app="agendav"
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
|
||||
sudo rm -rf /var/www/agendav
|
||||
sudo rm -rf /var/log/agendav
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/agendav.conf
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Drop MySQL database and user
|
||||
ynh_mysql_drop_db "$dbname" || true
|
||||
ynh_mysql_drop_user "$dbuser" || true
|
||||
|
||||
# Retrieve domain from app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
|
||||
# Delete app directory and configurations
|
||||
sudo rm -rf "/var/www/${app}" "/var/log/${app}"
|
||||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
|
||||
# Reload services
|
||||
sudo service nginx reload || true
|
||||
|
|
160
scripts/upgrade
160
scripts/upgrade
|
@ -1,103 +1,91 @@
|
|||
#!/bin/bash
|
||||
|
||||
baikal=0
|
||||
radicale=0
|
||||
if [[ $(sudo yunohost app list --json | grep -q '"id": "baikal"') -eq 0 ]]; then
|
||||
echo "Detected Baikal"
|
||||
baikal=1
|
||||
caldavapp=baikal
|
||||
elif [[ $(sudo yunohost app list --json | grep -q '"id": "radicale"')? -eq 0 ]]; then
|
||||
echo "Detected Radicale"
|
||||
radicale=1
|
||||
caldavapp=radicale
|
||||
else
|
||||
echo "Error : You must install Baikal or Radicale before"
|
||||
exit 1
|
||||
fi
|
||||
set -e
|
||||
|
||||
domain=$(sudo yunohost app setting agendav domain)
|
||||
path=$(sudo yunohost app setting agendav path)
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Set app specific variables
|
||||
app="agendav"
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
path=${path%/}
|
||||
db_user=agendav
|
||||
db_pwd=$(sudo yunohost app setting agendav mysqlpwd)
|
||||
db_name=agendav
|
||||
encryptkey=$(sudo yunohost app setting agendav encryptkey)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
encryptkey=$(ynh_app_setting_get "$app" encryptkey)
|
||||
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
[[ ! -d $DESTDIR ]] && ynh_die \
|
||||
"The destination directory '$DESTDIR' does not exist.\
|
||||
The app is not correctly installed, you should remove it first."
|
||||
|
||||
# Check whether Baïkal or Radicale is installed
|
||||
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
||||
caldav_app="baikal"
|
||||
caldav_principal_path="/cal.php/%u/"
|
||||
caldav_calendar_path="/cal.php/calendars/%s/"
|
||||
elif sudo yunohost app list --installed -f radicale | grep -q id ; then
|
||||
caldav_app="radicale"
|
||||
caldav_principal_path="/%u/"
|
||||
caldav_calendar_path="/%s/"
|
||||
else
|
||||
ynh_die "You must install Baïkal or Radicale before"
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
sudo apt-get update
|
||||
sudo apt-get install php5-cli -y
|
||||
ynh_package_is_installed "php5-cli" \
|
||||
|| ynh_package_install "php5-cli"
|
||||
|
||||
# Clean up existing files and copy new files to the right place
|
||||
final_path=/var/www/agendav
|
||||
sudo rm -rf $final_path
|
||||
sudo mkdir -p $final_path
|
||||
sudo cp -r ../sources/* $final_path
|
||||
sudo rm -rf "$DESTDIR"
|
||||
sudo cp -r ../sources "$DESTDIR"
|
||||
|
||||
sudo chown -R admin: $final_path
|
||||
currentpath=$(pwd)
|
||||
cd $final_path/web/application && ln -s ../config config && cd $currentpath
|
||||
# CalDAV config
|
||||
caldav_domain=$(ynh_app_setting_get "$caldav_app" domain)
|
||||
caldav_path=$(ynh_app_setting_get "$caldav_app" path)
|
||||
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
||||
sed -i "s@{PRINCIPAL_URL}@${caldav_url}${caldav_principal_path}@g" \
|
||||
../conf/caldav.php
|
||||
sed -i "s@{CALENDAR_URL}@${caldav_url}${caldav_calendar_path}@g" \
|
||||
../conf/caldav.php
|
||||
|
||||
# caldav config
|
||||
caldavdomain=$(sudo yunohost app setting $caldavapp domain)
|
||||
caldavpath=$(sudo yunohost app setting $caldavapp path)
|
||||
caldavpath=${caldavpath%/}
|
||||
if [ $baikal -eq 1 ]; then
|
||||
caldav_principal_url="https://$caldavdomain$caldavpath/cal.php/%u/"
|
||||
caldav_calendar_url="https://$caldavdomain$caldavpath/cal.php/calendars/%s/"
|
||||
elif [ $radicale -eq 1 ]; then
|
||||
caldav_principal_url="https://$caldavdomain$caldavpath/%u/"
|
||||
caldav_calendar_url="https://$caldavdomain$caldavpath/%s/"
|
||||
fi
|
||||
echo "----- $caldav_principal_url"
|
||||
sed -i "s@YNH_CALDAV_PRINCIPAL_URL@$caldav_principal_url@g" ../conf/caldav.php
|
||||
sed -i "s@YNH_CALDAV_CALENDAR_URL@$caldav_calendar_url@g" ../conf/caldav.php
|
||||
# Database config
|
||||
sed -i "s/{DBUSER}/${dbuser}/g" ../conf/database.php
|
||||
sed -i "s/{DBPASS}/${dbpass}/g" ../conf/database.php
|
||||
sed -i "s/{DBNAME}/${dbname}/g" ../conf/database.php
|
||||
|
||||
radicale_path=${radicale_path%/}
|
||||
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/caldav.php
|
||||
sed -i "s@YNH_RADICALE_PATH@$radicale_path@g" ../conf/caldav.php
|
||||
# Main config
|
||||
LOGDIR=/var/log/agendav
|
||||
lang=${LANG/.*/}
|
||||
sed -i "s@{DOMAIN}@${domain}@g" ../conf/config.php
|
||||
sed -i "s@{PATH}@${path}@g" ../conf/config.php
|
||||
sed -i "s@{LOGDIR}@${LOGDIR}@g" ../conf/config.php
|
||||
sed -i "s/{ENCRYPTKEY}/${encryptkey}/g" ../conf/config.php
|
||||
sed -i "s@{COOKIE_PREFIX}@${path#/}@g" ../conf/config.php
|
||||
sed -i "s@{COOKIE_DOMAIN}@${domain}@g" ../conf/config.php
|
||||
sed -i "s@{LANG}@${lang:-en_EN}@g" ../conf/config.php
|
||||
sed -i "s@{TIMEZONE}@$(cat /etc/timezone)@g" ../conf/config.php
|
||||
|
||||
# database config
|
||||
sed -i "s/YNH_DB_USER/$db_user/g" ../conf/database.php
|
||||
sed -i "s/YNH_DB_PWD/$db_pwd/g" ../conf/database.php
|
||||
sed -i "s/YNH_DB_NAME/$db_user/g" ../conf/database.php
|
||||
# Copy config files and set permissions
|
||||
sudo cp ../conf/{config,database,caldav}.php "${DESTDIR}/web/config/"
|
||||
(cd "$DESTDIR/web/application" && sudo ln -s ../config config)
|
||||
sudo chown -hR root: "$DESTDIR"
|
||||
|
||||
# main config
|
||||
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.php
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/config.php
|
||||
logdir=/var/log/agendav
|
||||
sudo mkdir -p $logdir
|
||||
sudo chown www-data: $logdir
|
||||
sudo chmod 755 $logdir
|
||||
sed -i "s@YNH_LOG_PATH@$logdir@g" ../conf/config.php
|
||||
sed -i "s/YNH_ENCRYPT_KEY/$encryptkey/g" ../conf/config.php
|
||||
sed -i "s@YNH_COOKIE_PREFIX@${path#/}@g" ../conf/config.php
|
||||
sed -i "s/YNH_COOKIE_DOMAIN/$domain/g" ../conf/config.php
|
||||
logout_redirect="https://$domain/yunohost/sso"
|
||||
sed -i "s@YNH_LOGOUT_REDIRECT_TO@$logout_redirect@g" ../conf/config.php
|
||||
lang=$(sudo bash -c "echo $LANG | cut -d '.' -f 1")
|
||||
sed -i "s@YNH_LANG@$lang@g" ../conf/config.php
|
||||
timezone=$(cat /etc/timezone)
|
||||
sed -i "s@YNH_TIMEZONE@$timezone@g" ../conf/config.php
|
||||
# Create log directory
|
||||
sudo install -m 750 -o www-data -d "$LOGDIR"
|
||||
|
||||
# copy config files
|
||||
sudo cp ../conf/{config.php,database.php,caldav.php} $final_path/web/config/
|
||||
|
||||
# execute database shema update
|
||||
# Execute database shema update
|
||||
sudo /var/www/agendav/bin/agendavcli dbupdate
|
||||
|
||||
# Set permissions to agendav directory
|
||||
sudo chown -R root: $final_path
|
||||
sudo find $final_path -type f | xargs sudo chmod 644
|
||||
sudo find $final_path -type d | xargs sudo chmod 755
|
||||
# Copy and set nginx configuration
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sed -i "s@{LOCATION}@${path:-/}@g" ../conf/nginx.conf
|
||||
sed -i "s@{DESTDIR}@${DESTDIR}@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||
sed -i "s@YNH_ALIAS@$final_path/web/public@g" ../conf/nginx.conf
|
||||
nginxconf=/etc/nginx/conf.d/$domain.d/agendav.conf
|
||||
sudo cp ../conf/nginx.conf $nginxconf
|
||||
sudo chown root: $nginxconf
|
||||
sudo chmod 600 $nginxconf
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
# Reload services
|
||||
sudo service nginx reload || true
|
||||
|
|
Loading…
Add table
Reference in a new issue