Skip to content

Commit

Permalink
Merge pull request #6 from Vilez0/encryption_support
Browse files Browse the repository at this point in the history
Encryption support and redesign questions page
  • Loading branch information
sulincix authored Jun 12, 2024
2 parents a25b348 + 80ac601 commit 4b31758
Show file tree
Hide file tree
Showing 8 changed files with 656 additions and 317 deletions.
266 changes: 158 additions & 108 deletions po/pardus-boot-repair.pot

Large diffs are not rendered by default.

280 changes: 170 additions & 110 deletions po/tr.po

Large diffs are not rendered by default.

299 changes: 205 additions & 94 deletions src/Main.py

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion src/data/ui/AppWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<property name="can-focus">False</property>
<property name="icon-name">window-close-symbolic</property>
</object>
<object class="GtkImage" id="image_button_continue">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">go-next-symbolic</property>
</object>
<object class="GtkImage" id="image_button_copy_logs">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -515,9 +520,25 @@
<property name="orientation">vertical</property>
<property name="spacing">16</property>
<child>
<object class="HdyHeaderBar">
<object class="HdyHeaderBar" id="titlebar_page_questions">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="has-subtitle">False</property>
<child>
<object class="GtkButton" id="button_questions_continue">
<property name="label" translatable="yes">Continue</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image_button_continue</property>
<property name="image-position">right</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_mainpage1">
<property name="label" translatable="yes">Main page</property>
Expand All @@ -528,6 +549,9 @@
<property name="always-show-image">True</property>
<signal name="clicked" handler="on_button_mainpage_clicked" swapped="no"/>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
Expand Down
11 changes: 7 additions & 4 deletions src/scripts/check-filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
while [[ ! -b /dev/$disk ]] ; do
echo $(ls /sys/block/* | grep "[0-9]$")
echo -n "partition >>> "
read part
read disk
done
type=$(blkid | grep /dev/$disk | sed "s/.*TYPE=\"//g;s/\".*//g")
if [[ "$type" == "ext4" ]] ; then
fs=$(blkid | grep /dev/$disk | sed "s/.*TYPE=\"//g;s/\".*//g")

source /usr/bin/pardus-open-luks-lvm

if [[ "$fs" == "ext4" ]] ; then
yes "" | fsck.ext4 -f -y /dev/$disk

else
yes "" | fsck.$type /dev/$disk
yes "" | fsck.$fs /dev/$disk
fi
3 changes: 3 additions & 0 deletions src/scripts/pardus-mount-rootfs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ done

umount -lf /dev/$disk 2>/dev/null || true
fs="$(lsblk -no FSTYPE /dev/$disk | tr -d '\n')"

source /usr/bin/pardus-open-luks-lvm

mount /dev/$disk "$DESTDIR"

# btrfs subvolumes
Expand Down
86 changes: 86 additions & 0 deletions src/scripts/pardus-open-luks-lvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash

if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi

if [[ $(ls /sys/block/* | grep "[0-9]$" | wc -l) -eq 0 ]]; then
echo "No block devices found"
exit 1
fi

# check if $DESTDIR is a valid directory
if [[ ! -d $DESTDIR ]]; then
DESTDIR=$(mktemp -d)
fi

while [[ ! -b /dev/$disk ]]; do
echo $(ls /sys/block/* | grep "[0-9]$")
echo -n "Rootfs partition >>> "
read disk
done

if [[ -z $fs ]]; then
fs=""
fi

if $(cryptsetup isLuks /dev/$disk); then
if [[ $(lsblk -r -o NAME,TYPE /dev/$disk | grep crypt | awk '{print $1 }') == "" ]]; then
LUKS_NAME="luks-$(date +%d-%m-%y_%H-%M-%S)"
cryptsetup open /dev/$disk $LUKS_NAME
disk="/mapper/$LUKS_NAME"
fs="$(lsblk -rno FSTYPE /dev/$disk | head -n 1)"
else
disk="mapper/$(lsblk -r -o NAME,TYPE /dev/$disk | grep crypt | awk '{print $1 }')"
fs="$(lsblk -rno FSTYPE /dev/$disk | head -n 1)"
fi
fi

if [[ $fs == 'LVM2_member' ]]; then
# detect volume groups
VG_NAMES=($(vgdisplay --colon | awk -F: '{print $1}' | xargs))
if [ ${#VG_NAMES[@]} -eq 0 ]; then
echo "No volume groups found."
exit 1
elif [ ${#VG_NAMES[@]} -gt 1 ]; then
while true; do
echo "Multiple volume groups found, please select one of:"
echo ${VG_NAMES[@]}
read -p "volume group >>> " VG_NAME
if [[ ${VG_NAMES[@]} =~ $VG_NAME ]]; then
break
else
echo "Invalid input. Please enter a valid number."
fi
done
else
VG_NAME=${VG_NAMES[0]}
fi
vgchange -ay $VG_NAME

# Find the logical volumes
LV_NAMES=($(lvdisplay --colon | grep ":$VG_NAME:" | awk -F: '{print $1}'))
for lv in ${!LV_NAMES[@]}; do
LV_NAMES[$lv]=$(echo ${LV_NAMES[$lv]} | sed "s/.*\/$VG_NAME\///")
done
if [ ${#LV_NAMES[@]} -eq 0 ]; then
echo "No logical volumes found."
exit 1
elif [ ${#LV_NAMES[@]} -gt 1 ]; then
while true; do
echo "Multiple logical volumes found, please select one of:"
echo "${!LV_NAMES[@]}"
read -p "logical volume >>> " LV_NAME
if [[ ${!LV_NAMES[@]} =~ $LV_NAME ]]; then
break
else
echo "Invalid input. Please enter a valid number."
fi
done
else
LV_NAME=${LV_NAMES[0]}
fi
disk="$VG_NAME/$LV_NAME"
fs="$(lsblk -rno FSTYPE /dev/$disk | head -n 1)"
fi
2 changes: 2 additions & 0 deletions src/scripts/search-operating-system
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ for part in $parts; do
fi
umount -lf -R $tmpdir 2>/dev/null
done

exit 0

0 comments on commit 4b31758

Please sign in to comment.