diff --git a/common/assets/init.d/expand-volume b/common/assets/init.d/expand-root similarity index 89% rename from common/assets/init.d/expand-volume rename to common/assets/init.d/expand-root index cfee83c..1c714b2 100644 --- a/common/assets/init.d/expand-volume +++ b/common/assets/init.d/expand-root @@ -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) diff --git a/common/tasks/initd.py b/common/tasks/initd.py index 1046d68..f002f77 100644 --- a/common/tasks/initd.py +++ b/common/tasks/initd.py @@ -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) diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index a383f7b..7ad81d7 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -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, diff --git a/providers/ec2/tasks/initd.py b/providers/ec2/tasks/initd.py index 1a68645..9539eee 100644 --- a/providers/ec2/tasks/initd.py +++ b/providers/ec2/tasks/initd.py @@ -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)