diff --git a/arkdep b/arkdep index e6de652..168846c 100755 --- a/arkdep +++ b/arkdep @@ -114,7 +114,7 @@ init () { btrfs subvolume create $arkdep_dir || cleanup_and_quit "Failed to create btrfs subvolume" # Create directory structure - printf "\e[1;34m-->\e[0m\e[1m Creating directory structure\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Creating directory structure\e[0m\n' mkdir -pv $(readlink -m $arkdep_dir/deployments) \ $(readlink -m $arkdep_dir/deployments) \ $(readlink -m $arkdep_dir/cache) \ @@ -131,7 +131,7 @@ init () { btrfs property set -f -ts $(readlink -m $arkdep_dir/shared/home) ro false # Write default config file - printf "\e[1;34m-->\e[0m\e[1m Adding default config file\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Adding default config file\e[0m\n' cat <<- END > $arkdep_dir/config # Write /arkdep/overlay overlay to root or etc enable_overlay=1 @@ -264,7 +264,7 @@ remove_deployment () { # List all available packages defined in the repo's list file get_available () { printf "\e[1;34m-->\e[0m\e[1m Downloading list file from $repo_url\e[0m\n" - curl -sf "${repo_url}/list" || printf "\e[1;33m\e[0m\e[1m Failed to download list file\e[0m\n" + curl -sf "${repo_url}/list" || printf '\e[1;33m\e[0m\e[1m Failed to download list file\e[0m\n' exit 0 } @@ -286,7 +286,7 @@ list_deployed () { untracked=$(echo $untracked | xargs) if [[ ! -z $untracked ]]; then - printf "\nThe following deployments were found but are not tracked;\n" + printf '\nThe following deployments were found but are not tracked;\n' for t in $untracked; do printf "$t\n" done @@ -316,7 +316,7 @@ deploy () { printf "\e[1;34m-->\e[0m\e[1m Deploying $deploy_target $deploy_version\e[0m\n" # If latest is requested grab database and get first line - printf "\e[1;34m-->\e[0m\e[1m Downloading database from repo\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Downloading database from repo\e[0m\n' if [[ $deploy_version == 'latest' ]]; then declare curl_data=$(curl -sf "${repo_url}/${deploy_target}/database" | head -n 1) else @@ -367,13 +367,13 @@ deploy () { fi - printf "\e[1;34m-->\e[0m\e[1m Validating integrity\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Validating integrity\e[0m\n' sha1sum "$(readlink -m $arkdep_dir/cache/${data[0]}.tar.${data[1]})" | grep "${data[2]}" || cleanup_and_quit "Checksum does not match the one defined in database\e[0m\n" # Extract the root image if not yet extracted - printf "\e[1;34m-->\e[0m\e[1m Writing root\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Writing root\e[0m\n' # Create directory using unique deployment name mkdir -pv $(readlink -m $arkdep_dir/deployments/${data[0]}) || cleanup_and_quit 'Failed to create deployment directory' @@ -391,7 +391,7 @@ deploy () { rm $(readlink -m $arkdep_dir/cache/${data[0]}-rootfs.img) # Extract the etc image if not yet extracted - printf "\e[1;34m-->\e[0m\e[1m Writing etc\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Writing etc\e[0m\n' if [[ ! -e $arkdep_dir/cache/${data[0]}-etc.img ]]; then tar -xf $(readlink -m $arkdep_dir/cache/${data[0]}.tar.${data[1]}) -C $(readlink -m $arkdep_dir/cache/) "./${data[0]}-etc.img" || cleanup_and_quit 'failed to extract etc' @@ -404,7 +404,7 @@ deploy () { btrfs receive -f $(readlink -m $arkdep_dir/cache/${data[0]}-etc.img) $(readlink -m $arkdep_dir/deployments/${data[0]}/rootfs/) || cleanup_and_quit 'Failed to receive etc' - printf "\e[1;34m-->\e[0m\e[1m Ensure var, root and arkdep mountpoints exist\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Ensure var, root and arkdep mountpoints exist\e[0m\n' mkdir -pv $(readlink -m $arkdep_dir/deployments/${data[0]}/rootfs/var) mkdir -pv $(readlink -m $arkdep_dir/deployments/${data[0]}/rootfs/arkdep) @@ -421,7 +421,7 @@ deploy () { # Write the var image if [[ ! -e $arkdep_dir/shared/var ]]; then - printf "\e[1;34m-->\e[0m\e[1m Writing var\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Writing var\e[0m\n' # Extract the var image if not yet extracted if [[ ! -e $arkdep_dir/cache/${data[0]}-var.img ]]; then @@ -445,7 +445,7 @@ deploy () { # Add overlay if enabled if [[ $enable_overlay -eq 1 ]]; then - printf "\e[1;34m-->\e[0m\e[1m Copying overlay to deployment\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Copying overlay to deployment\e[0m\n' declare -r overlay_files=($(ls $arkdep_dir/overlay/)) # Check if only /etc is present, if it is we do not have to unlock the root volume @@ -469,7 +469,7 @@ deploy () { fi fi - printf "\e[1;34m-->\e[0m\e[1m Copying kernel image\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Copying kernel image\e[0m\n' # Get list of all available kernels kernels_installed=($(ls $arkdep_dir/deployments/${data[0]}/rootfs/usr/lib/modules/)) mkdir -pv $(readlink -m /boot/arkdep/${data[0]}) @@ -478,7 +478,7 @@ deploy () { cleanup_and_quit 'Failed to copy kernel image' # Install kernel and generate initramfs - printf "\e[1;34m-->\e[0m\e[1m Generating initramfs\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Generating initramfs\e[0m\n' dracut -k $arkdep_dir/deployments/${data[0]}/rootfs/usr/lib/modules/${kernels_installed[0]} \ --kernel-image /boot/arkdep/${data[0]}/vmlinuz \ --kver ${kernels_installed[0]} \ @@ -486,17 +486,17 @@ deploy () { /boot/arkdep/${data[0]}/initramfs-linux.img || cleanup_and_quit 'Failed to generate initramfs' # Add to database - printf "\e[1;34m-->\e[0m\e[1m Updating database\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Updating database\e[0m\n' printf "${data[0]}\n$(cat $(readlink -m $arkdep_dir/tracker))" | tee $arkdep_dir/tracker.tmp mv $arkdep_dir/tracker.tmp $arkdep_dir/tracker # Deploy bootloader configuration # also insert newline - printf "\n\e[1;34m-->\e[0m\e[1m Adding bootloader entry\e[0m\n" + printf '\n\e[1;34m-->\e[0m\e[1m Adding bootloader entry\e[0m\n' sed "s/%target%/${data[0]}/" $arkdep_dir/templates/systemd-boot > /boot/loader/entries/${data[0]}.conf - printf "\e[1;34m-->\e[0m\e[1m Setting new bootloader entry as default\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Setting new bootloader entry as default\e[0m\n' # Configuring it with a oneshot for now, for testing bootctl set-default ${data[0]}.conf || cleanup_and_quit "Failed to set default bootloader entry" #bootctl set-oneshot ${data[0]}.conf || cleanup_and_quit "Failed to set default bootloader entry" diff --git a/arkdep-build b/arkdep-build index 6744ed5..a68c486 100755 --- a/arkdep-build +++ b/arkdep-build @@ -122,7 +122,7 @@ if [[ $type == 'archlinux' ]]; then # Read base package list and install base system readarray base_packages < $configs_dir/$variant/base.list - printf "\e[1;34m-->\e[0m\e[1m Installing base packages\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Installing base packages\e[0m\n' pacstrap $workdir ${base_packages[*]} || cleanup_and_quit 'Failed to install secondary package list' # If overlay directory exists in variant copy it's contents to the temporary subvolume @@ -138,21 +138,21 @@ if [[ $type == 'archlinux' ]]; then fi # Clear pacman cache - printf "\e[1;34m-->\e[0m\e[1m Clearing pacman cache\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Clearing pacman cache\e[0m\n' arch-chroot $workdir pacman -Scc <<< Y <<< Y # Insert a new line to clean, the previous command fails to do so printf '\n' # Remove subvolumes created by systemd [[ -d $workdir/var/lib/portables ]] && - printf "\e[1;34m-->\e[0m\e[1m Removing systemd subvolume var/lib/portables\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Removing systemd subvolume var/lib/portables\e[0m\n' btrfs subvolume delete $workdir/var/lib/portables [[ -d $workdir/var/lib/machines ]] && - printf "\e[1;34m-->\e[0m\e[1m Removing systemd subvolume var/lib/machines\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Removing systemd subvolume var/lib/machines\e[0m\n' btrfs subvolume delete $workdir/var/lib/machines # Make /usr/local symlink in var - printf "\e[1;34m-->\e[0m\e[1m Moving dirs to var and creating symlinks\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Moving dirs to var and creating symlinks\e[0m\n' mv $workdir/usr/local $workdir/var/usrlocal || cleanup_and_quit 'Failed to move usr/local to var/usrlocal' ln -sv ../var/usrlocal $workdir/usr/local || cleanup_and_quit 'Failed to create usrlocal symlink' @@ -176,7 +176,7 @@ if [[ $type == 'archlinux' ]]; then mv $workdir/mnt $workdir/var/mnt || cleanup_and_quit 'Failed to move mnt to var/mnt' ln -sv var/mnt $workdir/mnt || cleanup_and_quit 'Failed to create mnt symlink' - printf "\e[1;34m-->\e[0m\e[1m Moving passwd, shadow and group files to lib\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Moving passwd, shadow and group files to lib\e[0m\n' # Create second passwd, group and shadow file in usr/lib and configure for file in passwd group shadow; do @@ -202,13 +202,13 @@ if [[ $type == 'archlinux' ]]; then rm $workdir/etc/{passwd-,shadow-,group-} # Make subvolume read-only - printf "\e[1;34m-->\e[0m\e[1m Adding read-only property to subvolumes\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Adding read-only property to subvolumes\e[0m\n' btrfs property set -ts $workdir ro true || cleanup_and_quit 'Failed to set root to read-only' btrfs property set -ts $workdir/etc ro true || cleanup_and_quit 'Failed to set etc to read-only' btrfs property set -ts $workdir/var ro true || cleanup_and_quit 'Failed to set var to read-only' # Generate random name for new image - printf "\e[1;34m-->\e[0m\e[1m Generating psuedo-random image name\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Generating psuedo-random image name\e[0m\n' declare -r image_name=$(gen_random_string) printf "$image_name\n" @@ -216,13 +216,13 @@ if [[ $type == 'archlinux' ]]; then mkdir -vp $(readlink -m $output_target/$image_name) # Write subvolume to image - printf "\e[1;34m-->\e[0m\e[1m Creating images\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Creating images\e[0m\n' btrfs send -f $output_target/$image_name/$image_name-rootfs.img $workdir btrfs send -f $output_target/$image_name/$image_name-etc.img $workdir/etc btrfs send -f $output_target/$image_name/$image_name-var.img $workdir/var if [[ ! -v ARKDEP_NO_TAR ]]; then - printf "\e[1;34m-->\e[0m\e[1m Compressing images\e[0m\n" + printf '\e[1;34m-->\e[0m\e[1m Compressing images\e[0m\n' tar -cv -I 'zstd -12 -T0 ' -f $output_target/$image_name.tar.zst -C $output_target/$image_name . fi