From f2789752372e307bb0f6f3097a9b2626641ad1fd Mon Sep 17 00:00:00 2001 From: Kron4ek Date: Thu, 28 Oct 2021 00:52:32 +0500 Subject: [PATCH] Add an argument to show version of the image --- conty-start.sh | 26 +++++++++++++++++++++----- create-arch-bootstrap.sh | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/conty-start.sh b/conty-start.sh index 2ef981b..04d1fbd 100755 --- a/conty-start.sh +++ b/conty-start.sh @@ -12,14 +12,14 @@ if [ $EUID = 0 ] && [ -z "$ALLOW_ROOT" ]; then exit 1 fi -script_version="1.17.1" +script_version="1.18" # Full path to the script script_literal="${BASH_SOURCE[0]}" script_name="$(basename "${script_literal}")" script="$(readlink -f "${script_literal}")" -# MD5 of the last 1 MB of the script +# MD5 of the last 1 MB of the file script_md5="$(tail -c 1000000 "${script}" | md5sum | head -c 7)" script_id="${RANDOM}" @@ -43,16 +43,18 @@ mount_point="${working_dir}"/mnt # a problem with mounting the image due to an incorrectly calculated offset. # The size of this script -scriptsize=29501 +scriptsize=29829 -# The size of the utils.tar.gz archive -# utils.tar.gz contains bwrap, squashfuse and dwarfs binaries +# The size of the utils archive utilssize=2928770 # Offset where the image is stored offset=$((scriptsize+utilssize)) # Set to 1 if you are using an image compressed with dwarfs instead of squashfs +# +# Also, don't forget to change the utilssize variable to the size of +# utils_dwarfs.tar.gz dwarfs_image=0 dwarfs_cache_size="128M" @@ -69,6 +71,7 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ] || ([ -z "$1" ] && [ ! -L "${script_li echo "Arguments:" echo echo -e "-v \tShow version of this script" + echo -e "-V \tShow version of the image" echo -e "-e \tExtract the image" echo -e "-o \tShow the image offset" echo -e "-l \tShow a list of all installed packages" @@ -474,6 +477,7 @@ if [ "$1" = "-u" ] || [ "$1" = "-U" ]; then cat < container-update.sh reflector --protocol https --score 5 --sort rate --save /etc/pacman.d/mirrorlist fakeroot -- pacman -Syy 2>/dev/null +date -u +"%d-%m-%Y %H:%M (DMY UTC)" > /version fakeroot -- pacman --noconfirm -S archlinux-keyring 2>/dev/null fakeroot -- pacman --noconfirm -S chaotic-keyring 2>/dev/null rm -rf /etc/pacman.d/gnupg @@ -485,6 +489,8 @@ fakeroot -- pacman --noconfirm --overwrite "*" -Su 2>/dev/null fakeroot -- pacman --noconfirm -Runs ${pkgsremove} 2>/dev/null fakeroot -- pacman --noconfirm -S ${pkgsinstall} 2>/dev/null rm -f /var/cache/pacman/pkg/* +pacman -Qn > /pkglist.x86_64.txt +pacman -Qm >> /pkglist.x86_64.txt update-ca-trust locale-gen EOF @@ -819,6 +825,16 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ exit fi + if [ "$1" = "-V" ]; then + if [ -f "${mount_point}"/version ]; then + cat "${mount_point}"/version + else + echo "Unknown version" + fi + + exit + fi + echo 1 > "${working_dir}"/running_"${script_id}" if [ "${dwarfs_image}" = 1 ] && [ "${QUIET_MODE}" != 1 ]; then diff --git a/create-arch-bootstrap.sh b/create-arch-bootstrap.sh index fbcbd19..b9137d6 100755 --- a/create-arch-bootstrap.sh +++ b/create-arch-bootstrap.sh @@ -179,6 +179,8 @@ sed -i 's/#ParallelDownloads = 5/ParallelDownloads = 3/g' "${bootstrap}"/etc/pac run_in_chroot pacman -Syu --noconfirm +date -u +"%d-%m-%Y %H:%M (DMY UTC)" > "${bootstrap}"/version + # These packages are required for the self-update feature to work properly run_in_chroot pacman --noconfirm --needed -S base reflector squashfs-tools fakeroot