#!/bin/sh # setup new server ## PREFLIGHT ORIGIN_PWD="$PWD" if ! [ "$UID" = "0" ]; then echo "please perform as root, attempting to escalate privileges..." exec sudo $(cat /proc/$$/cmdline | sed 's/\x00/ /g') exit 1 fi if ! ssh git@git.ixvd.net; then echo "can't connect to git, please setup ssh" exit 1 fi ## MAIN if ! [ -f "/etc/ixvd/version" ]; then echo "applying overlay..." cp -r skel / fi if ! [ -d "/etc/ixvd/secrets" ]; then echo "setting up ixvd/secrets" git clone git@git.ixvd.net/ixvd/secrets /etc/ixvd/secrets fi if ! [ -f "/root/.ssh/authorized_keys" ]; then echo "importing authorized_keys..." mkdir -p /root/.ssh cp /etc/ixvd/secrets/ssh/authorized_keys /root/.ssh/authorized_keys else if ! grep -q "# IXVD keys" /root/.ssh/authorized_keys; then echo "importing authorized_keys..." cat /etc/ixvd/secrets/ssh/authorized_keys >> /root/.ssh/authorized_keys fi fi