Rename expand-volume script to expand-root

Also move task for adjustment of that script into common.
It still needs some modifications to support device names other than xvda
This commit is contained in:
Anders Ingemann 2013-11-21 16:58:21 +01:00
parent a1d465ea16
commit 2e29ac0f93
4 changed files with 23 additions and 23 deletions

View file

@ -1,13 +1,13 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: expand-volume
# Provides: expand-root
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Description: Expand the filesystem of the mounted root volume to its maximum possible size
# Description: Expand the filesystem of the mounted root volume/partition to its maximum possible size
### END INIT INFO
prog=$(basename $0)

View file

@ -10,7 +10,7 @@ class ResolveInitScripts(Task):
def run(self, info):
init_scripts = {}
init_scripts['expand-volume'] = 'expand-volume'
init_scripts['expand-root'] = 'expand-root'
from subprocess import CalledProcessError
try:
@ -53,3 +53,22 @@ class InstallInitScripts(Task):
for name in info.initd['disable']:
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '--remove', name])
class AdjustExpandRootScript(Task):
description = 'Adjusting the expand-root script'
phase = phases.system_modification
predecessors = [InstallInitScripts]
def run(self, info):
if 'expand-root' not in info.initd['install']:
raise TaskError('The expand-root 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-root')
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)

View file

@ -60,7 +60,7 @@ def tasks(tasklist, manifest):
common_initd.ResolveInitScripts,
initd.AddEC2InitScripts,
common_initd.InstallInitScripts,
initd.AdjustExpandVolumeScript,
common_initd.AdjustExpandRootScript,
cleanup.ClearMOTD,
cleanup.CleanTMP,

View file

@ -18,22 +18,3 @@ class AddEC2InitScripts(Task):
init_scripts_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/init.d'))
for name, path in init_scripts.iteritems():
info.initd['install'][name] = os.path.join(init_scripts_dir, path)
class AdjustExpandVolumeScript(Task):
description = 'Adjusting the expand-volume script'
phase = phases.system_modification
predecessors = [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)