Add Linux development station role with systemd services for code-server and OpenCode
- Implemented handlers for restarting code-server and OpenCode services. - Created main tasks for setting up a Linux development station, including user management, package installation, and configuration. - Added validation for OpenCode server credentials and code-server password. - Introduced tool package management for npm, uv, and go installers. - Developed templates for systemd service units for code-server and OpenCode. - Included scripts for starting code-server and OpenCode with SSH agent support. - Updated inventory and Terraform configuration to include new development host.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# SSH agent starter — idempotent, safe to source from concurrent sessions.
|
||||
# Starts ssh-agent if not already running, then adds keys.
|
||||
|
||||
export SSH_AUTH_SOCK="{{ linux_dev_station_ssh_agent_socket }}"
|
||||
|
||||
# Start ssh-agent if socket doesn't exist
|
||||
if [ ! -S "$SSH_AUTH_SOCK" ]; then
|
||||
eval "$(/usr/bin/ssh-agent -a "{{ linux_dev_station_ssh_agent_socket }}" -s)" > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Wait for the agent socket to appear
|
||||
__wait=0
|
||||
while [ ! -S "$SSH_AUTH_SOCK" ] && [ "$__wait" -lt 15 ]; do
|
||||
sleep 1
|
||||
__wait=$(( __wait + 1 ))
|
||||
done
|
||||
|
||||
# Add keys if the agent is running but has none loaded
|
||||
if [ -S "$SSH_AUTH_SOCK" ]; then
|
||||
if ssh-add -l 2>/dev/null | grep -q "The agent has no identities"; then
|
||||
for _key in {{ linux_dev_station_ssh_agent_keys | map('quote') | join(' ') }}; do
|
||||
if [ -f "$_key" ]; then
|
||||
if [ -n "{{ linux_dev_station_ssh_agent_passphrase }}" ]; then
|
||||
printf '%s\n' "{{ linux_dev_station_ssh_agent_passphrase }}" | ssh-add "$_key" 2>/dev/null || true
|
||||
else
|
||||
ssh-add "$_key" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user