From c429549a61fde6bdf5acf6788d56dc68b824e0fb Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 20 Oct 2023 12:04:25 +0300 Subject: [PATCH] some initial work --- pikainstall/usr/bin/pikainstall | 18 +++++++++++++++++ .../lib/pika/pikainstall/partition-helper.sh | 20 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 pikainstall/usr/bin/pikainstall create mode 100755 pikainstall/usr/lib/pika/pikainstall/partition-helper.sh diff --git a/pikainstall/usr/bin/pikainstall b/pikainstall/usr/bin/pikainstall new file mode 100755 index 0000000..28be6fc --- /dev/null +++ b/pikainstall/usr/bin/pikainstall @@ -0,0 +1,18 @@ +#! /bin/python3 + +import argparse +import subprocess + +parser = argparse.ArgumentParser() +parser.add_argument("-r", "--root", help="The Path where root is mounted to.", metavar="/mnt/root", default=argparse.SUPPRESS, required=True, nargs=1) +parser.add_argument("-b", "--boot", help="The Path where boot is mounted to.", metavar="/mnt/root/boot", default=argparse.SUPPRESS, required=True, nargs=1) +parser.add_argument("-e", "--efi", help="The Path where EFI is mounted to.", metavar="/mnt/root/boot/efi", default=argparse.SUPPRESS, required=True, nargs=1) +parser.add_argument("-H", "--home", help="The Path where home is mounted to.", metavar="/mnt/root/home", default=None, nargs=1) +args = parser.parse_args() + +# Print all command-line arguments. +print("Parsed arguments: {}".format(args)) +print(r) +if args.home is not None: + print("good") + exit(1) diff --git a/pikainstall/usr/lib/pika/pikainstall/partition-helper.sh b/pikainstall/usr/lib/pika/pikainstall/partition-helper.sh new file mode 100755 index 0000000..f4f3d30 --- /dev/null +++ b/pikainstall/usr/lib/pika/pikainstall/partition-helper.sh @@ -0,0 +1,20 @@ +#! /bin/bash + +if [[ -z $2 ]] +then + echo "no mount point specified" && exit 1 +fi + +if [[ "$1" == "part" ]] +then + df -P -h -T "$2" | awk 'END{print $1}' +elif [[ "$1" == "block" ]] +then + echo "/dev/$(lsblk -ndo pkname $(df -P "$2" | awk 'END{print $1}'))" +elif [[ "$1" == "uuid" ]] +then + blkid "$(df -P -h -T "$2" | awk 'END{print $1}')" -s UUID -o value +else + echo "invalid first args not in: part, block, uuid" && exit 1 +fi +