Skip to content

Commit

Permalink
feat: added support for macOS with install.sh (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikreinert authored Jan 17, 2025
1 parent b89a9dd commit af0835f
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/vorpal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ jobs:
sudo mv bwrap /etc/apparmor.d/bwrap
sudo systemctl restart apparmor.service
- run: ./script/install.sh
- run: |
sudo mkdir -pv /var/lib/vorpal/{cache,key,sandbox,store}
sudo chown -R "$(id -u):$(id -g)" /var/lib/vorpal
- run: |
echo "ARCH=$(uname -m | tr '[:upper:]' '[:lower:]' | sed 's/arm64/aarch64/')" >> $GITHUB_ENV
Expand Down
86 changes: 85 additions & 1 deletion script/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,90 @@
#!/bin/bash
set -euo pipefail

# Environment variables
INSTALL_ARCH=$(uname -m | tr '[:upper:]' '[:lower:]' | sed 's/arm64/aarch64/')
INSTALL_DIR="$HOME/.vorpal"
INSTALL_OS=$(uname -s | tr '[:upper:]' '[:lower:]')
INSTALL_VERSION="nightly"
INSTALL_BINARY_URL="https://github.com/ALT-F4-LLC/vorpal/releases/download/$INSTALL_VERSION/vorpal-$INSTALL_ARCH-$INSTALL_OS.tar.gz"

read -p "|> Install script requires sudo permissions. Would you like to continue? (y/n) " -n 1 -r

if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "\nAborting."
exit 1
fi

if [ -d "$INSTALL_DIR" ]; then
echo -e ""
read -p "|> Install path $INSTALL_DIR exists. Would you like to replace? (y/n) " -n 1 -r

if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "\nAborting."
exit 1
fi

rm -rf "$INSTALL_DIR"
fi

echo -e "\n|> Installing in $INSTALL_DIR directory..."

# Setup installation directories
mkdir -p "$INSTALL_DIR/bin"

# Download and extract the Vorpal binary
curl -s -L "$INSTALL_BINARY_URL" | tar xz -C "$INSTALL_DIR/bin"

# Setup directories
sudo mkdir -p /var/lib/vorpal/{cache,key,sandbox,store}
sudo mkdir -pv /var/lib/vorpal/{cache,key,sandbox,store}
sudo chown -R "$(id -u):$(id -g)" /var/lib/vorpal

# Generate a new keypair
echo -e "|> Generating a new keypair..."
"$INSTALL_DIR/bin/vorpal" keys generate

# Setup LaunchAgent for macOS
if [[ $INSTALL_OS == "darwin" ]]; then
echo -e "|> Setting up LaunchAgent for macOS..."

cat <<EOF > "com.altf4llc.vorpal.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Unique identifier for your LaunchAgent -->
<key>Label</key>
<string>com.altf4llc.vorpal</string>
<!-- Path to your Rust binary -->
<key>ProgramArguments</key>
<array>
<string>${INSTALL_DIR}/bin/vorpal</string>
<string>start</string>
</array>
<!-- Start on login/load -->
<key>RunAtLoad</key>
<true/>
<!-- Keep the process alive (restart if it exits) -->
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF

# Move the plist file to the LaunchAgents directory
mv com.altf4llc.vorpal.plist ~/Library/LaunchAgents/
chmod 644 ~/Library/LaunchAgents/com.altf4llc.vorpal.plist

echo -e "|> Starting Vorpal service..."

launchctl unload "$HOME/Library/LaunchAgents/com.altf4llc.vorpal.plist"
launchctl load "$HOME/Library/LaunchAgents/com.altf4llc.vorpal.plist"

echo -e "|> Vorpal service(s) started"
fi

## TODO: implement Linux service setup

0 comments on commit af0835f

Please sign in to comment.