dns-ops/apt/bootstrap-cosmos.sh

42 lines
1 KiB
Bash
Raw Normal View History

2013-09-02 14:01:50 +00:00
#!/bin/sh
set -e
cmd_hostname="$1"
if test -z "$cmd_hostname"; then
2013-10-31 22:26:16 +00:00
echo "Usage: $0 HOSTNAME REPO TAGPATTERN"
2013-09-02 14:01:50 +00:00
exit 1
fi
cmd_repo="$2"
if test -z "$cmd_repo"; then
2013-10-31 22:26:16 +00:00
echo "Usage $0 HOSTNAME REPO TAGPATTERN"
2013-09-02 14:01:50 +00:00
exit 2
fi
2013-10-31 22:26:16 +00:00
cmd_tags="$3"
if test -z "$cmd_tags"; then
echo "Usage $0 HOSTNAME REPO TAGPATTERN"
exit 3
fi
2013-09-02 14:01:50 +00:00
set -x
apt-get -y install rsync git-core
dpkg -i cosmos_1.2-2_all.deb
if ! test -d /var/cache/cosmos/repo; then
cosmos clone "$cmd_repo"
fi
hostname $cmd_hostname
perl -pi -e "s,#COSMOS_REPO_MODELS=.*,COSMOS_REPO_MODELS=\"\\\$COSMOS_REPO/global/:\\\$COSMOS_REPO/$cmd_hostname/\"," /etc/cosmos/cosmos.conf
2013-10-31 22:26:16 +00:00
perl -pi -e 's,#COSMOS_UPDATE_VERIFY_GIT_TAG_PATTERN=.*,COSMOS_UPDATE_VERIFY_GIT_TAG_PATTERN="${cmd_tags}*",' /etc/cosmos/cosmos.conf
2013-09-02 14:01:50 +00:00
2013-10-31 21:18:39 +00:00
env COSMOS_BASE=/var/cache/cosmos COSMOS_KEYS=/var/cache/cosmos/repo/global/overlay/etc/cosmos/keys /var/cache/cosmos/repo/global/post-tasks.d/015cosmos-trust
2013-09-02 14:01:50 +00:00
(date; nohup cosmos -v update && nohup cosmos -v apply; date) > /var/log/cosmos.log 2>&1
exit 0