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

add nginx-gitpuller

parent 5ae80497
No related branches found
No related tags found
No related merge requests found
...@@ -21,12 +21,13 @@ vagrant up ...@@ -21,12 +21,13 @@ vagrant up
``` ```
Wait for the provisioning to finish (~5mins), and go to your browser: https://indiehosters.dev Wait for the provisioning to finish (~5mins), and go to your browser: https://indiehosters.dev
If the process fails, for instance due to network problems, you can retry by running `vagrant provision`.
### If you want to add another nginx instance apart from indiehosters.dev: ### If you want to add another nginx instance apart from indiehosters.dev:
```bash ```bash
vagrant ssh vagrant ssh
sh /data/indiehosters/scripts/activate-user.sh example.dev nginx sudo sh /data/indiehosters/scripts/activate-user.sh example.dev nginx https://github.com/indiehosters/website-static.git
``` ```
Check https://example.dev in your bowser! Check https://example.dev in your bowser!
......
#!/bin/bash
cd /data/per-user/$USER/nginx/data/www-content && git pull
#!/bin/bash #!/bin/bash
if [ ! -d "/data/per-user/$USER/nginx/data" ]; then if [ ! -e "/data/per-user/$USER/nginx/data/www-content/index.html" ]; then
mkdir -p /data/per-user/$USER/nginx/data/www-content if [ -e "/data/per-user/$USER/nginx/data/git-url.txt" ]; then
echo Hello $USER > /data/per-user/$USER/nginx/data/www-content/index.html git clone `cat /data/per-user/$USER/nginx/data/git-url.txt` /data/per-user/$USER/nginx/data/www-content
else
mkdir -p /data/per-user/$USER/nginx/data/www-content
echo Hello $USER > /data/per-user/$USER/nginx/data/www-content/index.html
fi
fi fi
#!/bin/bash -eux #!/bin/bash -eux
# mkdir -p /data/per-user/$1/nginx/data if [ $# -ge 2 ]; then
# if [ -e /data/per-user/$1/nginx/data/www-content ]; then DOMAIN=$1
# cd /data/per-user/$1/nginx/data/www-content; git pull --rebase IMAGE=$2
# else else
# git clone $3 /data/per-user/$1/nginx/data/www-content echo "Usage: sh /data/indiehosters/scripts/activate-user domain image [gitrepo]"
# fi exit 1
fi
mkdir -p /data/per-user/$DOMAIN/nginx/data
if [ $# -ge 3 ]; then
GITREPO=$3
echo $GITREPO > /data/per-user/$DOMAIN/nginx/data/git-url.txt
fi
# Start service for new site (and create the user) # Start service for new site (and create the user). This will also enable the git puller.
systemctl enable $2@$1.service systemctl enable $IMAGE@$DOMAIN.service
systemctl start $2@$1.service systemctl start $IMAGE@$DOMAIN.service
[Path]
PathExists=/data/per-user/%i/nginx/data/git-url.txt
[Unit]
Description=nginx git puller
# Dependency ordering
Before=nginx@%i.service
[Service]
Environment=USER=%i
ExecStart=/data/indiehosters/importers/nginx-updater.sh
[Install]
WantedBy=nginx@%i.service
[Unit]
Description=Run git puller every 10 minutes
[Timer]
OnUnitActiveSec=10min
[Install]
WantedBy=timers.target
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