diff --git a/scripts/extract_nprofile.sh b/scripts/extract_nprofile.sh index 704b7b36..c5b86610 100644 --- a/scripts/extract_nprofile.sh +++ b/scripts/extract_nprofile.sh @@ -16,7 +16,11 @@ get_log_info() { fi # Get the modification time of the timestamp file as a UNIX timestamp - ref_timestamp=$(stat -c %Y "$TIMESTAMP_FILE") + if [ "$OS" = "Mac" ]; then + ref_timestamp=$(stat -f %m "$TIMESTAMP_FILE") + else + ref_timestamp=$(stat -c %Y "$TIMESTAMP_FILE") + fi # Wait for a new unlocker log file to be created while [ $(($(date +%s) - START_TIME)) -lt $MAX_WAIT_TIME ]; do @@ -24,7 +28,11 @@ get_log_info() { # Loop through log files and check their modification time for log_file in "${LOG_DIR}/components/"unlocker_*.log; do if [ -f "$log_file" ]; then - file_timestamp=$(stat -c %Y "$log_file") + if [ "$OS" = "Mac" ]; then + file_timestamp=$(stat -f %m "$log_file") + else + file_timestamp=$(stat -c %Y "$log_file") + fi if [ "$file_timestamp" -gt "$ref_timestamp" ]; then latest_unlocker_log="$log_file" break # Found the newest log file diff --git a/scripts/handle_macos.sh b/scripts/handle_macos.sh index 55b33d01..e5a9d9c0 100644 --- a/scripts/handle_macos.sh +++ b/scripts/handle_macos.sh @@ -91,7 +91,47 @@ handle_macos() { create_launchd_plists() { local NVM_DIR="$HOME/.nvm" + local NODE_BIN="$HOME/node/bin" + # Create wrapper scripts so macOS shows proper names in Background Items + mkdir -p "$HOME/.local/bin" + + # LND wrapper + cat > "$HOME/.local/bin/LND" < "$HOME/.local/bin/Lightning.Pub" </dev/null; then + cat >> "$shell_profile" <<'ALIASES' + +# Lightning.Pub service management +alias lpub-start='launchctl load ~/Library/LaunchAgents/local.lightning_pub.plist ~/Library/LaunchAgents/local.lnd.plist' +alias lpub-stop='launchctl unload ~/Library/LaunchAgents/local.lightning_pub.plist ~/Library/LaunchAgents/local.lnd.plist' +alias lpub-restart='lpub-stop; lpub-start' +alias lpub-log='tail -f ~/Library/Logs/Lightning.Pub/pub.log' +alias lnd-log='tail -f ~/Library/Logs/Lightning.Pub/lnd.log' +alias lpub-status='launchctl list | grep local.lightning_pub; launchctl list | grep local.lnd' +ALIASES + fi + + # Create log directory + mkdir -p "$HOME/Library/Logs/Lightning.Pub" + # LND plist if [ ! -f "$LAUNCH_AGENTS_DIR/local.lnd.plist" ]; then cat > "$LAUNCH_AGENTS_DIR/local.lnd.plist" <local.lnd ProgramArguments - $HOME/lnd/lnd + $HOME/.local/bin/LND RunAtLoad KeepAlive + StandardOutPath + $HOME/Library/Logs/Lightning.Pub/lnd.log + StandardErrorPath + $HOME/Library/Logs/Lightning.Pub/lnd.log EOF @@ -125,9 +169,7 @@ EOF local.lightning_pub ProgramArguments - /bin/bash - -c - source $NVM_DIR/nvm.sh && npm start + $HOME/.local/bin/Lightning.Pub WorkingDirectory $INSTALL_DIR @@ -135,6 +177,10 @@ EOF KeepAlive + StandardOutPath + $HOME/Library/Logs/Lightning.Pub/pub.log + StandardErrorPath + $HOME/Library/Logs/Lightning.Pub/pub.log EOF