\documentclass[letterpaper]{article}
\usepackage{common/ohpc-doc}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

% Include git variables
\input{vc.tex}

% Define Base OS and other local macros
\newcommand{\baseOS}{Ubuntu 24.04 LTS}
\newcommand{\OSRepo}{Ubuntu\_24.04}
\newcommand{\OSTree}{Ubuntu\_24.04}
\newcommand{\OSTag}{ubuntu24.04}
\newcommand{\baseos}{ubuntu-24.04}
\newcommand{\baseosshort}{ubuntu24.04}
\newcommand{\osimage}{ubuntu:24.04}
\newcommand{\provisioner}{Warewulf4}
\newcommand{\provheader}{\provisioner{}}
\newcommand{\rms}{SLURM}
\newcommand{\rmsshort}{slurm}
\newcommand{\arch}{x86\_64}

% Define package manager commands
\newcommand{\pkgmgr}{apt}
\newcommand{\addrepo}{add-apt-repository -y}
\newcommand{\chrootaddrepo}{wwctl image exec --build=false ubuntu-24.04 -- add-apt-repository -y}
\newcommand{\clean}{apt update}
\newcommand{\chrootclean}{wwctl image exec --build=false ubuntu-24.04 -- apt update}
\newcommand{\install}{apt -y install}
\newcommand{\chrootinstall}{wwctl image exec --build=false ubuntu-24.04 -- apt -y install}
\newcommand{\groupinstall}{apt -y install}
\newcommand{\groupchrootinstall}{wwctl image exec --build=false ubuntu-24.04 -- apt -y install}
\newcommand{\remove}{apt -y remove}
\newcommand{\upgrade}{apt -y install --only-upgrade}
\newcommand{\chrootupgrade}{wwctl image exec --build=false ubuntu-24.04 -- apt -y install --only-upgrade}
\newcommand{\tftppkg}{syslinux-tftpboot}
\newcommand{\beegfsrepo}{https://www.beegfs.io/release/beegfs\_7.4.5/dists/beegfs-rhel9.repo}

% boolean for os-specific formatting
\toggletrue{isCentOS}
\toggletrue{isCentOS_ww_slurm_x86}
\toggletrue{isUbuntu}
\toggletrue{isSLURM}
\toggletrue{isWarewulf}
\toggletrue{isWarewulf4}
\toggletrue{isx86}
\toggletrue{isCentOS_x86}

\begin{document}
\graphicspath{{common/figures/}}
\thispagestyle{empty}

% Title Page
\input{common/title}
% Disclaimer
\input{common/legal}

\newpage
\tableofcontents
\newpage

% Introduction  --------------------------------------------------

\section{Introduction} \label{sec:introduction}
\input{common/install_header}
\input{common/intro} \\

\input{common/base_edition/edition}
\input{common/audience}
\input{common/requirements}
\input{common/inputs}

% begin_ohpc_run
% ohpc_validation_newline
% ohpc_validation_comment Verify OpenHPC repository has been enabled before proceeding
% ohpc_validation_newline
% ohpc_command apt-cache policy ohpc-release | grep -q versatushpc
% ohpc_command if [ $? -ne 0 ];then
% ohpc_command    echo "Error: OpenHPC repository must be enabled locally"
% ohpc_command    exit 1
% ohpc_command fi
% end_ohpc_run

% Base Operating System --------------------------------------------

\section{Install Base Operating System (BOS)}
\input{common/bos}

%\clearpage
% begin_ohpc_run
% ohpc_validation_newline
% ohpc_validation_comment Disable firewall
\begin{lstlisting}[language=bash,keywords={}]
[sms](*\#*) systemctl disable --now ufw
\end{lstlisting}
% end_ohpc_run

% ------------------------------------------------------------------

\section{Install \OHPC{} Components} \label{sec:basic_install}
\input{common/install_ohpc_components_intro.tex}

\subsection{Enable \OHPC{} repository for local use} \label{sec:enable_repo}
\input{common/enable_ohpc_repo_ubuntu}
\input{common/ubuntu_repos}
\input{common/automation}


\subsection{Add provisioning services on {\em master} node} \label{sec:add_provisioning}
\input{common/install_provisioning_warewulf4_intro_ubuntu}
\input{common/enable_pxe}
\input{common/time_ubuntu}

\vspace*{0.15cm}
\subsection{Add resource management services on {\em master} node} \label{sec:add_rm}
\input{common/install_slurm_ubuntu}

\subsection{Optionally add \InfiniBand{} support services on {\em master} node} \label{sec:add_ofed}
\input{common/ibsupport_sms_ubuntu}

\subsection{Optionally add \OmniPath{} support services on {\em master} node} \label{sec:add_opa}
\input{common/opasupport_sms_ubuntu}

\vspace*{-0.15cm}
\subsection{Complete basic Warewulf setup for {\em master} node} \label{sec:setup_ww}
\input{common/warewulf4_setup}
\input{common/warewulf4_setup_ubuntu}

\subsection{Define {\em compute} image for provisioning}
\input{common/warewulf4_mkchroot_ubuntu}

\subsubsection{Add \OHPC{} components} \label{sec:add_components}
\input{common/warewulf4_add_to_compute_chroot_intro_ubuntu}
\input{common/warewulf4_add_to_compute_chroot_slurm_ubuntu}

\vspace*{.2cm}
\subsubsection{Customize system configuration} \label{sec:master_customization}
\input{common/oneapi_mountpoint}

% Additional commands when additional computes are requested

% begin_ohpc_run
% ohpc_validation_newline
% ohpc_validation_comment Update basic slurm configuration if additional computes defined
% ohpc_command if [ ${num_computes} -gt 4 ];then
% ohpc_command    perl -pi -e "s/^NodeName=(\S+)/NodeName=${compute_prefix}[1-${num_computes}]/" /etc/slurm/slurm.conf
% ohpc_command    perl -pi -e "s/^PartitionName=normal Nodes=(\S+)/PartitionName=normal Nodes=${compute_prefix}[1-${num_computes}]/" /etc/slurm/slurm.conf

% ohpc_command fi
% end_ohpc_run

%\clearpage
\subsubsection{Additional Customization ({\em optional})} \label{sec:addl_customizations}
\input{common/compute_customizations_intro}

%\clearpage
\paragraph{Enable \InfiniBand{} drivers}
\input{common/ibsupport_compute_ubuntu.tex}

\paragraph{Enable \OmniPath{} drivers}
\input{common/opasupport_compute_ubuntu.tex}

\vspace*{0.28cm}
\paragraph{Increase locked memory limits}
\input{common/memlimits}

\vspace*{-.17cm}
\paragraph{Enable ssh control via resource manager}
\input{common/slurm_pam}

%\vspace*{-.17cm}
%\paragraph{Add \beegfs{}} \label{sec:add_beegfs}
%\input{common/install_beegfs_client_ubuntu}

%\paragraph{Add \Lustre{} client} \label{sec:lustre_client}
%\input{common/lustre-client}
%%\vspace*{0.25cm}
%\input{common/lustre-client-ubuntu}
%\input{common/lustre-client-post}

\paragraph{Add GPU driver}
\input{common/install_gpu_driver_nvidia_ubuntu}

%\vspace*{.45cm}
\paragraph{Enable forwarding of system logs} \label{sec:add_syslog}
\input{common/syslog_ubuntu}

\paragraph{Add \clustershell{}}
\input{common/clustershell}

\paragraph{Add \genders{}}
\input{common/genders}

\paragraph{Add Magpie}
\input{common/magpie}

\paragraph{Add \conman{}} \label{sec:add_conman}
\input{common/conman}

\paragraph{Add \nhc{}} \label{sec:add_nhc}
\input{common/nhc}
\input{common/nhc_slurm}

%\clearpage
\subsubsection{Import files} \label{sec:file_import}
\input{common/import_ww4_files}
%\vspace*{0.3cm}
\input{common/import_ww4_files_slurm}
\input{common/import_ww4_files_ib_ubuntu}
%\vspace*{0.3cm}
\input{common/finalize_warewulf4_provisioning_ubuntu}
%\vspace*{0.2cm}
\input{common/add_ww4_hosts_intro}
\input{common/add_ww4_hosts_finalize}
\input{common/add_ww4_hosts_slurm}

\subsubsection{Optional kernel arguments} \label{sec:optional_kargs}
\input{common/charliecloud_ubuntu_warewulf_post}
\input{common/warewulf4_kargs_post}

%\vspace*{-0.4cm}
\subsection{Boot compute nodes} \label{sec:boot_computes}
\input{common/reset_computes}

%\clearpage
\section{Install \OHPC{} Development Components}
\input{common/dev_intro.tex}

%\vspace*{-0.15cm}
\subsection{Development Tools} \label{sec:install_dev_tools}
\input{common/dev_tools_ubuntu}

\vspace*{-0.15cm}
\subsection{Compilers} \label{sec:install_compilers}
\input{common/compilers}

%\clearpage
\subsection{MPI Stacks} \label{sec:mpi}
\input{common/mpi_slurm_ubuntu}

\subsection{Performance Tools} \label{sec:install_perf_tools}
\input{common/perf_tools}

\subsection{Setup default development environment}
\input{common/default_dev_ubuntu}

\vspace*{0.3cm}
\subsection{3rd Party Libraries and Tools} \label{sec:3rdparty}
\input{common/third_party_libs_intro}
\input{common/third_party_libs_petsc_ubuntu}
\input{common/third_party_libs_ubuntu}
\vspace*{0.1cm}
\input{common/third_party_mpi_libs_x86_ubuntu}
\vspace*{0.5cm}
\subsection{Optional Development Tool Builds} \label{sec:3rdparty_intel}
\input{common/oneapi_enabled_builds_slurm_ubuntu.tex}

\clearpage
\section{Resource Manager Startup} \label{sec:rms_startup}
\input{common/slurm_startup}

\section{Post-boot compute node configuration} \label{sec:post_boot}
\input{common/post_boot}

\section{Run a Test Job} \label{sec:test_job}
\input{common/warewulf4_slurm_test_job}

\clearpage
\appendix
%\section*{Appendices}
{\bf \LARGE \centerline{Appendices}} \vspace*{0.2cm}

\addcontentsline{toc}{section}{Appendices}
\renewcommand{\thesubsection}{\Alph{subsection}}

\input{common/automation_appendix}
\input{common/upgrade_ubuntu}
\input{common/test_suite_ubuntu}
\input{common/customization_appendix_ubuntu}
\input{manifest}
\input{common/signature_ubuntu}


\end{document}
