infra/roles/mainframe/templates/git-cron.sh.j2

48 lines
1.1 KiB
Django/Jinja

#!/bin/bash
set -e
cd /root
{% set base = git_cron.base_path %}
{% for repo in git_cron.repos %}
if [ ! -d {{ base }}/{{ repo.dest }}/.git ]; then
git clone {{ repo.src }} {{ base }}/{{ repo.dest }}
fi
{% endfor %}
(
{% for repo in git_cron.repos %}
echo "{{ repo.dest }}"
cd {{ base }}/{{ repo.dest }}
git remote rm origin
git remote add origin {{ repo.src }}
git config branch.{{ git_cron.branch }}.remote origin
git config branch.{{ git_cron.branch }}.merge refs/heads/master
git pull -q
{% endfor %}
) > /dev/null
(
{% for repo in git_cron.repos %}
{% for link_src in repo.private_links|default([]) %}
{% set link = '/'.join([base, git_cron.private, link_src]) %}
echo ln -s {{ link }} {{ base }}/{{ repo.dest }}/
ln -s {{ link }} {{ base }}/{{ repo.dest }}/
{% endfor %}
{% endfor %}
mkdir -p /root/.zsh.d/
ln -s /root/dotfiles/zsh/.zsh.d/jreese2.zsh-theme /root/.zsh.d/
ln -s /root/dotfiles/zsh/.zshrc /root/.zshrc
ln -s /root/dotfiles/emacs/.emacs /root/.zshrc
ln -s /root/dotfiles/ssh/config /root/.ssh/config
) &> /dev/null