mac wrappers and aliases
This commit is contained in:
parent
35ac191dd7
commit
740f518895
2 changed files with 60 additions and 6 deletions
|
|
@ -16,7 +16,11 @@ get_log_info() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the modification time of the timestamp file as a UNIX timestamp
|
# Get the modification time of the timestamp file as a UNIX timestamp
|
||||||
|
if [ "$OS" = "Mac" ]; then
|
||||||
|
ref_timestamp=$(stat -f %m "$TIMESTAMP_FILE")
|
||||||
|
else
|
||||||
ref_timestamp=$(stat -c %Y "$TIMESTAMP_FILE")
|
ref_timestamp=$(stat -c %Y "$TIMESTAMP_FILE")
|
||||||
|
fi
|
||||||
|
|
||||||
# Wait for a new unlocker log file to be created
|
# Wait for a new unlocker log file to be created
|
||||||
while [ $(($(date +%s) - START_TIME)) -lt $MAX_WAIT_TIME ]; do
|
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
|
# Loop through log files and check their modification time
|
||||||
for log_file in "${LOG_DIR}/components/"unlocker_*.log; do
|
for log_file in "${LOG_DIR}/components/"unlocker_*.log; do
|
||||||
if [ -f "$log_file" ]; then
|
if [ -f "$log_file" ]; then
|
||||||
|
if [ "$OS" = "Mac" ]; then
|
||||||
|
file_timestamp=$(stat -f %m "$log_file")
|
||||||
|
else
|
||||||
file_timestamp=$(stat -c %Y "$log_file")
|
file_timestamp=$(stat -c %Y "$log_file")
|
||||||
|
fi
|
||||||
if [ "$file_timestamp" -gt "$ref_timestamp" ]; then
|
if [ "$file_timestamp" -gt "$ref_timestamp" ]; then
|
||||||
latest_unlocker_log="$log_file"
|
latest_unlocker_log="$log_file"
|
||||||
break # Found the newest log file
|
break # Found the newest log file
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,46 @@ handle_macos() {
|
||||||
|
|
||||||
create_launchd_plists() {
|
create_launchd_plists() {
|
||||||
local NVM_DIR="$HOME/.nvm"
|
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
|
# LND plist
|
||||||
if [ ! -f "$LAUNCH_AGENTS_DIR/local.lnd.plist" ]; then
|
if [ ! -f "$LAUNCH_AGENTS_DIR/local.lnd.plist" ]; then
|
||||||
|
|
@ -103,12 +143,16 @@ create_launchd_plists() {
|
||||||
<string>local.lnd</string>
|
<string>local.lnd</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>$HOME/lnd/lnd</string>
|
<string>$HOME/.local/bin/LND</string>
|
||||||
</array>
|
</array>
|
||||||
<key>RunAtLoad</key>
|
<key>RunAtLoad</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>KeepAlive</key>
|
<key>KeepAlive</key>
|
||||||
<true/>
|
<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>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
EOF
|
EOF
|
||||||
|
|
@ -125,9 +169,7 @@ EOF
|
||||||
<string>local.lightning_pub</string>
|
<string>local.lightning_pub</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>/bin/bash</string>
|
<string>$HOME/.local/bin/Lightning.Pub</string>
|
||||||
<string>-c</string>
|
|
||||||
<string>source $NVM_DIR/nvm.sh && npm start</string>
|
|
||||||
</array>
|
</array>
|
||||||
<key>WorkingDirectory</key>
|
<key>WorkingDirectory</key>
|
||||||
<string>$INSTALL_DIR</string>
|
<string>$INSTALL_DIR</string>
|
||||||
|
|
@ -135,6 +177,10 @@ EOF
|
||||||
<true/>
|
<true/>
|
||||||
<key>KeepAlive</key>
|
<key>KeepAlive</key>
|
||||||
<true/>
|
<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>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
EOF
|
EOF
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue