add SELinux check and adjust mode in setup script for non-NixOS systems
All checks were successful
Nix Format Check / check-format (push) Successful in 38s

This commit is contained in:
Menno van Leeuwen 2025-01-15 11:43:11 +01:00
parent e06b93215f
commit c11c4e7482
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE

View File

@ -409,6 +409,23 @@ warning_prompt() {
log_info "Starting setup..." log_info "Starting setup..."
} }
check_selinux() {
# Only on Non-NixOS based systems
if ! command -v nixos-version >/dev/null 2>&1; then
return 0
fi
if [ -eq "$(getenforce)" "Enforcing" ]; then
log_warning "SELinux is enabled. Adjusting SELinux to permissive mode..."
sudo setenforce Permissive || die "Failed to disable SELinux"
tee /etc/selinux/config <<EOF
SELINUX=permissive
SELINUXTYPE=targeted
EOF
log_success "SELinux disabled successfully."
fi
}
main() { main() {
# Check if setup has already been run # Check if setup has already been run
if [ -f "$SETUP_MARKER" ]; then if [ -f "$SETUP_MARKER" ]; then
@ -428,6 +445,7 @@ main() {
# Run setup steps # Run setup steps
warning_prompt warning_prompt
prepare_hostname prepare_hostname
check_selinux
install_nix install_nix
install_home_manager install_home_manager
setup_symlinks setup_symlinks