Skip to content

Commit

Permalink
Merge pull request #150 from Edirom/issue-120
Browse files Browse the repository at this point in the history
improve error handling within post-install script
  • Loading branch information
peterstadler authored Feb 3, 2023
2 parents 8743041 + 3976047 commit 404b6a7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions post-install.xql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xquery version "1.0";
xquery version "3.1";

import module namespace xdb="http://exist-db.org/xquery/xmldb";
import module namespace util="http://exist-db.org/xquery/util";
Expand Down Expand Up @@ -34,10 +34,19 @@ declare function local:set-admin-password() as empty-sequence() {
return

if($opt = 'MERMEID_admin_password_file') then
if(file:exists(string(environment-variable($opt)))) then sm:passwd('admin', normalize-space(file:read(normalize-space(environment-variable($opt)))))
if(file:exists(string(environment-variable($opt))))
then
try { sm:passwd('admin', normalize-space(file:read(normalize-space(environment-variable($opt))))) }
catch java:org.exist.config.ConfigurationException { util:log-system-out('encountered known error: https://github.com/eXist-db/exist/issues/4722') }
catch * { util:log-system-out('encountered unknown error (' || $err:code || '): ' || $err:description) }
else util:log-system-out(concat('unable to read from file "', normalize-space(environment-variable($opt)), '"'))
else if($opt = 'MERMEID_admin_password') then sm:passwd('admin', string(environment-variable($opt)))
else ()
else
if($opt = 'MERMEID_admin_password')
then
try { sm:passwd('admin', string(environment-variable($opt))) }
catch java:org.exist.config.ConfigurationException { util:log-system-out('encountered known error: https://github.com/eXist-db/exist/issues/4722') }
catch * { util:log-system-out('encountered unknown error (' || $err:code || '): ' || $err:description) }
else ()
};

declare function local:first-run() as xs:boolean {
Expand Down

0 comments on commit 404b6a7

Please sign in to comment.