Обратите внимание, что XML (, а также HTML )не являются обязательной структурой с«1 тегом на 1 строку»-он может иметьнесколькоразных тегов на] однустроку.
В таком случае я бы предложилPythonрешение:
заполнить _xml.pyскрипт:
import collections, xml.etree.ElementTree as ET
tree = ET.parse('yourxmlfile.xml') # <- specify your actual xml file name
root = tree.getroot()
with open('input.txt', 'r') as f:
d = collections.defaultdict(list)
for k,l in enumerate(f.read().splitlines()):
if k % 2 == 0: # treating each 2nd line as `positions` value
d['path'].append(l)
else:
d['positions'].append(l)
# iterating through `path`/`positions` node pairs
for k, nodes in enumerate(zip(root.findall('.//path'), root.findall('.//positions'))):
nodes[0].text = d['path'][k] # setting `path` value
nodes[1].text = d['positions'][k] # setting `positions` value
tree.write('result.xml') # write to the result file
Использование:
python fill_xml.py
Содержание result.xml
:
<aaa><command name="move">
<domain>
<path>/user/sht</path>
<positions>227_89,45_99</positions>
</domain>
<domain>
<path>/user/sht1</path>
<positions>230_90</positions>
</domain>
<domain>
<path>/user/sht2</path>
<positions>441_50</positions>
</domain>
</command>
</aaa>
Та же проблема... Итак, вот что я нашел:
ks.cfg как это сделать:
Это верно по документации (как я читал...):
part / --size=8000 --grow --fstype=ext4 --encrypted --passphrase=somepassword
Конечный результат:
/dev/vda6 on / type ext4 (rw,relatime,errors=remount-ro)
Прекрасное незашифрованное бесплатно для всеобщего обозрения!:)
Решение:
Вы должны смешать файлы ks.cfg и preseed, чтобы заставить его работать в Ubuntu (Методы автоматизации Debian и Redhat ). Должен сказать, что я немного сбит с толку тем, почему Canonical выбрал именно этот путь... но большая часть документации, которую я нашел, предлагает файлы ks.cfg и ks.preseed для автоматизации установки Ubuntu. Обратите внимание, что если вы используете mini.iso (сетевую установку ), вы можете использовать только ks.preseed и полностью следовать документации Debian (Я много раз делал это ). Чтобы решить вашу проблему выше :, вы должны добавить ниже в свой файл ks.preseed ниже «Конфигурация диска».
Программа установки смонтирует файловую систему и установит ОС. В конце вы можете использовать инструкцию %packages, если хотите, я полагаю --, но если вам нужно больше контролировать, рассмотрите возможность повторного использования файла preseed:
ИЗМЕНЕНИЕ УСТАНОВЛЕННОЙ СИСТЕМЫ:
d-i preseed/late_command string \
# the root filesystem is in /target
mkdir -p /target/opt/scripts; \
# in-target executes everything as if you were in the new system.
in-target chmod +x /opt/rtd/scripts/post-install.sh; \
Конфигурация диска:
# --------------------------------------------------- #
# Disk layout
# --------------------------------------------------- #
#
## Set option to encrypt the hard disk:
d-i partman-auto/method string crypto
# Option to temporarily set full disk encryption password to automate the install below.
# If you prefer to be propmpted during the system installation process comment out the
# two crypto/passphrase options below. The disk encryption password can be changed at
# anytime once the system is installed using the following command:
#
# tool : command : device and partition number
# cryptsetup luksChangeKey /dev/sda4
#
#
d-i partman-crypto/passphrase password plaintextpassword-or-encrypted
d-i partman-crypto/passphrase-again password plaintextpassword-or-encrypted
# When disk encryption is enabled, skip wiping the partitions beforehand since it takes too much time.
d-i partman-auto-crypto/erase_disks boolean false
# Delete anything on the first hard drive, then define the actual layout of the disk
# using and encrypted LVM volume for security.
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/device_remove_lvm_span boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto-lvm/new_vg_name string crypt
# Use generic instead of vda & sda to ensure recipie is applied even if this install is run in KVM, vmware, virtualbox IDE or SATA.
# d-i partman-auto/disk string /dev/sdb
d-i partman-auto/choose_recipe select root-encrypted
d-i partman-auto/expert_recipe string \
root-encrypted :: \
538 538 1075 free \
$primary \
$iflabel{ gpt } \
$reusemethod{ } \
method{ efi } format{ } \
. \
500 500 500 ext3 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
\
. \
2000 2000 2000 linux-swap \
$lvmok{ } lv_name{ swap } \
in_vg { crypt } \
$primary{ } \
method{ swap } format{ } \
. \
500 10000 1000000000 ext4 \
$lvmok{ } lv_name{ root } \
in_vg { crypt } \
$primary{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
2000 2000 2000 ext4 \
$primary{ } \
method{ keep } \
use_filesystem{ } filesystem{ ext4 } \
label{ rescuedisk } \
.
d-i partman-md/device_remove_md boolean true
d-i partman-md/confirm boolean true
d-i partman-basicfilesystems/no_mount_point boolean false
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# --------------------------------------------------- #