From a7604c00bd58de79500a7bb7da7fe03904b38347 Mon Sep 17 00:00:00 2001 From: lgromero Date: Thu, 11 Apr 2024 12:56:26 +0200 Subject: [PATCH] refs #199 adds download repo and copy paste to tftpboot opengsys functions --- installer/ogboot_installer.sh | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/installer/ogboot_installer.sh b/installer/ogboot_installer.sh index 0fbdc49..1d5f9c7 100644 --- a/installer/ogboot_installer.sh +++ b/installer/ogboot_installer.sh @@ -2,3 +2,66 @@ echo "Hello world" touch "Hello world" +BRANCH=$1 +if [[ -z $BRANCH ]]; then + BRANCH="main" +fi +GIT_REPO="ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git" +# Obtiene el código fuente del proyecto desde el repositorio de GitHub. +function downloadCode() +{ + if [ $# -ne 1 ]; then + echo "${FUNCNAME}(): invalid number of parameters" + exit 1 + fi + + local url="$1" + + echo "${FUNCNAME}(): downloading code from '$url'..." + + GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=accept-new" git archive --remote=$url --format zip --output ogboot.zip --prefix=ogboot/ $BRANCH && unzip ogboot.zip + if [ $? -ne 0 ]; then + echo "${FUNCNAME}(): error getting OpenGnsys code from $url" + return 1 + fi + rm -f ogboot.zip + echo "${FUNCNAME}(): code was downloaded" + return 0 +} + +function add_tftpboot_files() { + # Navegar al directorio ogboot + cd ogboot + + src_dir="tftpboot" + dest_dir="/opt/opengnsys/tftpboot" + + # Crear el directorio de destino si no existe + mkdir -p "$dest_dir" + + # Copiar los archivos sin sobrescribir los existentes + cp -rn "$src_dir/." "$dest_dir/" + + # Comprobar si la copia fue exitosa + if [ $? -eq 0 ]; then + echo "Los archivos se añadieron con éxito." + else + echo "Hubo un error al añadir los archivos." + fi + + # Volver al directorio original + cd .. +} + + +downloadCode $GIT_REPO +if [ $? -ne 0 ]; then + echo "Error while getting code from the repository" + exit 1 +fi + +add_tftpboot_files +if [ $? -ne 0 ]; then + echo "Error añadiendo ficheros" + exit 1 +fi \ No newline at end of file