Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37545257
en ru br
Репозитории ALT

Группа :: Система/Настройка/Прочее
Пакет: installer-scripts-remount-stage2

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

installer-scripts-remount-stage2-0.5/000075500000000000000000000000001224120035600177035ustar00rootroot00000000000000installer-scripts-remount-stage2-0.5/initinstall/000075500000000000000000000000001224120035600222355ustar00rootroot00000000000000installer-scripts-remount-stage2-0.5/initinstall/stop-md-dm.sh000075500000000000000000000002421224120035600245530ustar00rootroot00000000000000#!/bin/sh

# provide clean situation for evms
# https://bugzilla.altlinux.org/show_bug.cgi?id=29554

. install2-remount-functions

reset_devmapper
stop_mdraid

:
installer-scripts-remount-stage2-0.5/scripts/000075500000000000000000000000001224120035600213725ustar00rootroot00000000000000installer-scripts-remount-stage2-0.5/scripts/install2-remount-functions000075500000000000000000000070551224120035600265540ustar00rootroot00000000000000#!/bin/sh
# remount EVMS-created volumes
# see https://bugzilla.altlinux.org/28181

# destdir must be defined by this time
check_destdir() {
[ -d "$destdir" ] || exit 1
}

remount_chroot() {
# no dups here:
# - bring lvm down;
# - free the appropriate volumes (could be on mdraid too);
# - bring mdraid down;
# - free the appropriate block devices
(
set -x
check_destdir &&
save_blkid_state &&
populate_fstab &&
copy_chroot_binaries &&
umount_chroot &&
reset_devmapper &&
stop_mdraid &&
reset_devmapper &&
start_luks &&
start_mdraid &&
start_lvm &&
start_luks &&
mount_chroot \
) >& /tmp/remount.log || return $?
}

# avoid automatic rpm shell.req dependency
MDADM=/sbin/mdadm
LVM=/sbin/lvm
CRYPTSETUP=/sbin/cryptsetup
CRYPTSETUP_KEY=/tmp/empty

# alterator-vm should leave LUKS containers
# with initial empty password, see #28200
:> "$CRYPTSETUP_KEY"

# for installer-feature-desktop-other-fs, see also #29005
save_blkid_state() {
find /dev/mapper -type l \
| xargs -r blkid -c /dev/null \
> /tmp/blkid.dm
}

populate_fstab() {
[ ! -f /tmp/fstab ] ||
cat /tmp/fstab >> "$destdir/etc/fstab"
}

copy_chroot_binaries() {
# these are normally missing in installer environment
# NB: /sbin writes rely on aufs in fact, would use /tmp otherwise
# but that might clobber cases when the binaries have to differ
for i in /sbin/{mdadm,lvm,cryptsetup}; do
if [ ! -x "$i" -a -x "$destdir$i" ]; then
cp -p "$destdir$i" "$i"
fi
done

if [ -f "$destdir/etc/lvm/lvm.conf" ]; then
mkdir -p /etc/lvm &&
cp -p "$destdir/etc/lvm/lvm.conf" /etc/lvm
fi
}

umount_chroot() {
fuser -vv -k -m "$destdir"

if [ -x "$CRYPTSETUP" ]; then
pushd /dev/mapper
for i in *_luks; do
"$CRYPTSETUP" luksClose "$i"
dmsetup remove "$i"
done
popd
fi

chroot "$destdir" swapoff -a

umount "$destdir/dev/pts"
chroot "$destdir" umount -a -v

# exclude " $destdir " itself
grep " $destdir/" /proc/mounts |
while read dev mnt rest; do umount -v "$mnt"; done

umount -v "$destdir" || return 1
}

reset_devmapper() {
# evms_deactivate does essentially the same but is normally missing
dmsetup remove_all ||:
}

stop_mdraid() {
# saving state is only important *after* evms
if [ -f /proc/mdstat -a -x "$MDADM" ]; then
"$MDADM" --examine --scan > /tmp/mdadm.conf
"$MDADM" --stop --scan
fi
}

start_mdraid() {
if [ -s /tmp/mdadm.conf -a -x "$MDADM" ]; then
# an arbitrary value of the year: packages installed already
sysctl -w dev.raid.speed_limit_max=1000000
"$MDADM" --assemble --run --scan --config=/tmp/mdadm.conf
fi
}

start_lvm() {
if [ -x "$LVM" ]; then
"$LVM" pvscan
"$LVM" vgscan
"$LVM" vgchange -ay --noudevsync
fi
}

start_luks() {
if [ -x "$CRYPTSETUP" ]; then
for device in $(blkid -o device); do
[ "$(blkid -o value -s TYPE "$device")" = "crypto_LUKS" ] || continue
"$CRYPTSETUP" isLuks "$device" || continue
"$CRYPTSETUP" --key-file "$CRYPTSETUP_KEY" luksOpen "$device" "$(basename "$device")_luks"
done
fi
}

mount_chroot() {
# depends on /tmp/fstab just like 10-fstab.sh
rootfs="$(awk '{ if ($2=="/") print $1 }' < /tmp/fstab)"
case "$rootfs" in
UUID=*)
rootfs="`blkid -U ${rootfs#UUID=}`"
;;
LABEL=*)
rootfs="`blkid -L ${rootfs#LABEL=}`"
;;
/*)
# all good as is
;;
*)
echo "remount: unknown rootfs: $rootfs" >&2
return 2
;;
esac

mount -v "$rootfs" "$destdir" || return 3

mount -v -o bind /dev "$destdir/dev"
mount -v -t sysfs sysfs "$destdir/sys"
mount -v -t proc proc "$destdir/proc"
chroot "$destdir" mount -a -v ||:

chroot "$destdir" swapon -a ||:

# NB: use "sleep 3600" here to debug :)
}
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin