mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
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:
parent
a1d465ea16
commit
2e29ac0f93
4 changed files with 23 additions and 23 deletions
|
@ -1,13 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: expand-volume
|
# Provides: expand-root
|
||||||
# Required-Start:
|
# Required-Start:
|
||||||
# Required-Stop:
|
# Required-Stop:
|
||||||
# Should-Start:
|
# Should-Start:
|
||||||
# Should-Stop:
|
# Should-Stop:
|
||||||
# Default-Start: 2 3 4 5
|
# Default-Start: 2 3 4 5
|
||||||
# Default-Stop:
|
# 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
|
### END INIT INFO
|
||||||
|
|
||||||
prog=$(basename $0)
|
prog=$(basename $0)
|
|
@ -10,7 +10,7 @@ class ResolveInitScripts(Task):
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
init_scripts = {}
|
init_scripts = {}
|
||||||
init_scripts['expand-volume'] = 'expand-volume'
|
init_scripts['expand-root'] = 'expand-root'
|
||||||
|
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
try:
|
try:
|
||||||
|
@ -53,3 +53,22 @@ class InstallInitScripts(Task):
|
||||||
|
|
||||||
for name in info.initd['disable']:
|
for name in info.initd['disable']:
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '--remove', name])
|
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)
|
||||||
|
|
|
@ -60,7 +60,7 @@ def tasks(tasklist, manifest):
|
||||||
common_initd.ResolveInitScripts,
|
common_initd.ResolveInitScripts,
|
||||||
initd.AddEC2InitScripts,
|
initd.AddEC2InitScripts,
|
||||||
common_initd.InstallInitScripts,
|
common_initd.InstallInitScripts,
|
||||||
initd.AdjustExpandVolumeScript,
|
common_initd.AdjustExpandRootScript,
|
||||||
cleanup.ClearMOTD,
|
cleanup.ClearMOTD,
|
||||||
cleanup.CleanTMP,
|
cleanup.CleanTMP,
|
||||||
|
|
||||||
|
|
|
@ -18,22 +18,3 @@ 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
|
|
||||||
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)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue