-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-join.sh
206 lines (178 loc) · 8.77 KB
/
03-join.sh
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
#!/bin/bash
# join
# outer script
VERSION=3
SERVICE="ownCloud"
. /usr/share/univention-join/joinscripthelper.lib
. /usr/share/univention-appcenter/joinscripthelper.sh
. /usr/share/univention-lib/all.sh
joinscript_init
eval "$(ucr shell)"
ucs_addServiceToLocalhost ${SERVICE} "$@" || die
ICON_PATH="/univention/js/dijit/themes/umc/icons/scalable/apps-"$(univention-app get owncloud component_id --values-only)".svg"
echo "[03.JOIN] Creating ownCloud admin docs..."
OVBASE="ucs/web/overview/entries/admin/owncloud-admindoc"
ucr set \
${OVBASE}/description="ownCloud Administration Manual" \
${OVBASE}/description/de="ownCloud Administrations-Handbuch (in Englisch)" \
${OVBASE}/icon="$ICON_PATH" \
${OVBASE}/label?"Admin Manual" \
${OVBASE}/label/de?"Admin Handbuch" \
${OVBASE}/link="https://doc.owncloud.com/server/10.0/admin_manual/" \
${OVBASE}/priority?95
echo "[03.JOIN] Creating ownCloud user docs..."
OVBASE="ucs/web/overview/entries/admin/owncloud-userdoc"
ucr set \
${OVBASE}/description="ownCloud User Manual" \
${OVBASE}/description/de="ownCloud Benutzer-Handbuch (in Englisch)" \
${OVBASE}/icon="$ICON_PATH" \
${OVBASE}/label?"User Manual" \
${OVBASE}/label/de?"Benutzer Handbuch" \
${OVBASE}/link="https://doc.owncloud.com/server/10.0/user_manual/" \
${OVBASE}/priority?100
ucs_unregisterLDAPExtension "$@" --schema owncloud
joinscript_register_schema "$@" || die
univention-directory-manager container/cn create "$@" --ignore_exists \
--position "cn=custom attributes,cn=univention,$ldap_base" \
--set name=owncloud
univention-directory-manager settings/extended_attribute create "$@" \
--position "cn=owncloud,cn=custom attributes,cn=univention,$ldap_base" --set module="users/user" \
--set ldapMapping='ownCloudEnabled' \
--set objectClass='ownCloudUser' \
--set name='ownCloudUserEnabled' \
--set shortDescription='ownCloud enabled' \
--set longDescription='Wether User may use ownCloud ' \
--set translationShortDescription='"de_DE" "ownCloud aktiviert"' \
--set translationLongDescription='"de_DE" "Der User darf ownCloud verwenden"' \
--set tabName='ownCloud' \
--set translationTabName='"de_DE" "ownCloud"' \
--set overwriteTab='0' \
--set valueRequired='0' \
--set CLIName='owncloudEnabled' \
--set syntax='boolean' \
--set default="$owncloud_user_enabled" \
--set tabAdvanced='1' \
--set mayChange='1' \
--set multivalue='0' \
--set deleteObjectClass='0' \
--set tabPosition='1' \
--set overwritePosition='0' \
--set doNotSearch='0' \
--set hook='None' || \
univention-directory-manager settings/extended_attribute modify "$@" \
--dn "cn=ownCloudUserEnabled,cn=owncloud,cn=custom attributes,cn=univention,$ldap_base" \
--set tabAdvanced='1' \
--set default="$owncloud_user_enabled"
univention-directory-manager settings/extended_attribute create "$@" \
--position "cn=owncloud,cn=custom attributes,cn=univention,$ldap_base" --set module="users/user" \
--set ldapMapping='ownCloudQuota' \
--set objectClass='ownCloudUser' \
--set name='ownCloudUserQuota' \
--set shortDescription='ownCloud Quota' \
--set longDescription='How much disk space may the user use' \
--set translationShortDescription='"de_DE" "ownCloud Quota"' \
--set translationLongDescription='"de_DE" "Wie viel Speicherplatz darf der User verwenden"' \
--set tabName='ownCloud' \
--set translationTabName='"de_DE" "ownCloud"' \
--set overwriteTab='0' \
--set valueRequired='0' \
--set CLIName='owncloudQuota' \
--set syntax='string' \
--set default="$owncloud_user_quota" \
--set tabAdvanced='1' \
--set mayChange='1' \
--set multivalue='0' \
--set deleteObjectClass='0' \
--set tabPosition='1' \
--set overwritePosition='0' \
--set doNotSearch='0' \
--set hook='None' || \
univention-directory-manager settings/extended_attribute modify "$@" \
--dn "cn=ownCloudUserQuota,cn=owncloud,cn=custom attributes,cn=univention,$ldap_base" \
--set tabAdvanced='1'
univention-directory-manager settings/extended_attribute create "$@" \
--position "cn=owncloud,cn=custom attributes,cn=univention,$ldap_base" --set module="groups/group" \
--set ldapMapping='ownCloudEnabled' \
--set objectClass='ownCloudGroup' \
--set name='ownCloudGroupEnabled' \
--set shortDescription='ownCloud enabled' \
--set longDescription='Wether Group may be used in ownCloud ' \
--set translationShortDescription='"de_DE" "ownCloud aktiviert"' \
--set translationLongDescription='"de_DE" "Die Gruppe in ownCloud verwenden"' \
--set tabName='ownCloud' \
--set translationTabName='"de_DE" "ownCloud"' \
--set overwriteTab='0' \
--set valueRequired='0' \
--set CLIName='owncloudEnabled' \
--set syntax='boolean' \
--set default="$owncloud_group_enabled" \
--set tabAdvanced='0' \
--set mayChange='1' \
--set multivalue='0' \
--set deleteObjectClass='0' \
--set tabPosition='1' \
--set overwritePosition='0' \
--set doNotSearch='0' \
--set hook='None' || \
univention-directory-manager settings/extended_attribute modify "$@" \
--dn "cn=ownCloudGroupEnabled,cn=owncloud,cn=custom attributes,cn=univention,$ldap_base" \
--set tabAdvanced='1'
# Create OpenID Connect relying party entry in UCS
if ! univention-app shell owncloud grep OWNCLOUD_OPENID_CLIENT_ID /etc/univention/base.conf > /dev/null; then
univention-app shell owncloud bash -c 'printf "\nOWNCLOUD_OPENID_CLIENT_ID: owncloud" >> /etc/univention/base.conf'
fi
# If no shared secret is set, set it in the owncloud container
shared_secret="undefined"
if univention-app shell owncloud grep "OWNCLOUD_OPENID_CLIENT_SECRET: AVeryLongStringThatGetsSetDuringInstallation" /etc/univention/base.conf > /dev/null; then
shared_secret="$(create_machine_password)"
univention-app shell owncloud bash -c "printf '\nOWNCLOUD_OPENID_CLIENT_SECRET: ${shared_secret}' >> /etc/univention/base.conf"
else
shared_secret="$(univention-app shell owncloud grep 'OWNCLOUD_OPENID_CLIENT_SECRET:' /etc/univention/base.conf 2>&1 | sed -e 's/OWNCLOUD_OPENID_CLIENT_SECRET: //g')"
fi
univention-app configure owncloud
oidc_server="$(univention-ldapsearch -LLL univentionService='OpenID Connect Provider' cn | grep '^cn: ' | sed s/'^cn: '// | head -n1)"
# the udm module is only available if the OIDC identity provider is installed
if [ -n "$oidc_server" ]; then
udm oidc/rpservice create "$@" --ignore_exists \
--position="cn=oidc,cn=univention,$(ucr get ldap/base)" \
--set name="owncloud" \
--set clientid="owncloud" \
--set clientsecret="${shared_secret}" \
--set trusted=yes \
--set applicationtype=web \
--set redirectURI="https://${hostname}.${domainname}/owncloud/apps/openidconnect/redirect" || die
# Update client secret in case object exists and secret changed
udm oidc/rpservice modify "$@" --dn "cn=owncloud,cn=oidc,cn=univention,${ldap_base}" --set clientsecret="${shared_secret}"
else
echo "No OpenID Connect Provider is installed in domain, cannot create service entry. Install OIDC App and rerun joinscript"
fi
OWNCLOUD_PERM_DIR="/var/lib/univention-appcenter/apps/owncloud"
OWNCLOUD_DATA="${OWNCLOUD_PERM_DIR}/data"
OWNCLOUD_CONF="${OWNCLOUD_PERM_DIR}/conf"
OWNCLOUD_CONF_LDAP="${OWNCLOUD_CONF}/ldap"
OWNCLOUD_BACKUP_DIR="${OWNCLOUD_DATA}/backup"
#echo "[03.JOIN] database check"
#mysql -uroot -p$(cat /etc/mysql.secret) -e "show databases" >> /root/databasecheck
#mysql -uroot -p$(cat /etc/mysql.secret) owncloud < ${OWNCLOUD_BACKUP_DIR}/database.sql
FQDN="$(ucr get hostname).$(ucr get domainname)"
if [ "$(ucr get appcenter/apps/onlyoffice-ds/status)" = "installed" ] || [ "$(ucr get appcenter/apps/onlyoffice-ds-integration/status)" = "installed" ]; then
echo "[03.JOIN] check for installation of ONLYOFFICE"
univention-app shell owncloud occ app:enable onlyoffice
if [[ "$(univention-app shell owncloud occ config:app:get onlyoffice DocumentServerUrl)" == "" ]]; then
univention-app shell owncloud occ config:app:set onlyoffice DocumentServerUrl --value="https://$FQDN/onlyoffice-documentserver"
fi
fi
if [ "$(ucr get appcenter/apps/collabora/status)" = "installed" ] || [ "$(ucr get appcenter/apps/collabora-online/status)" = "installed" ]; then
echo "[03.JOIN] check for installation of Collabora"
univention-app shell owncloud occ app:enable richdocuments
if [[ "$(univention-app shell owncloud occ config:app:get richdocuments wopi_url)" == "" ]]; then
univention-app shell owncloud occ config:app:set richdocuments wopi_url --value https://"$FQDN"/
fi
fi
joinscript_save_current_version
# Make Appliance Administrator=ownCloud Administrator
udm users/user modify --dn=uid=Administrator,cn=users,$(ucr get ldap/base) --set owncloudEnabled=1
echo "Adding Administrator account in to the ownCloud group..."
univention-app shell owncloud occ user:sync "OCA\User_LDAP\User_Proxy" -m remove
univention-app shell owncloud occ group:add-member --member Administrator admin
exit 0