free-hand updates from eduid-ops
This commit is contained in:
parent
19304f2d79
commit
b2272d409f
|
@ -21,6 +21,14 @@ if test -z "$cmd_tags"; then
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
|
||||||
|
# cloud-init runs with LANG='US-ASCII' which is likely to fail because of non-US-ASCII chars in the manifest
|
||||||
|
export LANG='en_US.UTF-8'
|
||||||
|
|
||||||
|
export DEBIAN_FRONTEND='noninteractive'
|
||||||
|
|
||||||
apt-get -y update
|
apt-get -y update
|
||||||
apt-get -y upgrade
|
apt-get -y upgrade
|
||||||
for pkg in rsync git git-core wget; do
|
for pkg in rsync git git-core wget; do
|
||||||
|
@ -32,16 +40,40 @@ if ! test -d /var/cache/cosmos/repo; then
|
||||||
cosmos clone "$cmd_repo"
|
cosmos clone "$cmd_repo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# re-run cosmos at reboot until it succeeds - use bash -l to get working proxy settings
|
||||||
|
grep -v "^exit 0" /etc/rc.local > /etc/rc.local.new
|
||||||
|
(echo ""
|
||||||
|
echo "test -f /etc/run-cosmos-at-boot && (bash -l cosmos -v update; bash -l cosmos -v apply && rm /etc/run-cosmos-at-boot)"
|
||||||
|
echo ""
|
||||||
|
echo "exit 0"
|
||||||
|
) >> /etc/rc.local.new
|
||||||
|
mv -f /etc/rc.local.new /etc/rc.local
|
||||||
|
|
||||||
|
touch /etc/run-cosmos-at-boot
|
||||||
|
|
||||||
hostname $cmd_hostname
|
hostname $cmd_hostname
|
||||||
short=`echo ${cmd_hostname} | awk -F. '{print $1}'`
|
short=`echo ${cmd_hostname} | awk -F. '{print $1}'`
|
||||||
echo "127.0.1.1 ${cmd_hostname} ${short}" >> /etc/hosts
|
echo "127.0.1.1 ${cmd_hostname} ${short}" >> /etc/hosts
|
||||||
|
|
||||||
perl -pi -e "s,#COSMOS_REPO_MODELS=.*,COSMOS_REPO_MODELS=\"\\\$COSMOS_REPO/global/:\\\$COSMOS_REPO/$cmd_hostname/\"," /etc/cosmos/cosmos.conf
|
# Set up cosmos models. They are in the order of most significant first, so we want
|
||||||
|
# <host> <group (if it exists)> <global>
|
||||||
|
_host_type=`echo $cmd_hostname | cut -d - -f 1`
|
||||||
|
models=$(
|
||||||
|
echo -n '\\$COSMOS_REPO/'"$cmd_hostname/:"
|
||||||
|
test -d /var/cache/cosmos/repo/${_host_type}-common && echo -n '\\$COSMOS_REPO/'"${_host_type}-common/:"
|
||||||
|
echo -n '\\$COSMOS_REPO/global/'
|
||||||
|
)
|
||||||
|
echo "Configuring cosmos with the following models:"
|
||||||
|
echo "${models}"
|
||||||
|
|
||||||
|
perl -pi -e "s,#COSMOS_REPO_MODELS=.*,COSMOS_REPO_MODELS=\"${models}\"," /etc/cosmos/cosmos.conf
|
||||||
perl -pi -e "s,#COSMOS_UPDATE_VERIFY_GIT_TAG_PATTERN=.*,COSMOS_UPDATE_VERIFY_GIT_TAG_PATTERN=\"${cmd_tags}*\"," /etc/cosmos/cosmos.conf
|
perl -pi -e "s,#COSMOS_UPDATE_VERIFY_GIT_TAG_PATTERN=.*,COSMOS_UPDATE_VERIFY_GIT_TAG_PATTERN=\"${cmd_tags}*\"," /etc/cosmos/cosmos.conf
|
||||||
|
|
||||||
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
|
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
|
||||||
|
|
||||||
(date; nohup cosmos -v update && nohup cosmos -v apply; date) 2>&1 | tee /var/log/cosmos.log
|
mkdir -p /var/cache/scriptherder
|
||||||
|
|
||||||
|
(date; nohup cosmos -v update && nohup cosmos -v apply && rm /etc/run-cosmos-at-boot; date) 2>&1 | tee /var/log/cosmos.log
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue