diff --git a/data/server-wide/postfix/destinations b/data/server-wide/postfix/destinations new file mode 100644 index 0000000000000000000000000000000000000000..71d164bae41c65d9e2b155d2e5487dee8389be0c --- /dev/null +++ b/data/server-wide/postfix/destinations @@ -0,0 +1 @@ +k2.michiel.indiehosters.net, indiehosters.net, 3pp.io diff --git a/data/server-wide/postfix/forwards b/data/server-wide/postfix/forwards new file mode 100644 index 0000000000000000000000000000000000000000..d185aa65aaec2622f554c6fb8ee977808681363b --- /dev/null +++ b/data/server-wide/postfix/forwards @@ -0,0 +1,2 @@ +/.*@somedomain.com/ person1@gmail.com, person2@hotmail.com +/michiel@somewhere-else.net/ me@forward.net diff --git a/data/server-wide/postfix/hostname b/data/server-wide/postfix/hostname new file mode 100644 index 0000000000000000000000000000000000000000..cc7fd8bf07fb6e237ae3d516cce85a531d215a9c --- /dev/null +++ b/data/server-wide/postfix/hostname @@ -0,0 +1 @@ +k2.michiel.indiehosters.net diff --git a/deploy/add-site.sh b/deploy/add-site.sh new file mode 100755 index 0000000000000000000000000000000000000000..882b64f5b86199e29b4651f9bf5c4fa0055a7b1e --- /dev/null +++ b/deploy/add-site.sh @@ -0,0 +1,21 @@ +#!/bin/sh +if [ $# -ge 4 ]; then + SERVER=$1 + DOMAIN=$2 + PEMFILE=$3 + GITREPO=$4 +else + echo "Usage: sh ./deploy/add-site.sh server domain pemfile gitrepo [user]" + exit 1 +fi +if [ $# -ge 5 ]; then + USER=$5 +else + USER="core" +fi +echo "Adding $DOMAIN to $SERVER with cert from $PEMFILE" +echo "Remote user is $USER" + +ssh $USER@$SERVER sudo mkdir -p /data/per-user/$DOMAIN/nginx/data +scp $PEMFILE $USER@$SERVER:/data/server-wide/haproxy/approved-certs/$DOMAIN.pem +ssh $USER@$SERVER sudo sh /data/indiehosters/scripts/activate-user.sh $DOMAIN nginx $GITREPO diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 085d7fd7c8901f832ae9e18b4c073d9d58a49921..8119c88357a2b0cbd9d2767a3c4394f522492f59 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -2,15 +2,20 @@ if [ $# -ge 1 ]; then SERVER=$1 else - echo "Usage: sh ./deploy/deploy.sh server [branch [user]]" + echo "Usage: sh ./deploy/deploy.sh server [folder [branch [user]]]" exit 1 fi if [ $# -ge 2 ]; then + FOLDER=$2 +else + FOLDER="./data/" +fi +if [ $# -ge 3 ]; then BRANCH=$2 else BRANCH="master" fi -if [ $# -ge 3 ]; then +if [ $# -ge 4 ]; then USER=$3 else USER="core" @@ -20,26 +25,13 @@ if [ -e ../orchestration/per-server/$SERVER/default-site ]; then else DEFAULTSITE=$SERVER fi +echo "Hoster data folder is $FOLDER" echo "Infrastructure branch is $BRANCH" echo "Remote user is $USER" echo "Default site is $DEFAULTSITE" -chmod -R go-w ../orchestration/deploy-keys -if [ -f ../orchestration/deploy-keys/authorized_keys ]; then - scp -r ../orchestration/deploy-keys $USER@$SERVER:.ssh -fi +scp $FOLDER $USER@$SERVER:/data scp ./deploy/onServer.sh $USER@$SERVER: ssh $USER@$SERVER sudo mkdir -p /var/lib/coreos-install/ -scp ../infrastructure/cloud-config $USER@$SERVER:/var/lib/coreos-install/user_data +scp cloud-config $USER@$SERVER:/var/lib/coreos-install/user_data ssh $USER@$SERVER sudo sh ./onServer.sh $BRANCH $DEFAULTSITE -cd ../orchestration/per-server/$SERVER/sites/ -for i in * ; do - echo "setting up site $i as `cat $i` on $SERVER"; - ssh $USER@$SERVER sudo mkdir -p /data/per-user/$i/ - scp ../../../TLS/approved-certs/$i.pem $USER@$SERVER:/data/server-wide/haproxy/approved-certs/$i.pem - rsync -r ../../../../user-data/live/$SERVER/$i/ $USER@$SERVER:/data/per-user/$i/ - ssh $USER@$SERVER sudo sh /data/infrastructure/scripts/activate-user.sh $i `cat $i` -done - -# Restart the default site now that its data has been rsync'ed in place: -ssh $USER@$SERVER sudo systemctl restart nginx\@$DEFAULTSITE diff --git a/scripts/activate-user.sh b/scripts/activate-user.sh index 86c114a835ad3baba7a42bc0c03591992f668036..2f820791f60587d06bd7e33c111ae39eef83ef65 100755 --- a/scripts/activate-user.sh +++ b/scripts/activate-user.sh @@ -1,5 +1,14 @@ #!/bin/bash -eux +mkdir -p /data/per-user/$1/$2/data +cd /data/per-user/$1/$2/data +if [ -e www-content ]; then + cd www-content + git pull +else + git clone $3 www-content +fi + # Start service for new site (and create the user) systemctl enable $2@$1.service systemctl start $2@$1.service