Status LED
Dieser Commit ist enthalten in:
72
setup_activity_server_profile.sh
Normale Datei
72
setup_activity_server_profile.sh
Normale Datei
@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
# Setup script to configure automatic directory change for Activity Server SSH connections
|
||||
|
||||
echo "Activity Server Profile Setup Script"
|
||||
echo "===================================="
|
||||
echo ""
|
||||
echo "This script will configure the server to automatically navigate to"
|
||||
echo "/home/claude-dev/cpm-activity-server when connecting via SSH."
|
||||
echo ""
|
||||
|
||||
# SSH connection details
|
||||
SSH_HOST="91.99.192.14"
|
||||
SSH_USER="claude-dev"
|
||||
SSH_PASS="z0E1Al}q2H?Yqd!O"
|
||||
|
||||
# Create the profile modification script
|
||||
cat << 'PROFILE_SCRIPT' > /tmp/setup_profile.sh
|
||||
#!/bin/bash
|
||||
|
||||
# Add to .bashrc to detect SSH connections and change directory
|
||||
echo "" >> ~/.bashrc
|
||||
echo "# Auto-navigate to Activity Server directory for SSH connections" >> ~/.bashrc
|
||||
echo "if [ -n \"\$SSH_CLIENT\" ] || [ -n \"\$SSH_TTY\" ]; then" >> ~/.bashrc
|
||||
echo " # Check if we're in an SSH session" >> ~/.bashrc
|
||||
echo " if [ -d \"/home/claude-dev/cpm-activity-server\" ]; then" >> ~/.bashrc
|
||||
echo " cd /home/claude-dev/cpm-activity-server" >> ~/.bashrc
|
||||
echo " echo \"Automatically changed to Activity Server directory\"" >> ~/.bashrc
|
||||
echo " echo \"\"" >> ~/.bashrc
|
||||
echo " fi" >> ~/.bashrc
|
||||
echo "fi" >> ~/.bashrc
|
||||
|
||||
echo "Profile updated successfully!"
|
||||
PROFILE_SCRIPT
|
||||
|
||||
# Make the script executable
|
||||
chmod +x /tmp/setup_profile.sh
|
||||
|
||||
echo "Connecting to server to apply configuration..."
|
||||
echo ""
|
||||
|
||||
# Try different methods to connect and run the script
|
||||
if command -v sshpass >/dev/null 2>&1; then
|
||||
echo "Using sshpass..."
|
||||
sshpass -p "$SSH_PASS" ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST 'bash -s' < /tmp/setup_profile.sh
|
||||
elif command -v expect >/dev/null 2>&1; then
|
||||
echo "Using expect..."
|
||||
expect << EOF
|
||||
spawn ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST
|
||||
expect "password:"
|
||||
send "$SSH_PASS\r"
|
||||
expect "$ "
|
||||
send "bash < /tmp/setup_profile.sh\r"
|
||||
expect "$ "
|
||||
send "exit\r"
|
||||
expect eof
|
||||
EOF
|
||||
else
|
||||
echo "Neither sshpass nor expect found."
|
||||
echo ""
|
||||
echo "Please manually run the following on the server:"
|
||||
echo "1. SSH to $SSH_USER@$SSH_HOST"
|
||||
echo "2. Run the commands in /tmp/setup_profile.sh"
|
||||
echo ""
|
||||
echo "Or install sshpass: sudo apt-get install sshpass"
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
rm -f /tmp/setup_profile.sh
|
||||
|
||||
echo ""
|
||||
echo "Setup complete! Future SSH connections will automatically"
|
||||
echo "navigate to the Activity Server directory."
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren