Skip to content

Commit ebadae4

Browse files
Refactor installation script by removing macOS-specific checks and unused functions
1 parent 70ec401 commit ebadae4

1 file changed

Lines changed: 7 additions & 79 deletions

File tree

scripts/dappnode_install.sh

Lines changed: 7 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -343,28 +343,6 @@ fi
343343
# Cross-platform Helpers #
344344
##############################
345345

346-
# macOS: determine whether we're running on a server-suitable always-on Mac.
347-
# Heuristic: treat Mac mini / Mac Studio / Mac Pro as always-on capable.
348-
# Returns 0 (true) if server-class, 1 otherwise.
349-
is_always_on_mac() {
350-
# Non-macOS hosts are not considered always-on Macs
351-
if ! $IS_MACOS; then
352-
return 1
353-
fi
354-
355-
local model
356-
model="$(sysctl -n hw.model 2>/dev/null)" || return 1
357-
358-
case "$model" in
359-
Macmini*|MacStudio*|MacPro*)
360-
return 0
361-
;;
362-
*)
363-
return 1
364-
;;
365-
esac
366-
}
367-
368346
# Download a file: download_file <destination> <url>
369347
download_file() {
370348
local dest="$1"
@@ -461,6 +439,7 @@ remove_logging_section() {
461439
sed_inplace '/logging/d;/journald/d' "$file"
462440
}
463441

442+
# TODO: review difference between this and patch_compose_paths
464443
# Replace Linux paths with macOS paths in compose files
465444
patch_compose_paths() {
466445
local file="$1"
@@ -511,16 +490,6 @@ patch_dappmanager_compose_for_macos() {
511490
rm -f "$insert_file" || true
512491
}
513492

514-
# TODO: remove once profile macos-compatibility published
515-
# Patch .dappnode_profile for macOS compatibility
516-
patch_profile_for_macos() {
517-
local profile="$1"
518-
# Replace GNU find -printf with POSIX-compatible -exec printf
519-
sed_inplace 's/-printf "-f %p "/-exec printf -- "-f %s " {} \\;/' "$profile"
520-
# Replace hardcoded Linux paths with $HOME-based paths
521-
sed_inplace 's|/usr/src/dappnode|\$HOME/dappnode|g' "$profile"
522-
}
523-
524493
bootstrap_filesystem() {
525494
# Clean if update
526495
if [[ "${UPDATE}" == "true" ]]; then
@@ -546,21 +515,6 @@ bootstrap_filesystem() {
546515
touch "${LOGFILE}" || true
547516
}
548517

549-
# TEMPORARY: think a way to integrate flags instead of use files to detect installation type
550-
is_iso_install() {
551-
# ISO installs are Linux-only
552-
if $IS_MACOS; then
553-
IS_ISO_INSTALL=false
554-
return
555-
fi
556-
# Check old and new location of iso_install.log
557-
if [ -f "${DAPPNODE_DIR}/iso_install.log" ] || [ -f "${DAPPNODE_DIR}/logs/iso_install.log" ]; then
558-
IS_ISO_INSTALL=true
559-
else
560-
IS_ISO_INSTALL=false
561-
fi
562-
}
563-
564518
# Check if port 80 is in use (necessary for HTTPS)
565519
# Returns IS_PORT_USED=true only if port 80 or 443 is used by something OTHER than our HTTPS container
566520
is_port_used() {
@@ -685,31 +639,13 @@ determine_packages() {
685639
return 0
686640
fi
687641

688-
# macOS: package selection depends on whether the Mac is suitable to run always-on.
689-
# - non-server mac: BIND VPN WIREGUARD DAPPMANAGER
690-
# - server mac: BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI HTTPS
691-
# NOTE: HTTPS may be skipped if ports 80/443 are already in use.
692-
if $IS_MACOS; then
693-
is_port_used
694-
695-
if is_always_on_mac; then
696-
if [ "$IS_PORT_USED" == "true" ]; then
697-
PKGS=(BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM)
698-
else
699-
PKGS=(BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI HTTPS NOTIFICATIONS PREMIUM)
700-
fi
701-
else
702-
PKGS=(BIND VPN WIREGUARD DAPPMANAGER NOTIFICATIONS PREMIUM)
703-
fi
642+
# Default mode (no --packages/--minimal/--lite): install full package set.
643+
# HTTPS is included only when ports 80/443 are available.
644+
is_port_used
645+
if [ "$IS_PORT_USED" == "true" ]; then
646+
PKGS=(BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM)
704647
else
705-
# Linux / ISO logic
706-
is_iso_install
707-
is_port_used
708-
if [ "$IS_PORT_USED" == "true" ]; then
709-
PKGS=(BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM)
710-
else
711-
PKGS=(HTTPS BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM)
712-
fi
648+
PKGS=(HTTPS BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM)
713649
fi
714650

715651
log "Packages to be installed: ${PKGS[*]}"
@@ -757,18 +693,10 @@ ensure_profile_loaded() {
757693
download_file "${DAPPNODE_PROFILE}" "${PROFILE_URL}"
758694
fi
759695

760-
# Patch profile for macOS compatibility (replace GNU-isms and hardcoded Linux paths)
761-
# TODO: remove once profile macos-compatibility published
762-
if $IS_MACOS; then
763-
patch_profile_for_macos "$DAPPNODE_PROFILE"
764-
fi
765-
766696
# shellcheck disable=SC1090
767697
source "${DAPPNODE_PROFILE}"
768698
}
769699

770-
771-
772700
resolve_packages() {
773701
# The indirect variable expansion used in ${!ver##*:} allows us to use versions like 'dev:development'
774702
# If such variable with 'dev:'' suffix is used, then the component is built from specified branch or commit.

0 commit comments

Comments
 (0)