Skip to content

Commit 324bf01

Browse files
author
sheeek
committed
Simplify user switch with bash --rcfile approach
- Use bash --rcfile to display MOTD and start interactive shell - Combines .bashrc loading with one-time welcome message - exec sudo -i ensures we stay as clawdbot user - Cleaner than temp script + bash -c approach
1 parent 556e296 commit 324bf01

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

playbook.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
- " - Open Ports: SSH (22) + Tailscale (41641/udp)"
6262
- " - Docker isolation: ACTIVE"
6363
- ""
64-
- "🚀 To complete setup, run:"
64+
- "📚 Documentation: https://docs.clawd.bot"
6565
- ""
66-
- " /tmp/clawdbot-setup.sh"
66+
- "🚀 run-playbook.sh will now switch to clawdbot user..."
6767
- ""

roles/clawdbot/files/clawdbot-setup.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ echo ""
5252
echo -e "${YELLOW}Switching to clawdbot user for setup...${NC}"
5353
echo ""
5454

55-
# Create a profile script that shows the welcome message
56-
cat > /tmp/.clawdbot-welcome.sh << 'WELCOME_EOF'
55+
# Create a .bashrc snippet that shows the welcome message once
56+
cat > /tmp/.clawdbot-motd << 'MOTD_EOF'
5757
echo "============================================"
5858
echo "📋 Clawdbot Setup - Next Steps"
5959
echo "============================================"
@@ -85,10 +85,10 @@ echo "============================================"
8585
echo ""
8686
echo "Type 'exit' to return to previous user"
8787
echo ""
88-
rm -f /tmp/.clawdbot-welcome.sh
89-
WELCOME_EOF
88+
# Remove this file so it only shows once
89+
rm -f /tmp/.clawdbot-motd
90+
MOTD_EOF
9091

91-
chmod +x /tmp/.clawdbot-welcome.sh
92-
93-
# Switch to clawdbot user with login shell and run welcome message
94-
exec sudo -i -u clawdbot bash -c '/tmp/.clawdbot-welcome.sh; exec bash --login'
92+
# Switch to clawdbot user with login shell
93+
# Use bash --rcfile to source the MOTD before starting interactive shell
94+
exec sudo -i -u clawdbot bash --rcfile <(cat ~/.bashrc 2>/dev/null; cat /tmp/.clawdbot-motd 2>/dev/null)

0 commit comments

Comments
 (0)