drive-ops/global/overlay/etc/cosmos/apt/bootstrap-cosmos.sh

48 lines
1.2 KiB
Bash
Raw Normal View History

2013-09-02 14:01:50 +00:00
#!/bin/sh
2016-04-20 14:44:14 +00:00
#set -e
# not all breakage is un-recoverable...
2013-09-02 14:01:50 +00:00
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
2016-04-20 14:44:14 +00:00
apt-get -y update
apt-get -y upgrade
2016-04-20 13:37:25 +00:00
for pkg in rsync git git-core wget; do
apt-get -y install $pkg
done
dpkg -i cosmos_1.5-1_all.deb
2013-09-02 14:01:50 +00:00
if ! test -d /var/cache/cosmos/repo; then
cosmos clone "$cmd_repo"
fi
hostname $cmd_hostname
2016-04-20 15:29:04 +00:00
short=`echo ${cmd_hostname} | awk -F. '{print $1}'`
echo "127.0.1.1 ${cmd_hostname} ${short}" >> /etc/hosts
2013-09-02 14:01:50 +00:00
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:36:37 +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) 2>&1 | tee /var/log/cosmos.log
2013-09-02 14:01:50 +00:00
exit 0