mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
change provider to raw, set opennebula as plugin
This commit is contained in:
parent
237069b941
commit
6ffa601488
36 changed files with 78 additions and 0 deletions
5
plugins/opennebula/__init__.py
Normal file
5
plugins/opennebula/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
|
def tasks(tasklist, manifest):
|
||||||
|
from opennebula import OpenNebulaContext
|
||||||
|
tasklist.add(OpenNebulaContext())
|
42
plugins/opennebula/opennebula.py
Normal file
42
plugins/opennebula/opennebula.py
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
from base import Task
|
||||||
|
from common import phases
|
||||||
|
import os
|
||||||
|
from providers.one.tasks.locale import GenerateLocale
|
||||||
|
|
||||||
|
|
||||||
|
class OpenNebulaContext(Task):
|
||||||
|
description = 'Setup OpenNebula init context'
|
||||||
|
phase = phases.system_modification
|
||||||
|
after = [GenerateLocale]
|
||||||
|
|
||||||
|
def run(self, info):
|
||||||
|
import stat
|
||||||
|
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
||||||
|
stat.S_IRGRP | stat.S_IXGRP |
|
||||||
|
stat.S_IROTH | stat.S_IXOTH)
|
||||||
|
|
||||||
|
from shutil import copy
|
||||||
|
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets/one-context_3.8.1.deb'))
|
||||||
|
script_dst = os.path.join(info.root, 'tmp/one-context_3.8.1.deb')
|
||||||
|
copy(script_src, script_dst)
|
||||||
|
os.chmod(script_dst, rwxr_xr_x)
|
||||||
|
|
||||||
|
from common.tools import log_check_call
|
||||||
|
log_check_call(['/usr/sbin/chroot', info.root, 'dpkg', '-i', '/tmp/one-context_3.8.1.deb'])
|
||||||
|
# Fix start
|
||||||
|
from common.tools import sed_i
|
||||||
|
vmcontext_def = os.path.join(info.root, 'etc/init.d/vmcontext')
|
||||||
|
sed_i(vmcontext_def, '# Default-Start:', '# Default-Start: 2 3 4 5')
|
||||||
|
os.chmod(vmcontext_def, rwxr_xr_x)
|
||||||
|
log_check_call(['/usr/sbin/chroot', info.root, 'update-rc.d', 'vmcontext', 'start', '90', '2', '3', '4', '5', 'stop', '90', '0', '6'])
|
||||||
|
|
||||||
|
# Load all pubkeys in root authorized_keys
|
||||||
|
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets/one-pubkey.sh'))
|
||||||
|
script_dst = os.path.join(info.root, 'etc/one-context.d/one-pubkey.sh')
|
||||||
|
copy(script_src, script_dst)
|
||||||
|
|
||||||
|
# If USER_EC2_DATA is a script, execute it
|
||||||
|
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets/one-ec2.sh'))
|
||||||
|
script_dst = os.path.join(info.root, 'etc/one-context.d/one-ec2.sh')
|
||||||
|
copy(script_src, script_dst)
|
||||||
|
|
BIN
providers/raw/assets/one-context_3.8.1.deb
Normal file
BIN
providers/raw/assets/one-context_3.8.1.deb
Normal file
Binary file not shown.
14
providers/raw/assets/one-ec2.sh
Executable file
14
providers/raw/assets/one-ec2.sh
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -n "$EC2_USER_DATA" ]; then
|
||||||
|
# Check if EC2 user data is a script, if yes, execute
|
||||||
|
if [[ $EC2_USER_DATA =~ ^#! ]]; then
|
||||||
|
echo "EC2 data is an executable script, so execute it now"
|
||||||
|
TMPFILE=$(mktemp /tmp/output.XXXXXXXXXX)
|
||||||
|
chmod 755 $TMPFILE
|
||||||
|
$TMPFILE
|
||||||
|
cat $TMPFILE
|
||||||
|
else
|
||||||
|
print "Not an executable"
|
||||||
|
fi
|
||||||
|
fi
|
17
providers/raw/assets/one-pubkey.sh
Executable file
17
providers/raw/assets/one-pubkey.sh
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Reconfigure host ssh keys"
|
||||||
|
dpkg-reconfigure openssh-server
|
||||||
|
|
||||||
|
if [ ! -e /root/.ssh ]; then
|
||||||
|
mkdir /root/.ssh
|
||||||
|
touch /root/.ssh/authorized_keys
|
||||||
|
chmod 600 /root/.ssh/authorized_keys
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Copy public ssh keys to authorized_keys"
|
||||||
|
for f in /mnt/*.pub
|
||||||
|
do
|
||||||
|
cat $f >> /root/.ssh/authorized_keys
|
||||||
|
|
||||||
|
done
|
Loading…
Add table
Reference in a new issue