Added script to setup environment on a new server.
Signed-off-by: Jacob Kiers <jacob@alphacomm.nl>
This commit is contained in:
parent
9eaea22b9f
commit
5c5efbe77d
41
bin/setup-server
Executable file
41
bin/setup-server
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
NORMAL=$(tput sgr0)
|
||||||
|
GREEN=$(tput setaf 2; tput bold)
|
||||||
|
YELLOW=$(tput setaf 3)
|
||||||
|
RED=$(tput setaf 1)
|
||||||
|
|
||||||
|
function red() { echo -e "$RED$*$NORMAL"; }
|
||||||
|
function green() { echo -e "$GREEN$*$NORMAL"; }
|
||||||
|
function yellow() { echo -e "$YELLOW$*$NORMAL"; }
|
||||||
|
|
||||||
|
if [ ! $# == 2 ]; then
|
||||||
|
echo "Usage: $0 <user> <host>"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
USER=$1
|
||||||
|
HOST=$2
|
||||||
|
IP=`dig +short $HOST`
|
||||||
|
|
||||||
|
if [ -z "$IP" ]; then
|
||||||
|
IP=$HOST
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Adding server to .ssh/config...
|
||||||
|
cat >> ~/.ssh/config <<EOF
|
||||||
|
|
||||||
|
Host $HOST
|
||||||
|
HostName $IP
|
||||||
|
User $USER
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo Copying .ssh directory to $USER@$HOST...
|
||||||
|
scp -qr $HOME/.ssh/ $HOST:
|
||||||
|
|
||||||
|
echo Installing dotfiles...
|
||||||
|
ssh $HOST 'find . -maxdepth 1 -type l -exec unlink {} \;; rm $HOME/.bash*; curl -s https://dot.jacobkiers.net | bash'
|
||||||
|
|
||||||
|
echo
|
||||||
|
green Done installing server. You will now be logged in.
|
||||||
|
|
||||||
|
ssh $HOST
|
Loading…
Reference in New Issue
Block a user