cloudymax / pxeless

An automated system install and image customization tool for when PXE is not an option, or is not an option yet.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make sudo conditional to user/env

ToroNZ opened this issue · comments

commented

Noticed that this function was expanded quite a bit and "sudo" is now a dependency (which broke CI builds for me in Bitbucket). Perhaps we could make sudo optional if not running as root or in CI runners?... like:

#!/bin/bash
if [ ! "$CI" ]; then
  if [ "$USER" != "root" ]; then
    SUDO="sudo "
  fi
fi

I've had a quick look and they seem to be related to #27 . Though I never had issues adding extra files in Ubuntu Focal (20.04). So there must be something more to it... I hope to dig a little bit deeper on the following days, for now I will lock this submodule to the previous commit.

BTW - Kudos @cloudymax for maintaining this tool :)

pxeless/image-create.sh

Lines 387 to 398 in d814df0

sudo unsquashfs "${SQUASH_FS}"
log " - Step 3. Copy extra files to /media..."
sudo cp -R "${EXTRA_FILES_FOLDER}/." "squashfs-root/media/"
if [ -n "$OFFLINE_INSTALLER" ]; then
log " - Step 3.5. Runing offline installer script..."
sudo chroot squashfs-root/ /bin/bash "/media/${OFFLINE_INSTALLER}"
fi
log " - Step 4. Rebuilding squashfs.."
sudo mksquashfs squashfs-root/ "${SQUASH_FS}" -comp xz -b 1M -noappend

commented

Thanks for the kind words as well as letting me know the changes cased issues with your flow, ill definitely need to do some testing to sort out a solution for user/group/root/sudo permissions.

I think part of the problem is that 20.04 is the last version before the switch to the new ISO creation process using El troito, but I was unable to get the previous extra files method to work on 22.04.

Could you share how your running the command for 20.04 so I can try to get in-sync with how you're using the tool?

Work has been very hectic this month so I apologize for the delayed reply 🙏