mac wrappers and aliases

This commit is contained in:
shocknet-justin 2025-11-26 22:23:30 -05:00
parent 35ac191dd7
commit 740f518895
2 changed files with 60 additions and 6 deletions

View file

@ -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

View file

@ -91,6 +91,46 @@ 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" <<EOF
#!/bin/bash
exec "$HOME/lnd/lnd" "\$@"
EOF
chmod +x "$HOME/.local/bin/LND"
# Lightning.Pub wrapper
cat > "$HOME/.local/bin/Lightning.Pub" <<EOF
#!/bin/bash
export PATH="$NODE_BIN:\$PATH"
cd "$INSTALL_DIR"
exec "$NODE_BIN/npm" start
EOF
chmod +x "$HOME/.local/bin/Lightning.Pub"
# Add aliases to shell profile
local shell_profile="$HOME/.zshrc"
[ -f "$HOME/.bash_profile" ] && ! [ -f "$HOME/.zshrc" ] && shell_profile="$HOME/.bash_profile"
if ! grep -q 'lpub-start' "$shell_profile" 2>/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
@ -103,12 +143,16 @@ create_launchd_plists() {
<string>local.lnd</string>
<key>ProgramArguments</key>
<array>
<string>$HOME/lnd/lnd</string>
<string>$HOME/.local/bin/LND</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>$HOME/Library/Logs/Lightning.Pub/lnd.log</string>
<key>StandardErrorPath</key>
<string>$HOME/Library/Logs/Lightning.Pub/lnd.log</string>
</dict>
</plist>
EOF
@ -125,9 +169,7 @@ EOF
<string>local.lightning_pub</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>source $NVM_DIR/nvm.sh &amp;&amp; npm start</string>
<string>$HOME/.local/bin/Lightning.Pub</string>
</array>
<key>WorkingDirectory</key>
<string>$INSTALL_DIR</string>
@ -135,6 +177,10 @@ EOF
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>$HOME/Library/Logs/Lightning.Pub/pub.log</string>
<key>StandardErrorPath</key>
<string>$HOME/Library/Logs/Lightning.Pub/pub.log</string>
</dict>
</plist>
EOF