Skip to content
Snippets Groups Projects
Commit 1abd5017 authored by Michiel de Jong's avatar Michiel de Jong
Browse files

drafting add-site script with git pull

parent e6045769
No related branches found
No related tags found
No related merge requests found
k2.michiel.indiehosters.net, indiehosters.net, 3pp.io
/.*@somedomain.com/ person1@gmail.com, person2@hotmail.com
/michiel@somewhere-else.net/ me@forward.net
k2.michiel.indiehosters.net
#!/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
...@@ -2,15 +2,20 @@ ...@@ -2,15 +2,20 @@
if [ $# -ge 1 ]; then if [ $# -ge 1 ]; then
SERVER=$1 SERVER=$1
else else
echo "Usage: sh ./deploy/deploy.sh server [branch [user]]" echo "Usage: sh ./deploy/deploy.sh server [folder [branch [user]]]"
exit 1 exit 1
fi fi
if [ $# -ge 2 ]; then if [ $# -ge 2 ]; then
FOLDER=$2
else
FOLDER="./data/"
fi
if [ $# -ge 3 ]; then
BRANCH=$2 BRANCH=$2
else else
BRANCH="master" BRANCH="master"
fi fi
if [ $# -ge 3 ]; then if [ $# -ge 4 ]; then
USER=$3 USER=$3
else else
USER="core" USER="core"
...@@ -20,26 +25,13 @@ if [ -e ../orchestration/per-server/$SERVER/default-site ]; then ...@@ -20,26 +25,13 @@ if [ -e ../orchestration/per-server/$SERVER/default-site ]; then
else else
DEFAULTSITE=$SERVER DEFAULTSITE=$SERVER
fi fi
echo "Hoster data folder is $FOLDER"
echo "Infrastructure branch is $BRANCH" echo "Infrastructure branch is $BRANCH"
echo "Remote user is $USER" echo "Remote user is $USER"
echo "Default site is $DEFAULTSITE" echo "Default site is $DEFAULTSITE"
chmod -R go-w ../orchestration/deploy-keys scp $FOLDER $USER@$SERVER:/data
if [ -f ../orchestration/deploy-keys/authorized_keys ]; then
scp -r ../orchestration/deploy-keys $USER@$SERVER:.ssh
fi
scp ./deploy/onServer.sh $USER@$SERVER: scp ./deploy/onServer.sh $USER@$SERVER:
ssh $USER@$SERVER sudo mkdir -p /var/lib/coreos-install/ 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 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
#!/bin/bash -eux #!/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) # Start service for new site (and create the user)
systemctl enable $2@$1.service systemctl enable $2@$1.service
systemctl start $2@$1.service systemctl start $2@$1.service
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment