Installation von Radicale (Kalender- und Addressbuchdienst) auf einem Uberspace-Nutzerkonto.

tl;dr

  • ./radicale-0.10.sh
    • Standart Installation.
  • ./radicale-0.10.sh uninstall
    • Löschen vom Radicale-Daemon und den Installationsordner.
    • Bestehen bleiben die Nutzerdaten und Konfiguration.
  • ./radicale-0.10.sh uninstallall
    • Löscht alle Inhalte, Daten, Quellen und Abhängigkeiten.
  • TODO: Authentifizierung mittels IMAP statt htaccess.
    • Die virtuellen Benutzer unter dem Uberspacekonto haben automatisch einen Kalender- und Addressbuch-Nutzerkonto.
  • TODO: Better logging rotation.
  • TODO: Update commands.
wget frank.zisko.info/assets/code/2015/radicale-0.10.sh
chmod u+x radicale-0.10.sh
./radicale-0.10.sh

Info

  • Radicale ist ein Service. Zur Nutzung wird also ein Client benötigt.
  • Das URL-Schema ist:
    • subdomain.example.com/username/contacts.vcf/
    • subdomain.example.com/username/calendar.ics/
    • subdomain.example.com/username/memos.ics/
    • subdomain.example.com/username/tasks.ics/
    • Dabei ist die Dateiendung egal. Die habe ich nur rangemacht, dass man weiß, was man hat, wenn man die Datei vom Server kopiert.
    • Wer sich über Memos und Tasks wundert: Ich verwende Radicale z.B. auch für meine Aufgabenliste und meine Notizen unter Evolution.
  • Sollte ein Adressbuch/Kalender noch nicht vorhanden sein, so wird dieses/dieser angelegt.
  • Nach der Installation kann man den Dienst durch den Aufruf der URL subdomain.example.com/public/pub.vcf/ testen.
  • Beachte die Informationen, welche nach der Installation in der Konsole angezeigt werden.
  • Durch die Änderung der Home-Variable, werden alle Installations- und Laufzeit-Dateien in ein separates Verzeichnis geschrieben.
    • Dadurch ist eine einfache, restlose Deinstallation möglich.
  • Für mehr Informationen zu Radicale selbst ist die Project Description hilfreich.
  • Fragen zum Skript kannst du direkt an mich stellen.

Data

Angelegte Dateien und Verzeichnisse:

  • /home/ubername/workspace/radicale
    • Git-Repository.
    • Checkout aus dem Git-Repo.
  • /home/ubername/workspace/radicale-home
    • Darauf wird die $HOME-Variable geändert. Hier werden alle zur Installation und Laufzeit erstellten Dateien, welche normalerweise ins echte Homeverzeichnis geschrieben werden, abgelegt.
    • Beinhaltet auch eine .bashrc, um in die Radicale-“Umgebung” zu wechseln.
  • /home/ubername/workspace/radicale-config
    • Beinhaltet alle Einträge, sog. Collections, Configuration, Rechteverwaltung und die Log-Dateien
  • /var/www/virtual/ubername/subdomain.ubername.uberspace.de/
    • Immer erreichbare Uberspace-Domain für Redicale.
    • Enthält eine .htaccess-Datei, welche erst auf eine https-Verbindung, dann auf den localhost und zum Schluss auf den Radicale-Dienst umleitet.
  • /var/www/virtual/ubername/subdomain.example.com
    • Symbolischer Link auf /var/www/virtual/ubername/subdomain.ubername.uberspace.de/

Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
#!/usr/bin/env bash
################################################################################
# Author: Frank Zisko, 2015
# Version: 1.4.0.3
# Licence: MIT
#
# No warranty! For nothing. Use it at your own risk.
#
# About: Radicale 0.10 installation at an uberspace account.
#        No prerequirements and no needed configuration (like PATHs in .bashrc).
#        Just edit the variables and run this script.
#        For uninstallation give the script the argument 'uninstall'.
################################################################################


### Logging ### ################################################################
# Call this script again with logging parameters.
if [ -z "${IS_CALLED}" ]; then
    export IS_CALLED=1
    # Get script path an set logging file.
    SCRIPT_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/`basename "${BASH_SOURCE[0]}"`
    LOG_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/`basename "${BASH_SOURCE[0]}"`.log
    . ${SCRIPT_PATH} ${1} 2>&1 | tee "${LOG_PATH}"
    # Exit here! If not, you'll go into endless recursive script calls!
    exit
    # Never reach this!
    echo "+++ If you read this line, abort this script immediately! +++"
    echo "+++ ABORT. THIS. SCRIPT. NOW! +++"
fi


### Log ### ####################################################################
JOB_NAME="Install Radicale"
echo " "
echo "### Start Job: ${JOB_NAME} at $(date "+%Y-%m-%dT%H:%M:%S"). ###"
time_begin=$(date +"%s")


### Variables ### ##############################################################
# You just have to adjust these three variables:

   # Subdomain for this service.
   SUBDOMAIN=r
   # Domain. An Uberspace domain (<subdomain>.<uberuser>.<uberserver>.uberspace.de) will be automatically added.
   DOMAINNAME="${SUBDOMAIN}.example.com"
   # Free usable port. Will be tested before the installation.
   PORT=61000


# Project name. Used for installation and "virtual" home dir.
PROJECTNAME=radicale
RADICALE_V=0.10
# Place where all (other) projects are installed.
WORKSPACE=${HOME}/workspace
mkdir -p ${WORKSPACE}

# The real home dir.
REALHOME=${HOME}
# Virtual home dir. It's usen for a clean installation and uninstallation.
VIRTHOME=${WORKSPACE}/${PROJECTNAME}-home
mkdir -p ${WORKSPACE}/${PROJECTNAME}-home
# This home dir.
HOME=${VIRTHOME}

# Paths:
PATH=${HOME}/bin:${HOME}/.local/bin:${PATH}


### Uninstall ### ##############################################################
if [[ ("${1}" == "uninstall") || ("${1}" == "uninstallall") ]]; then
    echo "Uninstallation ..."
    HOME=${REALHOME}

  #### Services ####
    echo "  services ..."

    SVC="${PROJECTNAME}-starter"
    if [ -d "${HOME}/service/${SVC}" ]; then
        cd ${HOME}/service/${SVC}
        svc -dx . log
        rm ${HOME}/service/${SVC}
    fi
    if [ -d "${HOME}/etc/run-${SVC}" ]; then
        rm -rf ${HOME}/etc/run-${SVC}
    fi
    if [ -f "${HOME}/service/${SVC}" ]; then
        rm ${HOME}/service/${SVC}
    fi
    
  #### HTML links ####
    echo "  html links ..."
    if [ -n "${SUBDOMAIN}" ]; then
        if [ -d "/var/www/virtual/${USER}/${SUBDOMAIN}.${USER}.$(hostname -a).uberspace.de" ]; then
            rm -rf /var/www/virtual/${USER}/${SUBDOMAIN}.${USER}.$(hostname -a).uberspace.de
        fi
    fi
    # Prevent deleting ${USER}s www directory, if ${DOMAINNAME} is empty.
    if [ -n "${DOMAINNAME}" ]; then
        if [ -f "/var/www/virtual/${USER}/${DOMAINNAME}" ]; then
            rm /var/www/virtual/${USER}/${DOMAINNAME}
        fi
    fi
  
  #### Installation folder and all its content ####
    # Virtual home directory.
    if [ -d "${WORKSPACE}/${PROJECTNAME}-home" ]; then
      rm -rf ${WORKSPACE}/${PROJECTNAME}-home
    fi
    # Project directory.
    if [ -d "${WORKSPACE}/${PROJECTNAME}" ]; then
      rm -rf ${WORKSPACE}/${PROJECTNAME}
    fi
    # Collections and settings.
    if [[ "${1}" == "uninstallall" ]]; then
        if [ -d "${WORKSPACE}/${PROJECTNAME}-config" ]; then
            rm -rf ${WORKSPACE}/${PROJECTNAME}-config
        fi
    fi
    
  #### End uninstallation ####
    echo "Uninstallation finished."
    exit 0
fi

### Check ### ##################################################################
echo "Checking existing installation ..."

#### Exist ####
# Check existing installation of radicale.
if [ -f ${HOME}/bin/${PROJECTNAME} ]; then
    echo "~/bin/${PROJECTNAME} exists."
    IS_INSTALLED=1
fi
# Check termination condition.
if [ -n "${IS_INSTALLED}" ]; then
    echo "${PROJECTNAME} files found. Maybe it is already installed. Aborting."
    exit 1
fi

echo "Checking server port ..."

#### Port ####
# Check if port is (already) unused.
if [ -z "$(netstat -tulpen | grep ${PORT})" ]; then
    echo "  Your choosen port (${PORT}) is available."
else
    echo "  Your choosen port (${PORT}) is not available. Choose another."
    echo "  Aborting the script."
    exit 2
fi


### Setup environment ### ######################################################
echo "Setup build environment ..."

# When you load this from your shell, you're in the installing environment.
cat > ${HOME}/.bashrc <<__EOF__
SUBDOMAIN=${SUBDOMAIN}
DOMAINNAME=${DOMAINNAME}
PORT=${PORT}
PROJECTNAME=${PROJECTNAME}
WORKSPACE=${WORKSPACE}

# The real home dir.
REALHOME=${REALHOME}
# Virtual home dir.
VIRTHOME=${VIRTHOME}
# This home dir.
HOME=${HOME}
alias getmyhomeback='HOME=${REALHOME}'

RADICALE_CONFIG=${WORKSPACE}/${PROJECTNAME}-config/config
PATH=\${HOME}/bin:\${HOME}/.local/bin:\${PATH}

__EOF__


### Download ### ###############################################################

## Install via archive download.
#echo "Download Radicale and unpacking it ..."
#mkdir -p ${WORKSPACE}; cd ${WORKSPACE}
#wget http://pypi.python.org/packages/source/R/Radicale/Radicale-${RADICALE_V}.tar.gz
#tar xf Radicale-${RADICALE_V}.tar.gz
#mv Radicale-${RADICALE_V} ${PROJECTNAME}
#cd ${WORKSPACE}/${PROJECTNAME}
#echo "Installing Radicale ..."
#python3.4 setup.py install --user &> /dev/null

# Install via git.
echo "Cloneing Radicale directory from repo ..."
git clone git://github.com/Kozea/Radicale.git ${WORKSPACE}/${PROJECTNAME}
cd ${WORKSPACE}/${PROJECTNAME}
git checkout ${RADICALE_V} > /dev/null 2>&1
echo "Installing Radicale ..."
python3.4 setup.py install --user &> /dev/null

## Install using Python Pip.
#echo "Installing Radicale via pip ..."
#pip3.4 install --user radicale==${RADICALE_V}


### Configure ### ##############################################################
echo "Configure Radicale ..."

# Folder for the config symlink.
mkdir -p ${WORKSPACE}/${PROJECTNAME}-home/.config/

# Folder for config , data and log
mkdir -p ${WORKSPACE}/${PROJECTNAME}-config/
mkdir -p ${WORKSPACE}/${PROJECTNAME}-config/collections
mkdir -p ${WORKSPACE}/${PROJECTNAME}-config/log

# Link the storage folder to the virtual home folder.
ln -s ${WORKSPACE}/${PROJECTNAME}-config ${WORKSPACE}/${PROJECTNAME}-home/.config/radicale

#### config ####
cat > ${WORKSPACE}/${PROJECTNAME}-config/config <<__EOF__

# Place it into /etc/radicale/config (global)
# or ~/.config/radicale/config (user)

################################################################################

[server]
# CalDAV server hostnames separated by a comma
# IPv4 syntax: address:port
# IPv6 syntax: [address]:port
# For example: 0.0.0.0:9999, [::]:9999
# IPv6 adresses are configured to only allow IPv6 connections
hosts = localhost:${PORT}
# Daemon flag
daemon = False
# File storing the PID in daemon mode
pid =
# SSL flag, enable HTTPS protocol
ssl = False
# SSL Protocol used. See python's ssl module for available values
protocol = PROTOCOL_SSLv23
# Ciphers available. See python's ssl module for available ciphers
ciphers =
# Reverse DNS to resolve client address in logs
dns_lookup = True
# Root URL of Radicale (starting and ending with a slash)
base_prefix = /
# Possibility to allow URLs cleaned by a HTTP server, without the base_prefix
can_skip_base_prefix = False
# Message displayed in the client when a password is needed
realm = Radicale - Password Required.


[encoding]
# Encoding for responding requests
request = utf-8
# Encoding for storing local collections
stock = utf-8


[auth]
# Authentication method
# Value: None | htpasswd | IMAP | LDAP | PAM | courier | http | remote_user | custom
type = htpasswd

# Htpasswd filename
htpasswd_filename = ~/.config/radicale/users
# Htpasswd encryption method
# Value: plain | sha1 | crypt
htpasswd_encryption = sha1

## LDAP server URL, with protocol and port
#ldap_url = ldap://localhost:389/
## LDAP base path
#ldap_base = ou=users,dc=example,dc=com
## LDAP login attribute
#ldap_attribute = uid
## LDAP filter string
## placed as X in a query of the form (&(...)X)
## example: (objectCategory=Person)(objectClass=User)(memberOf=cn=calenderusers,ou=users,dc=example,dc=org)
## leave empty if no additional filter is needed
#ldap_filter =
## LDAP dn for initial login, used if LDAP server does not allow anonymous searches
## Leave empty if searches are anonymous
#ldap_binddn =
## LDAP password for initial login, used with ldap_binddn
#ldap_password =
## LDAP scope of the search
#ldap_scope = OneLevel

## IMAP Configuration
#imap_hostname = localhost
#imap_port = 143
#imap_ssl = True

## PAM group user should be member of
#pam_group_membership =

## Path to the Courier Authdaemon socket
#courier_socket =

## HTTP authentication request URL endpoint
#http_url =
## POST parameter to use for username
#http_user_parameter =
## POST parameter to use for password
#http_password_parameter =


[rights]
# Rights backend
# Value: None | authenticated | owner_only | owner_write | from_file | custom
type = from_file
# File for rights management from_file
file = ~/.config/radicale/rights


[storage]
# Storage backend
# Value: filesystem | multifilesystem | database | custom
type = filesystem
# Folder for storing local collections, created if not present
filesystem_folder = ~/.config/radicale/collections

## Database URL for SQLAlchemy
## dialect+driver://user:password@host/dbname[?key=value..]
## For example: sqlite:///var/db/radicale.db, postgresql://user:password@localhost/radicale
## See http://docs.sqlalchemy.org/en/rel_0_8/core/engines.html#sqlalchemy.create_engine
#database_url =


[logging]
# Logging configuration file
# If no config is given, simple information is printed on the standard output
# For more information about the syntax of the configuration file, see:
# http://docs.python.org/library/logging.config.html
config = ~/.config/radicale/logging
# Set the default logging level to debug
debug = False
# Store all environment variables (including those set in the shell)
full_environment = False 


# Additional HTTP headers
#[headers]
#Access-Control-Allow-Origin = *

__EOF__

#### users ####
# Edit this file with
# htpasswd -s ${WORKSPACE}/${PROJECTNAME}-config/users newusername
# user: test, pwd : test
cat > ${WORKSPACE}/${PROJECTNAME}-config/users <<'__EOF__'
test:{SHA}qUqP5cyxm6YcTAhz05Hph5gvu9M=
__EOF__


#### rights ####
cat > ${WORKSPACE}/${PROJECTNAME}-config/rights <<__EOF__
# Default path for this kind of files is ~/.config/radicale/rights
# Web: https://docs.python.org/2/howto/regex.html
# Metacharacters:
# . ^ $ * + ? { } [ ] \ | ( )
#
# Test:
# https://${DOMAINNAME}/public/pub.vcf/


### Anonymous user ###
[anonymous]
user: ^
collection: public(/.+)?$
permission: r


### Owner ###
# Give write access to owners
[owner]
user: .+
collection: ^%(login)s/.+$
permission: rw


### Users ###

## User can read and write own files.
#[namename]
#user: ^name.*$
#collection: ^name(/.+)?$
#permission: rw

[publisher]
user: publisher
collection: public(/.+)?$
permission: rw

[testname]
user: testor
collection: testerin/Test\.vcf
permission: r
__EOF__


#### logging ####
cat > ${WORKSPACE}/${PROJECTNAME}-config/logging <<__EOF__
# Logging config file for Radicale - A simple calendar server
#
# The default path for this file is /etc/radicale/logging
# This can be changed in the configuration file
#
# Other handlers are available. For more information, see:
# http://docs.python.org/library/logging.config.html
# https://docs.python.org/3.1/library/logging.html

# Loggers, handlers and formatters keys

[loggers]
# Loggers names, main configuration slots
keys = root

[handlers]
# Logging handlers, defining logging output methods -> # Loggers & # Handlers: handler_<key>
keys = console,file,infofile

[formatters]
# Logging formatters -> # Formatters: formatter_<key>
keys = simple,full

################################################################################

# Loggers

[logger_root]
# Root logger -> # Handlers: handler_<handler>
level = NOTSET
handlers = console,file,infofile

#[logger_parser]
#level = INFO
#handlers = infofile
#propgate=1
#qualname=compiler.parser

################################################################################

# Handlers

[handler_console]
# Console handler.
level = INFO
formatter = simple
#
class = StreamHandler
args = (sys.stdout,)

######################################

[handler_file]
# File handler.
level = DEBUG
formatter = full
#
# class logging.FileHandler(filename, mode='a', encoding=None, delay=0)
# class logging.handlers.RotatingFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=0)
# class logging.handlers.TimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=0, utc=False)
#
#class = FileHandler
#class = handlers.RotatingFileHandler
#class = handlers.TimedRotatingFileHandler
class = handlers.TimedRotatingFileHandler
when='midnight'
interval=1
backupCount=8
#
#args = (os.getenv("HOME")+'/.config/radicale/log/'+os.path.basename(sys.argv[0]).split('.')[0]+'.log', 'D', 15, 'backupCount=30')
args = (os.getenv("HOME")+'/.config/radicale/log/'+os.path.basename(sys.argv[0]).split('.')[0]+'.log',)

######################################

[handler_infofile]
# Second file handler.
level = INFO
formatter = full
#
# class logging.FileHandler(filename, mode='a', encoding=None, delay=0)
# class logging.handlers.RotatingFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=0)
# class logging.handlers.TimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=0, utc=False)
#
#class = FileHandler
#class = handlers.RotatingFileHandler
#class = handlers.TimedRotatingFileHandler
class = handlers.RotatingFileHandler
mode='a'
maxBytes=10240
backupCount=0
#
#args = (os.getenv("HOME")+'/.config/radicale/log/'+os.path.basename(sys.argv[0]).split('.')[0]+'.log', 'D', 15, 'backupCount=30')
args = (os.getenv("HOME")+'/.config/radicale/log/'+os.path.basename(sys.argv[0]).split('.')[0]+'.info',)

################################################################################

# Formatters

[formatter_simple]
# Simple output format
format = %(message)s

[formatter_full]
# Full output format
format = %(asctime)s - %(levelname)s: %(message)s
__EOF__


### Test Entry ### #############################################################
mkdir -p ${WORKSPACE}/${PROJECTNAME}-config/collections/public
cat > ${WORKSPACE}/${PROJECTNAME}-config/collections/public/pub.vcf <<__EOF__
BEGIN:VCARD
VERSION:3.0
TEL;TYPE=WORK,VOICE;X-EVOLUTION-UI-SLOT=1:0123456789
URL:
TITLE:
ROLE:
NICKNAME:
NOTE:
FN:ABC DEF
N:DEF;ABC;;;
X-EVOLUTION-FILE-AS:ABC DEF
CALURI:
FBURL:
X-EVOLUTION-VIDEO-URL:
X-MOZILLA-HTML:FALSE
UID:pas-id-55123D1200000000
REV:1970-01-01T01:01:01Z(1)
END:VCARD
__EOF__
cat > ${WORKSPACE}/${PROJECTNAME}-config/collections/public/pub.vcf.props <<__EOF__
{"tag": "VADDRESSBOOK"}
__EOF__


### Startscripts ### ###########################################################
echo "Create Radicale start script ..."

# Radicale starter.
mkdir -p ${HOME}/bin
cat <<__EOF__ > ${HOME}/bin/${PROJECTNAME}-starter
#!/usr/bin/env bash
HOME=${WORKSPACE}/${PROJECTNAME}-home
PATH=\$HOME/bin:\$HOME/.local/bin:\$PATH
exec radicale
__EOF__
chmod +x ${HOME}/bin/${PROJECTNAME}-starter


### Start Services ### #########################################################
echo "Install Radicale services ..."

# We change $HOME back to the real one.
# We need this for managing the project as service.
HOME=${REALHOME}
test -d ${HOME}/service || uberspace-setup-svscan
uberspace-setup-service ${PROJECTNAME}-starter ${WORKSPACE}/${PROJECTNAME}-home/bin/${PROJECTNAME}-starter &> /dev/null


### Rewrite Proxy ### ##########################################################
echo "Install Radicale apache rewrite proxy ..."

mkdir -p /var/www/virtual/${USER}/${SUBDOMAIN}.${USER}.$(hostname -a).uberspace.de
if [ -n "${DOMAINNAME}" ]; then
    cd /var/www/virtual/${USER}
    ln -s ${SUBDOMAIN}.${USER}.$(hostname -a).uberspace.de ${DOMAINNAME}
fi

cd /var/www/virtual/${USER}/${SUBDOMAIN}.${USER}.$(hostname -a).uberspace.de
cat > .htaccess <<__EOF__
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteRule (.*) http://localhost:${PORT}/\$1 [P]
__EOF__


### Info ### ###################################################################
echo " "
echo "You can use the Radicale server via:"
echo "    https://${DOMAINNAME}/<user>/<contacts>.vcf/"
echo "    https://${DOMAINNAME}/<user>/<calendar>.ics/"
echo "    A test adressbook: https://${DOMAINNAME}/public/pub.vcf/"
echo " "
echo "Add new users via:"
echo "    htpasswd -s ${WORKSPACE}/${PROJECTNAME}-config/users <newuser>"
echo "(Re)Create new users file via:"
echo "    htpasswd -cs ${WORKSPACE}/${PROJECTNAME}-config/users <newuser>"
echo " "
echo "Restart Radicale services:"
echo "    svc -du ~/service/${PROJECTNAME}-starter"
echo "Logs will be written in:"
echo "    ~/service/${PROJECTNAME}-starter/log/main/current"
echo " "
echo "For uninstallation call:"
echo "    $(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/`basename "${BASH_SOURCE[0]}"` uninstall"


### Log ### ####################################################################
echo " "
time_end=$(date +"%s")
time_diff=$((${time_end}-${time_begin}))
echo "### Finished Job: ${JOB_NAME} at $(date "+%Y-%m-%dT%H:%M:%S"). ###"
echo "    $((${time_diff} / 60)) minutes and $((${time_diff} % 60)) seconds elapsed."
echo " " 
################################################################################
################################################################################