mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
New task for adjusting the expand-volume script
By default it only expands /dev/xvda
This commit is contained in:
parent
6eb56721dc
commit
1db38ec7dd
4 changed files with 24 additions and 2 deletions
|
@ -13,7 +13,7 @@
|
||||||
prog=$(basename $0)
|
prog=$(basename $0)
|
||||||
logger="logger -t $prog"
|
logger="logger -t $prog"
|
||||||
|
|
||||||
device_path="/dev/xvda1"
|
device_path="/dev/xvda"
|
||||||
|
|
||||||
filesystem=`blkid | grep $device_path | sed 's#\(.*\):.*TYPE="\(.*\)".*#\2#'`
|
filesystem=`blkid | grep $device_path | sed 's#\(.*\):.*TYPE="\(.*\)".*#\2#'`
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ class ResolveInitScripts(Task):
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
init_scripts = {'expand-volume': 'expand-volume'}
|
init_scripts = {}
|
||||||
|
init_scripts['expand-volume'] = 'expand-volume'
|
||||||
|
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -60,6 +60,7 @@ def tasks(tasklist, manifest):
|
||||||
common_initd.ResolveInitScripts,
|
common_initd.ResolveInitScripts,
|
||||||
initd.AddEC2InitScripts,
|
initd.AddEC2InitScripts,
|
||||||
common_initd.InstallInitScripts,
|
common_initd.InstallInitScripts,
|
||||||
|
initd.AdjustExpandVolumeScript,
|
||||||
cleanup.ClearMOTD,
|
cleanup.ClearMOTD,
|
||||||
cleanup.CleanTMP,
|
cleanup.CleanTMP,
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from base import Task
|
from base import Task
|
||||||
from common import phases
|
from common import phases
|
||||||
|
from common.exceptions import TaskError
|
||||||
from common.tasks import initd
|
from common.tasks import initd
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
@ -17,3 +18,22 @@ class AddEC2InitScripts(Task):
|
||||||
init_scripts_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/init.d'))
|
init_scripts_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/init.d'))
|
||||||
for name, path in init_scripts.iteritems():
|
for name, path in init_scripts.iteritems():
|
||||||
info.initd['install'][name] = os.path.join(init_scripts_dir, path)
|
info.initd['install'][name] = os.path.join(init_scripts_dir, path)
|
||||||
|
|
||||||
|
|
||||||
|
class AdjustExpandVolumeScript(Task):
|
||||||
|
description = 'Adjusting the expand-volume script'
|
||||||
|
phase = phases.system_modification
|
||||||
|
after = [initd.InstallInitScripts]
|
||||||
|
|
||||||
|
def run(self, info):
|
||||||
|
if 'expand-volume' not in info.initd['install']:
|
||||||
|
raise TaskError('The expand-volume script was not installed')
|
||||||
|
|
||||||
|
from base.fs.partitionmaps.none import NoPartitions
|
||||||
|
if not isinstance(info.volume.partition_map, NoPartitions):
|
||||||
|
import os.path
|
||||||
|
from common.tools import sed_i
|
||||||
|
script = os.path.join(info.root, 'etc/init.d.expand-volume')
|
||||||
|
root_idx = info.volume.partition_map.root.get_index()
|
||||||
|
device_path = 'device_path="/dev/xvda{idx}"'.format(idx=root_idx)
|
||||||
|
sed_i(script, '^device_path="/dev/xvda$', device_path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue