kayrus / deploy-vm

Libvirt wrapper to spawn VMs using cloud images
GNU General Public License v2.0
59 stars 19 forks source link

Fix selinux checker #1

Closed kayrus closed 8 years ago

kayrus commented 8 years ago

subj

kayrus commented 8 years ago

Selinux checker was fixed, but then removed in favor of ISO image.

Just for the history, code was:

  if [ -n $(selinuxenabled 2>/dev/null || echo "SELinux") ]; then
    if [[ -z $SUDO_YES ]]; then
      print_green "SELinux is enabled, this step requires sudo"
      read -p "Are you sure you want to modify SELinux fcontext? (Type 'y' when agree) " -n 1 -r
      echo
    fi

    if [[ $REPLY =~ ^[Yy]$ || "$SUDO_YES" == "yes" ]]; then
      unset $REPLY
      SUDO_YES="yes"
      print_green "Adding SELinux fcontext for the '$IMG_PATH/$VM_HOSTNAME' path"
      sudo semanage fcontext -d -t virt_content_t "$IMG_PATH/$VM_HOSTNAME(/.*)?" || true
      sudo semanage fcontext -a -t virt_content_t "$IMG_PATH/$VM_HOSTNAME(/.*)?"
      sudo restorecon -R "$IMG_PATH"
    else
      SUDO_YES="no"
    fi
  else
    print_green "Skipping SELinux context modification"
  fi