\documentclass[12pt]{article}
\usepackage{euler}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage[colorlinks=true, urlcolor=blue, linkcolor=red]{hyperref}
\newcounter{Chapcounter}
\newcommand\showmycounter{\addtocounter{Chapcounter}{1}\themycounter}
\newcommand{\chapter}[1] 
{{\centering          
  \addtocounter{Chapcounter}{1} \Large \underline{\textbf{ \color{blue} Chapter \theChapcounter: ~#1}} }   
  \addcontentsline{toc}{section}{ \color{blue} Chapter:~\theChapcounter~~ #1}    
}
\hypersetup{colorlinks=true}
\hypersetup{linkcolor=black}

\title{Update PTU}
\author{Gerhard Hoffmann}
\date{\today}

\begin{document}
\maketitle
\chapter{Introduction}
    \section{Motivation}
        The two main components of a PSA are
        \begin{itemize}
            \item PTU software.
            \item Device controller (DC) firmware.
        \end{itemize}
    While the DC firmware is basically the same for each PSA (even for different
    customers), the PTU software is highly dependent on customer requirements.\par
    Hence, each customer is assigned an own git-repository, which will be loaded
    ("cloned") on the PSA when configuring the machine for the first time.\par
    Two special tools, the {\bf UpdateController} (a \href{https://doc.qt.io/qt-5/}{Qt}
    binary [{\bf \nameref{UpdateTool}}]) and the {\bf UpdateScript}
    (a \href{https://www.gnu.org/software/bash/manual/bash.html}{bash}
    script [{\bf \nameref{UpdateScript}}]), work together to finish a PSA installation.\par 
    
    \section{PSA: Initial configuration}
        For the initial configuration, a PSA loads a customer-specific git-repository,
        which structure is detailed below [{\bf \nameref{repostructure}}].\par
        The "git clone" for the repository is done by the UpdateScript [{\bf \nameref{UpdateScript}}].
        It updates the file
        \begin{center}
            \fbox{
                /opt/app/tools/atbupdate/update\_log.csv
            }
        \end{center}
        which will be interpreted by the UpdateController [{\bf \nameref{UpdateTool}}].
        The structure of {\bf update\_log.csv} is detailed below [{\bf \nameref{updatelogcsv}}].\par
        Each line of {\bf update\_log.csv} represents a command for the UpdateController,
        which will either download certain files to the DC or execute some
        \href{https://openwrt.org/docs/guide-user/additional-software/opkg}{opkg}
        commands [{\bf \nameref{opkg}}].
        
    \section{PSA: Update}
    
    \newpage
    
\chapter{Update-Tool "up\_dev\_ctrl"}
    \section{up\_dev\_ctrl}
    \label{UpdateTool}

        The update-tool is a Qt binary ("up\_dev\_ctrl") and called by the
        system-controller application. It is installed under
        \begin{center}
            \fbox{
                /opt/app/tools/atbupdate/up\_dev\_ctrl
            }
        \end{center}

        and has two responsibilities:
        \begin{itemize}
            \item Call update-script "update\_psa".
            \item Update the device controller firmware.
        \end{itemize}
    \subsection{Calling the update-script "update\_psa"}
        The update-script "update\_psa" is about executing all git-commands
        necessary to clone and pull a customer repository.

    \newpage

\chapter{Update-Script "update\_psa"}
    \section{update\_psa}
    \label{UpdateScript}

    Inside of such a
        repository, there are at least the following directories:
        \begin{itemize}
           \item {\bf etc} 
           \item {\bf etc/dc}\newline 
                Contains the device controller firmware as binary file.
           \item {\bf etc/psa\_config}\newline
                Contains the printer template files (JSON).
           \item {\bf etc/psa\_tariff}\newline
                Contains the tariff files (JSON).
           \item {\bf etc/psa\_update}\newline
                Contains a single file for opkg-commands.
        \end{itemize}
    \newpage

\chapter{Annex}
    \section{Structure of a customer git-repository}
    \label{repostructure}
    
    \section{Structure of "update\_log.csv"}
    \label{updatelogcsv}
    
    \section{The package manager "opkg"}
    \label{opkg}
\end{document}
