Commit 34f0d410 authored by Kristopher Ruzic's avatar Kristopher Ruzic

write startup script to /etc/rc.local, save playbooks to a permanent location

parent c35d2605
#!/bin/bash
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_FILE=erp5-standalone.yml
STARTUP_FILE=/usr/local/bin/erp5-startup
EXE_PATH="`dirname \"$0\"`"
echo "Running from $EXE_PATH"
#### First run of this script ####
if [ -f $STARTUP_FILE ]; then
# let the user know
echo "Script has been run previously, use the script in /usr/local/bin unless upgrading"
else
# save the startup script to /usr/local/bin
# and mark it as executable
# temporary download url
wget --no-check-certificate https://lab.nexedi.cn/krruzic/slapos.playbook/raw/master/install/erp5-startup -O $STARTUP_FILE
chmod -x $STARTUP_FILE
# add as the second to last line (last line is `exit 0`)
sed -i -e '$i \bash /usr/local/bin/erp5-startup &\n' /etc/rc.local
echo "Script added to startup"
fi
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5=e2c9b43ccff6e606ad25cd1df0e2705f
BASE_SETUP_SCRIPT_MD5=e2c9b43ccff6e606ad25cd1df0e2705f
mkdir -p /opt/slapos.playbook/
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /tmp/base-setup
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /opt/slapos.playbook/base-setup
if [ "`md5sum /tmp/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /tmp/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
if [ "`md5sum /opt/slapos.playbook/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /opt/slapos.playbook/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
exit 1
fi
source /tmp/base-setup
source /opt/slapos.playbook/base-setup
download_playbook $PLAYBOOK_REPOSITORY_URL
download_playbook $PLAYBOOK_REPOSITORY_URL
echo "Starting Ansible playbook:"
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
\ No newline at end of file
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
#!/bin/bash
# Reruns the ansible playbook, does nothing else
PLAYBOOK_FILE=erp5-standalone.yml
source /opt/slapos.playbook/base-setup
echo "Starting Ansible playbook:"
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment