@@ -363,6 +363,55 @@ patch_profile_for_macos() {
363363 sed_inplace ' s|/usr/src/dappnode|\$HOME/dappnode|g' " $profile "
364364}
365365
366+ # macOS (non-server): ensure dappmanager uses remote IPFS services.
367+ # This updates ${DAPPNODE_CORE_DIR}/maindb.json with:
368+ # "ipfs-gateway": "https://ipfs-gateway.dappnode.net"
369+ # "ipfs-client-target": "remote"
370+ patch_maindb_for_macos_nonserver () {
371+ if ! $IS_MACOS ; then
372+ return 0
373+ fi
374+
375+ local maindb_file=" ${DAPPNODE_CORE_DIR} /maindb.json"
376+ if [[ ! -f " $maindb_file " ]]; then
377+ warn " macOS non-server: maindb.json not found at ${maindb_file} ; skipping"
378+ return 0
379+ fi
380+
381+ log " macOS non-server: patching maindb.json to use remote IPFS"
382+
383+ if ! command -v osascript > /dev/null 2>&1 ; then
384+ die " macOS non-server: cannot patch maindb.json (missing 'osascript')"
385+ fi
386+
387+ osascript -l JavaScript - " $maindb_file " << 'JXA '
388+ ObjC.import('Foundation');
389+
390+ function run(argv) {
391+ var path = argv[0];
392+ if (!path) throw new Error('Missing maindb.json path');
393+
394+ var data = $.NSData.dataWithContentsOfFile(path);
395+ if (!data) throw new Error('Unable to read file: ' + path);
396+
397+ var content = ObjC.unwrap($.NSString.alloc.initWithDataEncoding(data, $.NSUTF8StringEncoding));
398+ var obj = JSON.parse(content);
399+ if (Object.prototype.toString.call(obj) !== '[object Object]') {
400+ throw new Error('maindb.json is not a JSON object: ' + path);
401+ }
402+
403+ obj['ipfs-gateway'] = 'https://ipfs-gateway.dappnode.net';
404+ obj['ipfs-client-target'] = 'remote';
405+
406+ var out = JSON.stringify(obj, null, 2) + '\n';
407+ var outStr = $.NSString.stringWithString(out);
408+ var ok = outStr.writeToFileAtomicallyEncodingError(path, true, $.NSUTF8StringEncoding, null);
409+ if (!ok) throw new Error('Unable to write file: ' + path);
410+ }
411+ JXA
412+ return 0
413+ }
414+
366415bootstrap_filesystem () {
367416 # Clean if update
368417 if [[ " ${UPDATE} " == " true" ]]; then
@@ -911,6 +960,11 @@ main() {
911960 echo " DAppNode installed" 2>&1 | tee -a " $LOGFILE "
912961 dappnode_core_start
913962
963+ # macOS non-server machines should not try to use local IPFS.
964+ if ! is_always_on_mac; then
965+ patch_maindb_for_macos_nonserver
966+ fi
967+
914968 echo " "
915969 echo " Waiting for VPN initialization..."
916970 wait_for_internal_ip " DAppNodeCore-dappmanager.dnp.dappnode.eth" 120 10
0 commit comments