tractatus/.credential-vault/install-systemd-service.sh
TheFlow ac2db33732 fix(submissions): restructure Economist package and fix article display
- Create Economist SubmissionTracking package correctly:
  * mainArticle = full blog post content
  * coverLetter = 216-word SIR— letter
  * Links to blog post via blogPostId
- Archive 'Letter to The Economist' from blog posts (it's the cover letter)
- Fix date display on article cards (use published_at)
- Target publication already displaying via blue badge

Database changes:
- Make blogPostId optional in SubmissionTracking model
- Economist package ID: 68fa85ae49d4900e7f2ecd83
- Le Monde package ID: 68fa2abd2e6acd5691932150

Next: Enhanced modal with tabs, validation, export

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 08:47:42 +13:00

147 lines
4.9 KiB
Bash
Executable file

#!/bin/bash
# Install Credential Vault as systemd service
# This makes the vault available 24/7 across all projects
set -e
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
SERVICE_NAME="credential-vault"
SERVICE_FILE="credential-vault.service"
SYSTEMD_USER_DIR="$HOME/.config/systemd/user"
VAULT_DIR="$HOME/projects/tractatus/.credential-vault"
echo -e "${YELLOW}═══════════════════════════════════════════════════════════${NC}"
echo -e "${YELLOW} CREDENTIAL VAULT - SYSTEMD SERVICE INSTALLATION${NC}"
echo -e "${YELLOW}═══════════════════════════════════════════════════════════${NC}"
echo ""
# Step 1: Check prerequisites
echo -e "${BLUE}[1/6] Checking prerequisites...${NC}"
if [ ! -f "$VAULT_DIR/$SERVICE_FILE" ]; then
echo -e "${RED}✗ Service file not found: $VAULT_DIR/$SERVICE_FILE${NC}"
exit 1
fi
if [ ! -f "$VAULT_DIR/server.js" ]; then
echo -e "${RED}✗ Server file not found: $VAULT_DIR/server.js${NC}"
exit 1
fi
if [ ! -f "$HOME/Documents/credentials/vault.kdbx" ]; then
echo -e "${YELLOW}⚠ Vault database not found${NC}"
echo -e "${YELLOW} Run: ~/Documents/credentials/scripts/create-vault.sh${NC}"
read -p "Continue anyway? (yes/NO): " continue_anyway
if [ "$continue_anyway" != "yes" ]; then
exit 1
fi
fi
echo -e "${GREEN}✓ Prerequisites met${NC}"
echo ""
# Step 2: Install Node.js dependencies
echo -e "${BLUE}[2/6] Installing Node.js dependencies...${NC}"
cd "$VAULT_DIR"
if [ ! -d "node_modules" ]; then
npm install
echo -e "${GREEN}✓ Dependencies installed${NC}"
else
echo -e "${GREEN}✓ Dependencies already installed${NC}"
fi
echo ""
# Step 3: Create systemd user directory
echo -e "${BLUE}[3/6] Creating systemd user directory...${NC}"
mkdir -p "$SYSTEMD_USER_DIR"
echo -e "${GREEN}✓ Directory created: $SYSTEMD_USER_DIR${NC}"
echo ""
# Step 4: Copy service file
echo -e "${BLUE}[4/6] Installing service file...${NC}"
if [ -f "$SYSTEMD_USER_DIR/$SERVICE_FILE" ]; then
echo -e "${YELLOW}⚠ Service file already exists${NC}"
read -p "Overwrite? (yes/NO): " overwrite
if [ "$overwrite" != "yes" ]; then
echo "Installation cancelled"
exit 0
fi
fi
cp "$VAULT_DIR/$SERVICE_FILE" "$SYSTEMD_USER_DIR/$SERVICE_FILE"
echo -e "${GREEN}✓ Service file installed: $SYSTEMD_USER_DIR/$SERVICE_FILE${NC}"
echo ""
# Step 5: Reload systemd and enable service
echo -e "${BLUE}[5/6] Configuring systemd...${NC}"
# Reload systemd to recognize new service
systemctl --user daemon-reload
echo -e "${GREEN}✓ systemd reloaded${NC}"
# Enable service to start on boot
systemctl --user enable "$SERVICE_NAME"
echo -e "${GREEN}✓ Service enabled (will start on boot)${NC}"
echo ""
# Step 6: Start service
echo -e "${BLUE}[6/6] Starting service...${NC}"
# Check if already running
if systemctl --user is-active --quiet "$SERVICE_NAME"; then
echo -e "${YELLOW}⚠ Service already running${NC}"
read -p "Restart service? (yes/NO): " restart
if [ "$restart" = "yes" ]; then
systemctl --user restart "$SERVICE_NAME"
echo -e "${GREEN}✓ Service restarted${NC}"
fi
else
systemctl --user start "$SERVICE_NAME"
echo -e "${GREEN}✓ Service started${NC}"
fi
# Wait a moment for service to initialize
sleep 2
# Check status
if systemctl --user is-active --quiet "$SERVICE_NAME"; then
echo -e "${GREEN}✓ Service is running${NC}"
else
echo -e "${RED}✗ Service failed to start${NC}"
echo ""
echo "Check logs with:"
echo " journalctl --user -u $SERVICE_NAME -n 50"
exit 1
fi
echo ""
echo -e "${YELLOW}═══════════════════════════════════════════════════════════${NC}"
echo -e "${YELLOW} INSTALLATION COMPLETE${NC}"
echo -e "${YELLOW}═══════════════════════════════════════════════════════════${NC}"
echo ""
echo "Service Status:"
systemctl --user status "$SERVICE_NAME" --no-pager | head -10
echo ""
echo "Access vault at: ${GREEN}http://127.0.0.1:8888${NC}"
echo ""
echo "Management commands:"
echo " systemctl --user status $SERVICE_NAME # Check status"
echo " systemctl --user restart $SERVICE_NAME # Restart service"
echo " systemctl --user stop $SERVICE_NAME # Stop service"
echo " systemctl --user start $SERVICE_NAME # Start service"
echo " journalctl --user -u $SERVICE_NAME -f # View live logs"
echo ""
echo "Uninstall:"
echo " systemctl --user stop $SERVICE_NAME"
echo " systemctl --user disable $SERVICE_NAME"
echo " rm $SYSTEMD_USER_DIR/$SERVICE_FILE"
echo " systemctl --user daemon-reload"
echo ""