2023-10-29 17:24:17 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-10-30 01:04:08 +01:00
|
|
|
if ! echo "$PATH" | grep -q "sbin"; then
|
2023-10-30 01:03:25 +01:00
|
|
|
# sudo is quirky
|
|
|
|
PATH="$PATH:/sbin"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -q "automation" /etc/passwd; then
|
2023-10-29 17:24:17 +01:00
|
|
|
echo "setting up automation user..."
|
|
|
|
useradd -m automation
|
|
|
|
|
|
|
|
mkdir -p /home/automation/.ssh
|
|
|
|
|
|
|
|
cat /etc/ixvd/secrets/ssh/keys/$HOSTNAME/id_rsa.pub > /home/automation/.ssh/authorized_keys
|
|
|
|
chown automation:automation /home/automation/.ssh/authorized_keys
|
|
|
|
|
|
|
|
cp /etc/ixvd/secrets/ssh/keys/$HOSTNAME/id_rsa /home/automation/.ssh/id_rsa
|
|
|
|
chown automation:automation /home/automation/.ssh/id_rsa
|
|
|
|
chmod 600 /home/automation/.ssh/id_rsa
|
|
|
|
|
|
|
|
cp /etc/ixvd/secrets/ssh/keys/$HOSTNAME/id_rsa.pub /home/automation/.ssh/id_rsa.pub
|
|
|
|
chown automation:automation /home/automation/.ssh/id_rsa.pub
|
|
|
|
chmod 600 /home/automation/.ssh/id_rsa.pub
|
|
|
|
fi
|