Skip to content

Commit 5b1bae0

Browse files
Merge branch 'pablo/install-script-macos' into marc/uninstall_macos
2 parents cb34454 + eea2784 commit 5b1bae0

1 file changed

Lines changed: 64 additions & 70 deletions

File tree

scripts/dappnode_install.sh

Lines changed: 64 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,7 @@ else
7272
ARCH=$(dpkg --print-architecture)
7373
fi
7474

75-
# Color output helpers
76-
color_echo() {
77-
local color="$1"; shift
78-
if $IS_LINUX; then
79-
case "$color" in
80-
green) code="\e[32m" ;;
81-
yellow) code="\e[33m" ;;
82-
*) code="" ;;
83-
esac
84-
echo -e "${code}$*\e[0m"
85-
else
86-
echo "$*"
87-
fi
88-
}
75+
8976

9077
##############################
9178
# Cross-platform Helpers #
@@ -95,7 +82,7 @@ color_echo() {
9582
download_file() {
9683
local dest="$1"
9784
local url="$2"
98-
echo "[DEBUG] Downloading from $url to $dest" 2>&1 | tee -a $LOGFILE
85+
echo "Downloading from $url to $dest" 2>&1 | tee -a "$LOGFILE"
9986
if $IS_MACOS; then
10087
curl -sL -o "$dest" "$url"
10188
else
@@ -277,13 +264,13 @@ determine_packages() {
277264
PKGS=(HTTPS BIND IPFS VPN WIREGUARD DAPPMANAGER)
278265
fi
279266
fi
280-
color_echo green "Packages to be installed: ${PKGS[*]}" 2>&1 | tee -a $LOGFILE
267+
echo "Packages to be installed: ${PKGS[*]}" 2>&1 | tee -a "$LOGFILE"
281268

282269
# Debug: print all PKGS and their version variables
283-
echo "[DEBUG] PKGS: ${PKGS[*]}" 2>&1 | tee -a $LOGFILE
270+
echo "PKGS: ${PKGS[*]}" 2>&1 | tee -a "$LOGFILE"
284271
for comp in "${PKGS[@]}"; do
285272
ver_var="${comp}_VERSION"
286-
echo "[DEBUG] $ver_var = ${!ver_var}" 2>&1 | tee -a $LOGFILE
273+
echo "$ver_var = ${!ver_var}" 2>&1 | tee -a "$LOGFILE"
287274
done
288275
}
289276

@@ -315,7 +302,7 @@ fi
315302

316303
# If LOCAL_PROFILE_PATH is set, use it as the profile source instead of downloading
317304
if [ -n "$LOCAL_PROFILE_PATH" ]; then
318-
echo "Using local profile: $LOCAL_PROFILE_PATH" | tee -a $LOGFILE
305+
echo "Using local profile: $LOCAL_PROFILE_PATH" | tee -a "$LOGFILE"
319306
cp "$LOCAL_PROFILE_PATH" "$DAPPNODE_PROFILE"
320307
elif [ ! -f "$DAPPNODE_PROFILE" ]; then
321308
download_file "${DAPPNODE_PROFILE}" "${PROFILE_URL}"
@@ -337,14 +324,14 @@ source "${DAPPNODE_PROFILE}"
337324
determine_packages
338325
for comp in "${PKGS[@]}"; do
339326
ver="${comp}_VERSION"
340-
echo "[DEBUG] Processing $comp: ${!ver}" 2>&1 | tee -a $LOGFILE
327+
echo "Processing $comp: ${!ver}" 2>&1 | tee -a "$LOGFILE"
341328

342329
raw_version_ref="${!ver}"
343330
if [[ "$raw_version_ref" == /ipfs/* || "$raw_version_ref" == ipfs/* ]]; then
344331
resolved_ref="$(normalize_ipfs_version_ref "$raw_version_ref" "$comp")" || exit 1
345332
eval "${comp}_VERSION=\"${resolved_ref}\""
346333
raw_version_ref="$resolved_ref"
347-
echo "[DEBUG] Using IPFS for ${comp}: ${raw_version_ref%:*} (version ${raw_version_ref##*:})" 2>&1 | tee -a $LOGFILE
334+
echo "Using IPFS for ${comp}: ${raw_version_ref%:*} (version ${raw_version_ref##*:})" 2>&1 | tee -a "$LOGFILE"
348335
DOWNLOAD_URL="${IPFS_ENDPOINT%/}${raw_version_ref%:*}"
349336
version_for_filenames="${raw_version_ref##*:}"
350337
else
@@ -428,7 +415,7 @@ dappnode_core_load() {
428415
ver="${comp}_VERSION"
429416
if [[ ${!ver} != dev:* ]]; then
430417
comp_lower=$(echo "$comp" | tr '[:upper:]' '[:lower:]')
431-
eval "[ ! -z \$(docker images -q ${comp_lower}.dnp.dappnode.eth:${!ver##*:}) ] || docker load -i \$${comp}_FILE 2>&1 | tee -a \$LOGFILE"
418+
eval "[ ! -z \$(docker images -q ${comp_lower}.dnp.dappnode.eth:${!ver##*:}) ] || docker load -i \$${comp}_FILE 2>&1 | tee -a \"\$LOGFILE\""
432419
fi
433420
done
434421
}
@@ -459,7 +446,7 @@ generateMotdText() {
459446
|___/\__,_| .__/ .__/_||_\___/\__,_\___|
460447
|_| |_|
461448
EOF
462-
welcome_message="\nChoose a way to connect to your DAppNode, then go to \e[1mhttp://my.dappnode\e[0m\n\n\e[1m- Wifi\e[0m\t\tScan and connect to DAppNodeWIFI. Get wifi credentials with \e[32mdappnode_wifi\e[0m\n\n\e[1m- Local Proxy\e[0m\tConnect to the same router as your DAppNode. Then go to \e[1mhttp://dappnode.local\e[0m\n\n\e[1m- Wireguard\e[0m\tDownload Wireguard app on your device. Get your dappnode wireguard credentials with \e[32mdappnode_wireguard\e[0m\n\n\e[1m- Open VPN\e[0m\tDownload OPen VPN app on your device. Get your openVPN creds with \e[32mdappnode_openvpn\e[0m\n\n\nTo see a full list of commands available execute \e[32mdappnode_help\e[0m\n"
449+
welcome_message="\nChoose a way to connect to your DAppNode, then go to http://my.dappnode\n\n- Wifi\t\tScan and connect to DAppNodeWIFI. Get wifi credentials with dappnode_wifi\n\n- Local Proxy\tConnect to the same router as your DAppNode. Then go to http://dappnode.local\n\n- Wireguard\tDownload Wireguard app on your device. Get your dappnode wireguard credentials with dappnode_wireguard\n\n- Open VPN\tDownload Open VPN app on your device. Get your openVPN creds with dappnode_openvpn\n\n\nTo see a full list of commands available execute dappnode_help\n"
463450
printf "%b" "$welcome_message" >>"${MOTD_FILE}"
464451
}
465452

@@ -486,7 +473,7 @@ addSwap() {
486473

487474
# if not then create it
488475
if [ "$IS_SWAP" -eq 0 ]; then
489-
echo -e '\e[32mSwap not found. Adding swapfile.\e[0m'
476+
echo 'Swap not found. Adding swapfile.'
490477
#RAM=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
491478
#SWAP=$(($RAM * 2))
492479
SWAP=8388608
@@ -496,7 +483,7 @@ addSwap() {
496483
swapon /swapfile
497484
echo '/swapfile none swap defaults 0 0' >>/etc/fstab
498485
else
499-
echo -e '\e[32mSwap found. No changes made.\e[0m'
486+
echo 'Swap found. No changes made.'
500487
fi
501488
}
502489

@@ -545,11 +532,11 @@ add_profile_to_shell() {
545532
}
546533

547534
dappnode_core_start() {
548-
echo -e "\e[32mDAppNode starting...\e[0m" 2>&1 | tee -a $LOGFILE
535+
echo "DAppNode starting..." 2>&1 | tee -a "$LOGFILE"
549536

550537
# Use DNCORE_YMLS from the profile (populated after re-sourcing post-download)
551-
docker compose $DNCORE_YMLS up -d 2>&1 | tee -a $LOGFILE
552-
echo -e "\e[32mDAppNode started\e[0m" 2>&1 | tee -a $LOGFILE
538+
docker compose $DNCORE_YMLS up -d 2>&1 | tee -a "$LOGFILE"
539+
echo "DAppNode started" 2>&1 | tee -a "$LOGFILE"
553540

554541
# Add profile sourcing to user's shell configuration
555542
add_profile_to_shell
@@ -563,17 +550,17 @@ dappnode_core_start() {
563550
# Linux-only: clean up rc.local
564551
if $IS_LINUX; then
565552
if [ -f "/etc/rc.local" ] && [ ! -f "${DAPPNODE_DIR}/.firstboot" ]; then
566-
sed_inplace '/\/usr\/src\/dappnode\/scripts\/dappnode_install.sh/d' /etc/rc.local 2>&1 | tee -a $LOGFILE
553+
sed_inplace '/\/usr\/src\/dappnode\/scripts\/dappnode_install.sh/d' /etc/rc.local 2>&1 | tee -a "$LOGFILE"
567554
fi
568555
fi
569556

570557
# Display help message to the user
571-
echo -e "Execute \e[32mdappnode_help\e[0m to see a full list with commands available"
558+
echo "Execute dappnode_help to see a full list with commands available"
572559
}
573560

574561
installExtraDpkg() {
575562
if [ -d "/usr/src/dappnode/extra_dpkg" ]; then
576-
dpkg -i /usr/src/dappnode/iso/extra_dpkg/*.deb 2>&1 | tee -a $LOGFILE
563+
dpkg -i /usr/src/dappnode/iso/extra_dpkg/*.deb 2>&1 | tee -a "$LOGFILE"
577564
fi
578565
}
579566

@@ -583,7 +570,7 @@ grabContentHashes() {
583570
for comp in "${content_hash_pkgs[@]}"; do
584571
CONTENT_HASH=$(download_stdout "https://github.com/dappnode/DAppNodePackage-${comp}/releases/latest/download/content-hash")
585572
if [ -z "$CONTENT_HASH" ]; then
586-
echo "ERROR! Failed to find content hash of ${comp}." 2>&1 | tee -a $LOGFILE
573+
echo "ERROR! Failed to find content hash of ${comp}." 2>&1 | tee -a "$LOGFILE"
587574
exit 1
588575
fi
589576
echo "${comp}.dnp.dappnode.eth,${CONTENT_HASH}" >>${CONTENT_HASH_FILE}
@@ -595,15 +582,15 @@ grabContentHashes() {
595582
installSgx() {
596583
if [ -d "/usr/src/dappnode/iso/sgx" ]; then
597584
# from sgx_linux_x64_driver_2.5.0_2605efa.bin
598-
/usr/src/dappnode/iso/sgx/sgx_linux_x64_driver.bin 2>&1 | tee -a $LOGFILE
599-
/usr/src/dappnode/iso/sgx/enable_sgx 2>&1 | tee -a $LOGFILE
585+
/usr/src/dappnode/iso/sgx/sgx_linux_x64_driver.bin 2>&1 | tee -a "$LOGFILE"
586+
/usr/src/dappnode/iso/sgx/enable_sgx 2>&1 | tee -a "$LOGFILE"
600587
fi
601588
}
602589

603590
# /extra_dpkg will only be installed on ISO's dappnode not on standalone script
604591
installExtraDpkg() {
605592
if [ -d "/usr/src/dappnode/iso/extra_dpkg" ]; then
606-
dpkg -i /usr/src/dappnode/extra_dpkg/*.deb 2>&1 | tee -a $LOGFILE
593+
dpkg -i /usr/src/dappnode/extra_dpkg/*.deb 2>&1 | tee -a "$LOGFILE"
607594
fi
608595
}
609596

@@ -615,77 +602,78 @@ addUserToDockerGroup() {
615602

616603
# If USER is not found, warn the user and return
617604
if [ -z "$USER" ]; then
618-
echo -e "\e[33mWARN: Default user not found. Could not add it to the docker group.\e[0m" 2>&1 | tee -a $LOGFILE
605+
echo "WARN: Default user not found. Could not add it to the docker group." 2>&1 | tee -a "$LOGFILE"
619606
return
620607
fi
621608

622609
if groups "$USER" | grep &>/dev/null '\bdocker\b'; then
623-
echo -e "\e[32mUser $USER is already in the docker group\e[0m" 2>&1 | tee -a $LOGFILE
610+
echo "User $USER is already in the docker group" 2>&1 | tee -a "$LOGFILE"
624611
return
625612
fi
626613

627614
# This step is already done in the dappnode_install_pre.sh script,
628615
# but it's not working in the Ubuntu ISO because the late-commands in the autoinstall.yaml
629616
# file are executed before the user is created.
630617
usermod -aG docker "$USER"
631-
echo -e "\e[32mUser $USER added to the docker group\e[0m" 2>&1 | tee -a $LOGFILE
618+
echo "User $USER added to the docker group" 2>&1 | tee -a "$LOGFILE"
632619
}
633620

634621
##############################################
635622
#### SCRIPT START ####
636623
##############################################
637624

638-
color_echo green "\n##############################################" 2>&1 | tee -a $LOGFILE
639-
color_echo green "#### DAPPNODE INSTALLER ####" 2>&1 | tee -a $LOGFILE
640-
color_echo green "##############################################" 2>&1 | tee -a $LOGFILE
625+
echo "" 2>&1 | tee -a "$LOGFILE"
626+
echo "##############################################" 2>&1 | tee -a "$LOGFILE"
627+
echo "#### DAPPNODE INSTALLER ####" 2>&1 | tee -a "$LOGFILE"
628+
echo "##############################################" 2>&1 | tee -a "$LOGFILE"
641629

642630
# --- Linux-only setup steps ---
643631
if $IS_LINUX; then
644-
color_echo green "Creating swap memory..." 2>&1 | tee -a $LOGFILE
632+
echo "Creating swap memory..." 2>&1 | tee -a "$LOGFILE"
645633
addSwap
646634

647-
color_echo green "Customizing login..." 2>&1 | tee -a $LOGFILE
635+
echo "Customizing login..." 2>&1 | tee -a "$LOGFILE"
648636
customMotd
649637

650-
color_echo green "Installing extra packages..." 2>&1 | tee -a $LOGFILE
638+
echo "Installing extra packages..." 2>&1 | tee -a "$LOGFILE"
651639
installExtraDpkg
652640

653-
color_echo green "Grabbing latest content hashes..." 2>&1 | tee -a $LOGFILE
641+
echo "Grabbing latest content hashes..." 2>&1 | tee -a "$LOGFILE"
654642
grabContentHashes
655643

656644
if [ "$ARCH" == "amd64" ]; then
657-
color_echo green "Installing SGX modules..." 2>&1 | tee -a $LOGFILE
645+
echo "Installing SGX modules..." 2>&1 | tee -a "$LOGFILE"
658646
installSgx
659647

660-
color_echo green "Installing extra packages..." 2>&1 | tee -a $LOGFILE
648+
echo "Installing extra packages..." 2>&1 | tee -a "$LOGFILE"
661649
installExtraDpkg # TODO: Why is this being called twice?
662650
fi
663651

664-
color_echo green "Adding user to docker group..." 2>&1 | tee -a $LOGFILE
652+
echo "Adding user to docker group..." 2>&1 | tee -a "$LOGFILE"
665653
addUserToDockerGroup
666654
fi
667655

668656
# --- Common steps (Linux and macOS) ---
669-
color_echo green "Creating dncore_network if needed..." 2>&1 | tee -a $LOGFILE
670-
docker network create --driver bridge --subnet 172.33.0.0/16 dncore_network 2>&1 | tee -a $LOGFILE || true
657+
echo "Creating dncore_network if needed..." 2>&1 | tee -a "$LOGFILE"
658+
docker network create --driver bridge --subnet 172.33.0.0/16 dncore_network 2>&1 | tee -a "$LOGFILE" || true
671659

672-
color_echo green "Building DAppNode Core if needed..." 2>&1 | tee -a $LOGFILE
660+
echo "Building DAppNode Core if needed..." 2>&1 | tee -a "$LOGFILE"
673661
dappnode_core_build
674662

675-
color_echo green "Downloading DAppNode Core..." 2>&1 | tee -a $LOGFILE
663+
echo "Downloading DAppNode Core..." 2>&1 | tee -a "$LOGFILE"
676664
dappnode_core_download
677665

678666
# Re-source profile now that compose files exist, so DNCORE_YMLS is populated
679667
# shellcheck disable=SC1090
680668
source "${DAPPNODE_PROFILE}"
681669

682-
color_echo green "Loading DAppNode Core..." 2>&1 | tee -a $LOGFILE
670+
echo "Loading DAppNode Core..." 2>&1 | tee -a "$LOGFILE"
683671
dappnode_core_load
684672

685673
# --- Start DAppNode ---
686674
if $IS_LINUX; then
687675
if [ ! -f "${DAPPNODE_DIR}/.firstboot" ]; then
688-
color_echo green "DAppNode installed" 2>&1 | tee -a $LOGFILE
676+
echo "DAppNode installed" 2>&1 | tee -a "$LOGFILE"
689677
dappnode_core_start
690678
fi
691679

@@ -699,28 +687,34 @@ if $IS_LINUX; then
699687
fi
700688

701689
if $IS_MACOS; then
702-
color_echo green "DAppNode installed" 2>&1 | tee -a $LOGFILE
690+
echo "DAppNode installed" 2>&1 | tee -a "$LOGFILE"
703691
dappnode_core_start
704692

705-
color_echo yellow "\nWaiting for VPN initialization..."
706-
sleep 10
707-
708-
color_echo green "\n##############################################"
709-
color_echo green "# DAppNode VPN Access Credentials #"
710-
color_echo green "##############################################"
711-
echo -e "\nYour DAppNode is ready! Connect using your preferred VPN client."
712-
echo -e "Choose either Wireguard (recommended) or OpenVPN and import the"
713-
echo -e "credentials below into your VPN app to access your DAppNode.\n"
714-
715-
echo -e "--- Wireguard ---"
693+
echo ""
694+
echo "Waiting for VPN initialization..."
695+
sleep 20
696+
697+
echo ""
698+
echo "##############################################"
699+
echo "# DAppNode VPN Access Credentials #"
700+
echo "##############################################"
701+
echo ""
702+
echo "Your DAppNode is ready! Connect using your preferred VPN client."
703+
echo "Choose either Wireguard (recommended) or OpenVPN and import the"
704+
echo "credentials below into your VPN app to access your DAppNode."
705+
echo ""
706+
707+
echo "--- Wireguard ---"
716708
dappnode_wireguard --localhost 2>&1 || \
717-
color_echo yellow "Wireguard credentials not yet available. Try later with: dappnode_wireguard --localhost"
709+
echo "Wireguard credentials not yet available. Try later with: dappnode_wireguard --localhost"
718710

719-
echo -e "\n--- OpenVPN ---"
711+
echo ""
712+
echo "--- OpenVPN ---"
720713
dappnode_openvpn_get dappnode_admin --localhost 2>&1 || \
721-
color_echo yellow "OpenVPN credentials not yet available. Try later with: dappnode_openvpn_get dappnode_admin --localhost"
714+
echo "OpenVPN credentials not yet available. Try later with: dappnode_openvpn_get dappnode_admin --localhost"
722715

723-
echo -e "\nImport the configuration above into your VPN client of choice to access your DAppNode at http://my.dappnode"
716+
echo ""
717+
echo "Import the configuration above into your VPN client of choice to access your DAppNode at http://my.dappnode"
724718
fi
725719

726720
exit 0

0 commit comments

Comments
 (0)