mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -08:00
feat: Improve SSH agent management and enhance VS Code repository setup with error handling; fixes bug recently introduced. the error messge "mkdtemp: private socket dir: Permission denied" was being displayed when a new terminal window was opened.
This commit is contained in:
@@ -180,8 +180,39 @@ if command -v fabric &> /dev/null; then
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$SSH_AUTH_SOCK" ]; then
|
# SSH Agent Management - Start only if needed and working properly
|
||||||
# Start the SSH agent if not already running
|
ssh_agent_start() {
|
||||||
# Add the SSH key to the agent
|
local ssh_agent_env="$HOME/.ssh-agent-env"
|
||||||
eval "$(ssh-agent -s)" >/dev/null 2>&1 && ssh-add ~/.ssh/id_ed25519 >/dev/null 2>&1
|
|
||||||
|
# Function to check if ssh-agent is running and responsive
|
||||||
|
ssh_agent_running() {
|
||||||
|
[ -n "$SSH_AUTH_SOCK" ] && [ -S "$SSH_AUTH_SOCK" ] && ssh-add -l >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load existing agent environment if it exists
|
||||||
|
if [ -f "$ssh_agent_env" ]; then
|
||||||
|
source "$ssh_agent_env" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if agent is running and responsive
|
||||||
|
if ! ssh_agent_running; then
|
||||||
|
# Start new agent only if ssh key exists
|
||||||
|
if [ -f "$HOME/.ssh/id_ed25519" ]; then
|
||||||
|
# Clean up any stale agent environment
|
||||||
|
[ -f "$ssh_agent_env" ] && rm -f "$ssh_agent_env"
|
||||||
|
|
||||||
|
# Start new agent and save environment
|
||||||
|
ssh-agent -s > "$ssh_agent_env" 2>/dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
source "$ssh_agent_env" >/dev/null 2>&1
|
||||||
|
# Add key to agent
|
||||||
|
ssh-add "$HOME/.ssh/id_ed25519" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only run SSH agent setup if we have SSH keys
|
||||||
|
if [ -f "$HOME/.ssh/id_ed25519" ]; then
|
||||||
|
ssh_agent_start
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -113,10 +113,16 @@ else
|
|||||||
|
|
||||||
# Setup VS Code repository
|
# Setup VS Code repository
|
||||||
echo -e "${YELLOW}Setting up VS Code repository...${NC}"
|
echo -e "${YELLOW}Setting up VS Code repository...${NC}"
|
||||||
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/packages.microsoft.gpg
|
TEMP_GPG=$(mktemp)
|
||||||
sudo install -D -o root -g root -m 644 /tmp/packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
|
if wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > "$TEMP_GPG"; then
|
||||||
|
sudo install -D -o root -g root -m 644 "$TEMP_GPG" /etc/apt/keyrings/packages.microsoft.gpg
|
||||||
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
|
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
|
||||||
rm /tmp/packages.microsoft.gpg
|
rm -f "$TEMP_GPG"
|
||||||
|
else
|
||||||
|
echo -e "${RED}ERROR: Failed to download Microsoft GPG key${NC}"
|
||||||
|
rm -f "$TEMP_GPG"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Setup GitHub CLI repository
|
# Setup GitHub CLI repository
|
||||||
echo -e "${YELLOW}Setting up GitHub CLI repository...${NC}"
|
echo -e "${YELLOW}Setting up GitHub CLI repository...${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user