@@ -219,20 +219,20 @@ export const configureNextcloud = async function(apps = ['viewer'], vendoredBran
219219
220220 console . log ( '\nConfiguring Nextcloud…' )
221221 container = container ?? getContainer ( )
222- await runExec ( container , [ 'php' , 'occ' , '--version' ] , true )
222+ await runOcc ( container , [ '--version' ] , true )
223223
224224 // Be consistent for screenshots
225- await runExec ( container , [ 'php' , 'occ' , 'config:system:set' , ' default_language', '--value' , ' en'] , true )
226- await runExec ( container , [ 'php' , 'occ' , 'config:system:set' , ' force_language', '--value' , ' en'] , true )
227- await runExec ( container , [ 'php' , 'occ' , 'config:system:set' , ' default_locale', '--value' , ' en_US'] , true )
228- await runExec ( container , [ 'php' , 'occ' , 'config:system:set' , ' force_locale', '--value' , ' en_US'] , true )
229- await runExec ( container , [ 'php' , 'occ' , 'config:system:set' , ' enforce_theme', '--value' , ' light'] , true )
225+ await setSystemConfig ( container , ' default_language', 'en' )
226+ await setSystemConfig ( container , ' force_language', 'en' )
227+ await setSystemConfig ( container , ' default_locale', 'en_US' )
228+ await setSystemConfig ( container , ' force_locale', 'en_US' )
229+ await setSystemConfig ( container , ' enforce_theme', 'light' )
230230
231231 // Checking apcu
232232 console . log ( '├─ Checking APCu configuration... 👀' )
233- const distributed = await runExec ( container , [ 'php' , 'occ' , 'config:system:get' , ' memcache.distributed'] )
234- const local = await runExec ( container , [ 'php' , 'occ' , 'config:system:get' , ' memcache.local'] )
235- const hashing = await runExec ( container , [ 'php' , 'occ' , 'config:system:get' , ' hashing_default_password'] )
233+ const distributed = await getSystemConfig ( container , ' memcache.distributed')
234+ const local = await getSystemConfig ( container , ' memcache.local')
235+ const hashing = await getSystemConfig ( container , ' hashing_default_password')
236236 if ( ! distributed . includes ( 'Memcache\\APCu' )
237237 || ! local . includes ( 'Memcache\\APCu' )
238238 || ! hashing . includes ( 'true' ) ) {
@@ -242,7 +242,7 @@ export const configureNextcloud = async function(apps = ['viewer'], vendoredBran
242242 console . log ( '│ └─ OK !' )
243243
244244 // Build app list
245- const json = await runExec ( container , [ 'php' , 'occ' , 'app:list' , '--output' , 'json' ] , false )
245+ const json = await runOcc ( container , [ 'app:list' , '--output' , 'json' ] , false )
246246 // fix dockerode bug returning invalid leading characters
247247 const applist = JSON . parse ( json . substring ( json . indexOf ( '{' ) ) )
248248
@@ -252,14 +252,14 @@ export const configureNextcloud = async function(apps = ['viewer'], vendoredBran
252252 console . log ( `├─ ${ app } version ${ applist . enabled [ app ] } already installed and enabled` )
253253 } else if ( app in applist . disabled ) {
254254 // built in or mounted already as the app under development
255- await runExec ( container , [ 'php' , 'occ' , 'app:enable' , '--force' , app ] , true )
255+ await runOcc ( container , [ 'app:enable' , '--force' , app ] , true )
256256 } else if ( app in VENDOR_APPS ) {
257257 // apps that are vendored but still missing (i.e. not build in or mounted already)
258258 await runExec ( container , [ 'git' , 'clone' , '--depth=1' , `--branch=${ vendoredBranch } ` , VENDOR_APPS [ app ] , `apps/${ app } ` ] , true )
259- await runExec ( container , [ 'php' , 'occ' , 'app:enable' , '--force' , app ] , true )
259+ await runOcc ( container , [ 'app:enable' , '--force' , app ] , true )
260260 } else {
261261 // try appstore
262- await runExec ( container , [ 'php' , 'occ' , 'app:install' , '--force' , app ] , true )
262+ await runOcc ( container , [ 'app:install' , '--force' , app ] , true )
263263 }
264264 }
265265 console . log ( '└─ Nextcloud is now ready to use 🎉' )
@@ -356,7 +356,7 @@ export const waitOnNextcloud = async function(ip: string) {
356356 console . log ( '└─ Done' )
357357}
358358
359- const runExec = async function (
359+ export const runExec = async function (
360360 container : Docker . Container ,
361361 command : string [ ] ,
362362 verbose = false ,
@@ -397,6 +397,30 @@ const runExec = async function(
397397 } )
398398}
399399
400+ export const runOcc = function (
401+ container : Docker . Container ,
402+ command : string [ ] ,
403+ verbose = false ,
404+ env : string [ ] = [ ] ,
405+ ) {
406+ return runExec ( container , [ 'php' , 'occ' , ...command ] , verbose , 'www-data' , env )
407+ }
408+
409+ export const setSystemConfig = function (
410+ container : Docker . Container ,
411+ key : string ,
412+ value : string ,
413+ ) {
414+ return runOcc ( container , [ 'config:system:set' , key , '--value' , value ] , true )
415+ }
416+
417+ export const getSystemConfig = function (
418+ container : Docker . Container ,
419+ key : string ,
420+ ) {
421+ return runOcc ( container , [ 'config:system:get' , key ] )
422+ }
423+
400424const sleep = function ( milliseconds : number ) {
401425 return new Promise ( ( resolve ) => setTimeout ( resolve , milliseconds ) )
402426}
0 commit comments