diff --git a/art/Opengnsys-wallpaper.jpg b/graf_installer/art/Opengnsys-wallpaper.jpg similarity index 100% rename from art/Opengnsys-wallpaper.jpg rename to graf_installer/art/Opengnsys-wallpaper.jpg diff --git a/art/logo_ogw.png b/graf_installer/art/logo_ogw.png similarity index 100% rename from art/logo_ogw.png rename to graf_installer/art/logo_ogw.png diff --git a/art/opengnsys-logo.png b/graf_installer/art/opengnsys-logo.png similarity index 100% rename from art/opengnsys-logo.png rename to graf_installer/art/opengnsys-logo.png diff --git a/builder.sh b/graf_installer/builder.sh similarity index 100% rename from builder.sh rename to graf_installer/builder.sh diff --git a/buildlib.sh b/graf_installer/buildlib.sh similarity index 100% rename from buildlib.sh rename to graf_installer/buildlib.sh diff --git a/calamares/modules/bootloader.conf b/graf_installer/calamares/modules/bootloader.conf similarity index 100% rename from calamares/modules/bootloader.conf rename to graf_installer/calamares/modules/bootloader.conf diff --git a/calamares/modules/bootloader/bootloader.conf b/graf_installer/calamares/modules/bootloader/bootloader.conf similarity index 100% rename from calamares/modules/bootloader/bootloader.conf rename to graf_installer/calamares/modules/bootloader/bootloader.conf diff --git a/calamares/modules/mount.conf b/graf_installer/calamares/modules/mount.conf similarity index 100% rename from calamares/modules/mount.conf rename to graf_installer/calamares/modules/mount.conf diff --git a/calamares/modules/mount/mount.conf b/graf_installer/calamares/modules/mount/mount.conf similarity index 100% rename from calamares/modules/mount/mount.conf rename to graf_installer/calamares/modules/mount/mount.conf diff --git a/calamares/modules/packages.conf b/graf_installer/calamares/modules/packages.conf similarity index 100% rename from calamares/modules/packages.conf rename to graf_installer/calamares/modules/packages.conf diff --git a/calamares/modules/packages/packages.conf b/graf_installer/calamares/modules/packages/packages.conf similarity index 100% rename from calamares/modules/packages/packages.conf rename to graf_installer/calamares/modules/packages/packages.conf diff --git a/calamares/modules/shell_chroot.conf b/graf_installer/calamares/modules/shell_chroot.conf similarity index 100% rename from calamares/modules/shell_chroot.conf rename to graf_installer/calamares/modules/shell_chroot.conf diff --git a/calamares/modules/shell_nonchroot.conf b/graf_installer/calamares/modules/shell_nonchroot.conf similarity index 100% rename from calamares/modules/shell_nonchroot.conf rename to graf_installer/calamares/modules/shell_nonchroot.conf diff --git a/calamares/modules/shellprocess/shell_chroot.conf b/graf_installer/calamares/modules/shellprocess/shell_chroot.conf similarity index 100% rename from calamares/modules/shellprocess/shell_chroot.conf rename to graf_installer/calamares/modules/shellprocess/shell_chroot.conf diff --git a/calamares/modules/shellprocess/shell_nonchroot.conf b/graf_installer/calamares/modules/shellprocess/shell_nonchroot.conf similarity index 100% rename from calamares/modules/shellprocess/shell_nonchroot.conf rename to graf_installer/calamares/modules/shellprocess/shell_nonchroot.conf diff --git a/calamares/modules/unpackfs.conf b/graf_installer/calamares/modules/unpackfs.conf similarity index 100% rename from calamares/modules/unpackfs.conf rename to graf_installer/calamares/modules/unpackfs.conf diff --git a/calamares/modules/unpackfs/unpackfs.conf b/graf_installer/calamares/modules/unpackfs/unpackfs.conf similarity index 100% rename from calamares/modules/unpackfs/unpackfs.conf rename to graf_installer/calamares/modules/unpackfs/unpackfs.conf diff --git a/calamares/modules/users.conf b/graf_installer/calamares/modules/users.conf similarity index 100% rename from calamares/modules/users.conf rename to graf_installer/calamares/modules/users.conf diff --git a/calamares/modules/users/users.conf b/graf_installer/calamares/modules/users/users.conf similarity index 100% rename from calamares/modules/users/users.conf rename to graf_installer/calamares/modules/users/users.conf diff --git a/calamares/settings.conf b/graf_installer/calamares/settings.conf similarity index 100% rename from calamares/settings.conf rename to graf_installer/calamares/settings.conf diff --git a/calamares/src/branding/opengnsys/Opengnsys-wallpaper.jpg b/graf_installer/calamares/src/branding/opengnsys/Opengnsys-wallpaper.jpg similarity index 100% rename from calamares/src/branding/opengnsys/Opengnsys-wallpaper.jpg rename to graf_installer/calamares/src/branding/opengnsys/Opengnsys-wallpaper.jpg diff --git a/calamares/src/branding/opengnsys/banner.png b/graf_installer/calamares/src/branding/opengnsys/banner.png similarity index 100% rename from calamares/src/branding/opengnsys/banner.png rename to graf_installer/calamares/src/branding/opengnsys/banner.png diff --git a/calamares/src/branding/opengnsys/banner.png.license b/graf_installer/calamares/src/branding/opengnsys/banner.png.license similarity index 100% rename from calamares/src/branding/opengnsys/banner.png.license rename to graf_installer/calamares/src/branding/opengnsys/banner.png.license diff --git a/calamares/src/branding/opengnsys/branding.desc b/graf_installer/calamares/src/branding/opengnsys/branding.desc similarity index 100% rename from calamares/src/branding/opengnsys/branding.desc rename to graf_installer/calamares/src/branding/opengnsys/branding.desc diff --git a/calamares/src/branding/opengnsys/lang/calamares-default_ar.qm b/graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_ar.qm similarity index 100% rename from calamares/src/branding/opengnsys/lang/calamares-default_ar.qm rename to graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_ar.qm diff --git a/calamares/src/branding/opengnsys/lang/calamares-default_en.qm b/graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_en.qm similarity index 100% rename from calamares/src/branding/opengnsys/lang/calamares-default_en.qm rename to graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_en.qm diff --git a/calamares/src/branding/opengnsys/lang/calamares-default_eo.qm b/graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_eo.qm similarity index 100% rename from calamares/src/branding/opengnsys/lang/calamares-default_eo.qm rename to graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_eo.qm diff --git a/calamares/src/branding/opengnsys/lang/calamares-default_fr.qm b/graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_fr.qm similarity index 100% rename from calamares/src/branding/opengnsys/lang/calamares-default_fr.qm rename to graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_fr.qm diff --git a/calamares/src/branding/opengnsys/lang/calamares-default_nl.qm b/graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_nl.qm similarity index 100% rename from calamares/src/branding/opengnsys/lang/calamares-default_nl.qm rename to graf_installer/calamares/src/branding/opengnsys/lang/calamares-default_nl.qm diff --git a/calamares/src/branding/opengnsys/languages.png b/graf_installer/calamares/src/branding/opengnsys/languages.png similarity index 100% rename from calamares/src/branding/opengnsys/languages.png rename to graf_installer/calamares/src/branding/opengnsys/languages.png diff --git a/calamares/src/branding/opengnsys/languages.png.license b/graf_installer/calamares/src/branding/opengnsys/languages.png.license similarity index 100% rename from calamares/src/branding/opengnsys/languages.png.license rename to graf_installer/calamares/src/branding/opengnsys/languages.png.license diff --git a/calamares/src/branding/opengnsys/logo_ogw.png b/graf_installer/calamares/src/branding/opengnsys/logo_ogw.png similarity index 100% rename from calamares/src/branding/opengnsys/logo_ogw.png rename to graf_installer/calamares/src/branding/opengnsys/logo_ogw.png diff --git a/calamares/src/branding/opengnsys/show.qml b/graf_installer/calamares/src/branding/opengnsys/show.qml similarity index 100% rename from calamares/src/branding/opengnsys/show.qml rename to graf_installer/calamares/src/branding/opengnsys/show.qml diff --git a/calamares/src/branding/opengnsys/squid.png b/graf_installer/calamares/src/branding/opengnsys/squid.png similarity index 100% rename from calamares/src/branding/opengnsys/squid.png rename to graf_installer/calamares/src/branding/opengnsys/squid.png diff --git a/calamares/src/branding/opengnsys/squid.png.license b/graf_installer/calamares/src/branding/opengnsys/squid.png.license similarity index 100% rename from calamares/src/branding/opengnsys/squid.png.license rename to graf_installer/calamares/src/branding/opengnsys/squid.png.license diff --git a/calamares/src/branding/opengnsys/stylesheet.qss b/graf_installer/calamares/src/branding/opengnsys/stylesheet.qss similarity index 100% rename from calamares/src/branding/opengnsys/stylesheet.qss rename to graf_installer/calamares/src/branding/opengnsys/stylesheet.qss diff --git a/calamares/src/modules b/graf_installer/calamares/src/modules similarity index 100% rename from calamares/src/modules rename to graf_installer/calamares/src/modules diff --git a/chroot_setup.sh b/graf_installer/chroot_setup.sh similarity index 100% rename from chroot_setup.sh rename to graf_installer/chroot_setup.sh diff --git a/conf/pcmanfm.conf b/graf_installer/conf/pcmanfm.conf similarity index 100% rename from conf/pcmanfm.conf rename to graf_installer/conf/pcmanfm.conf diff --git a/pat.txt b/graf_installer/pat.txt similarity index 100% rename from pat.txt rename to graf_installer/pat.txt diff --git a/provision_ogcore.sh b/graf_installer/provision_ogcore.sh similarity index 100% rename from provision_ogcore.sh rename to graf_installer/provision_ogcore.sh diff --git a/provision_oggui.sh b/graf_installer/provision_oggui.sh similarity index 100% rename from provision_oggui.sh rename to graf_installer/provision_oggui.sh diff --git a/root_passwd b/graf_installer/root_passwd similarity index 100% rename from root_passwd rename to graf_installer/root_passwd diff --git a/setup_chroot_ubuntu.sh b/graf_installer/setup_chroot_ubuntu.sh similarity index 100% rename from setup_chroot_ubuntu.sh rename to graf_installer/setup_chroot_ubuntu.sh diff --git a/component-installer.sh b/non_graf_installer/component-installer.sh similarity index 100% rename from component-installer.sh rename to non_graf_installer/component-installer.sh diff --git a/component-installer/component-installer.sh b/non_graf_installer/component-installer/component-installer.sh similarity index 98% rename from component-installer/component-installer.sh rename to non_graf_installer/component-installer/component-installer.sh index 54a3125..08ef618 100644 --- a/component-installer/component-installer.sh +++ b/non_graf_installer/component-installer/component-installer.sh @@ -21,6 +21,10 @@ OGREPOSITORY_REPO="$OPENGNSYS_BASE_URL/ogrepository.git" export GIT_SSL_NO_VERIFY=1 +# Creamos el usuario opengnsys + +useradd -m -d /opt/opengnsys -r -s /bin/bash opengnsys + ## Functions function install_docker() { @@ -123,7 +127,7 @@ do mkdir -p $component_dir/etc cp $component_dir/repo/.env $component_dir/etc/ cp $component_dir/repo/env.json $component_dir/etc/ - mkdir -p $component_dir/etc/ + chown 82:82 $component_dir/etc/env.json mkdir -p $component_dir/bin/ cp $CONFIGS_DIR/provision_ogcore.sh $component_dir/bin/ chmod 755 $component_dir/bin/provision_ogcore.sh diff --git a/component-installer/provision_ogcore.sh b/non_graf_installer/component-installer/provision_ogcore.sh similarity index 91% rename from component-installer/provision_ogcore.sh rename to non_graf_installer/component-installer/provision_ogcore.sh index 8e7cd18..70ebd92 100644 --- a/component-installer/provision_ogcore.sh +++ b/non_graf_installer/component-installer/provision_ogcore.sh @@ -3,14 +3,8 @@ set -x CONF_DIR=/opt/opengnsys/ogCore/etc/ -cd /opt/opengnsys/ogCore/repo/ +cd /opt/opengnsys/ogCore/repo/ || exit -# Preparar el fichero .yaml -# CONF_DIR=/opt/opengnsys/ogCore/etc/ -# mkdir -p $CONF_DIR - -# Copiar el fichero de configuración a CONF_DIR -# cp docker-compose-deploy.yml $CONF_DIR/ if [ -f /opt/opengnsys/ogCore/installer/.deployed ]; then echo "ogCore ya instalado" @@ -48,5 +42,6 @@ curl -k -L --location 'https://localhost:8443/users' \ --header "Authorization: Bearer $bearer" \ --data "{ \"username\": \"$adminuser\", \"password\": \"$adminpass\", \"roles\": [\"ROLE_SUPER_ADMIN\"] }" + touch /opt/opengnsys/ogCore/installer/.deployed exit 0 diff --git a/component-installer/provision_oggui.sh b/non_graf_installer/component-installer/provision_oggui.sh similarity index 100% rename from component-installer/provision_oggui.sh rename to non_graf_installer/component-installer/provision_oggui.sh diff --git a/component-installer/provision_ogrepository.sh b/non_graf_installer/component-installer/provision_ogrepository.sh similarity index 84% rename from component-installer/provision_ogrepository.sh rename to non_graf_installer/component-installer/provision_ogrepository.sh index 64f9b25..6f94c2f 100644 --- a/component-installer/provision_ogrepository.sh +++ b/non_graf_installer/component-installer/provision_ogrepository.sh @@ -10,6 +10,7 @@ OGPASS=${4:-"og"} INSTALL_DIR=/opt/opengnsys/ogrepository DOWNLOAD_DIR=${5:-"/tmp/ogrepository"} DEBIAN_FRONTEND=noninteractive +OGUSER_HOME=/opt/opengnsys export DEBIAN_FRONTEND export GIT_SSL_NO_VERIFY @@ -34,12 +35,22 @@ install_updcast () { add_user_ogrepository() { if ! id "$OGUSER" &>/dev/null; then echo "User ogrepository does not exist, creating it" - useradd -r -s /bin/bash $OGUSER + useradd -m -d $OGUSER_HOME -r -s /bin/bash $OGUSER fi + if [ ! -d $OGUSER_HOME/.ssh ] ; then + mkdir -p $OGUSER_HOME/.ssh + cp /tmp/oginstall/ssh-keys/opengnsys $OGUSER_HOME/.ssh/id_ed25519 + cp /tmp/oginstall/ssh-keys/opengnsys.pub $OGUSER_HOME/.ssh/id_ed25519.pub + cat /tmp/oginstall/ssh-keys/opengnsys.pub >> $OGUSER_HOME/.ssh/authorized_keys + chown -R $OGUSER:$OGUSER $OGUSER_HOME/.ssh + chmod 0600 $OGUSER_HOME/.ssh/* + + fi if [ ! -f /etc/sudoers.d/$OGUSER ]; then echo "User $OGUSER does not have sudo permissions, adding it" echo "$OGUSER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/"$OGUSER" fi + } diff --git a/non_graf_installer/component-installer/ssh-keys/opengnsys b/non_graf_installer/component-installer/ssh-keys/opengnsys new file mode 100644 index 0000000..4514194 --- /dev/null +++ b/non_graf_installer/component-installer/ssh-keys/opengnsys @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACBs7Wbqztq5ixPGFL+1DlTa0T6QUBMiLq6KxZnCJ5rofQAAAJD7Xj89+14/ +PQAAAAtzc2gtZWQyNTUxOQAAACBs7Wbqztq5ixPGFL+1DlTa0T6QUBMiLq6KxZnCJ5rofQ +AAAEC4UmYDisgl5jNR6SUwRA80k6Qc06cBHg1mW3+2NU6SfmztZurO2rmLE8YUv7UOVNrR +PpBQEyIurorFmcInmuh9AAAABm5vbmFtZQECAwQFBgc= +-----END OPENSSH PRIVATE KEY----- diff --git a/non_graf_installer/component-installer/ssh-keys/opengnsys.pub b/non_graf_installer/component-installer/ssh-keys/opengnsys.pub new file mode 100644 index 0000000..7edd74c --- /dev/null +++ b/non_graf_installer/component-installer/ssh-keys/opengnsys.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGztZurO2rmLE8YUv7UOVNrRPpBQEyIurorFmcInmuh9 noname diff --git a/non_graf_installer/python-installer/get_release.py b/non_graf_installer/python-installer/get_release.py new file mode 100644 index 0000000..2a39b5b --- /dev/null +++ b/non_graf_installer/python-installer/get_release.py @@ -0,0 +1,54 @@ +import os +from git import Repo +from packaging.version import Version + +def get_highest_remote_tag(repo_path): + try: + # Abre el repositorio local + repo = Repo(repo_path) + + # Asegúrate de que el repositorio tiene un remoto + if not repo.remotes: + return None # No hay remotos configurados + + # Obtén el remoto por defecto (origin o el primero disponible) + remote = repo.remotes.origin + + # Recupera los tags remotos + remote.fetch(tags=True) + remote_tags = [ref.name.split('/')[-1] for ref in repo.references if ref.path.startswith('refs/tags/')] + if not remote_tags: + return None # No hay tags remotos + + # Ordena los tags remotos por versión + tags_sorted = sorted(remote_tags, key=lambda t: Version(t) if t.replace('.', '').isdigit() else Version('0.0.0'), reverse=True) + return tags_sorted[0] if tags_sorted else None + + except Exception as e: + print(f"Error al procesar el repositorio {repo_path}: {e}") + return None + +def process_selected_repositories(base_path, repo_names): + repo_highest_tags = {} + for repo_name in repo_names: + repo_path = os.path.join(base_path, repo_name) + if os.path.exists(repo_path) and os.path.isdir(os.path.join(repo_path, '.git')): + highest_tag = get_highest_remote_tag(repo_path) + repo_highest_tags[repo_name] = highest_tag + else: + repo_highest_tags[repo_name] = "No es un repositorio Git válido" + return repo_highest_tags + +# Ruta base donde están los repositorios locales +base_path = "../" + +# Lista de nombres de repositorios específicos +repo_names = [ "ogcore" , "oggui" , "ogboot" , "ogdhcp" , "ogrepository" ] + +result = process_selected_repositories(base_path, repo_names) + +# Muestra los resultados +for repo_name, tag in result.items(): + print(f'{repo_name}:{tag}') + + diff --git a/python-installer/oginstaller-v2.py b/non_graf_installer/python-installer/oginstaller-v2.py similarity index 100% rename from python-installer/oginstaller-v2.py rename to non_graf_installer/python-installer/oginstaller-v2.py diff --git a/python-installer/oginstaller.py b/non_graf_installer/python-installer/oginstaller.py similarity index 100% rename from python-installer/oginstaller.py rename to non_graf_installer/python-installer/oginstaller.py diff --git a/python-installer/oginstaller.sh b/non_graf_installer/python-installer/oginstaller.sh similarity index 100% rename from python-installer/oginstaller.sh rename to non_graf_installer/python-installer/oginstaller.sh diff --git a/python-installer/opengnsys_installer.sh b/non_graf_installer/python-installer/opengnsys_installer.sh similarity index 88% rename from python-installer/opengnsys_installer.sh rename to non_graf_installer/python-installer/opengnsys_installer.sh index c228988..b38aa94 100755 --- a/python-installer/opengnsys_installer.sh +++ b/non_graf_installer/python-installer/opengnsys_installer.sh @@ -37,8 +37,8 @@ download_installer() { extract_installer() { rm -rf /tmp/oginstall mkdir -p /tmp/oginstall - cp -r /tmp/oginstaller-$BRANCH/python-installer/* /tmp/oginstall/ - cp -r /tmp/oginstaller-$BRANCH/component-installer/* /tmp/oginstall/ + cp -r /tmp/oginstaller-$BRANCH/non_graf_installer/python-installer/* /tmp/oginstall/ + cp -r /tmp/oginstaller-$BRANCH/non_graf_installer/component-installer/* /tmp/oginstall/ chmod 755 /tmp/oginstall/*.sh chmod 755 /tmp/oginstall/*.py } diff --git a/python-installer/requirements.txt b/non_graf_installer/python-installer/requirements.txt similarity index 100% rename from python-installer/requirements.txt rename to non_graf_installer/python-installer/requirements.txt diff --git a/non_graf_installer/python-installer/update_opengsys.sh b/non_graf_installer/python-installer/update_opengsys.sh new file mode 100644 index 0000000..ab9d632 --- /dev/null +++ b/non_graf_installer/python-installer/update_opengsys.sh @@ -0,0 +1,214 @@ +#!/bin/bash + +# Detect installed components. + + +INSTALLER_BRANCH=${INSTALLER_BRANCH:-main} +OPENGNSYS_BASE=/opt/opengnsys +OPENGNSYS_COMPONENTS=(ogCore ogGui ogDhcp ogBoot ogRepository) +GIT_SSL_NO_VERIFY=1 +INSTALLED_COMPONENTS=() + +GIT_REPO="https://ognproject.evlt.uma.es/gitea/api/v1/repos/opengnsys/oginstaller/archive/$INSTALLER_BRANCH.zip" + +export GIT_SSL_NO_VERIFY +INSTALLED_COMPONENTS=() + +check_os(){ + if [ -f /etc/os-release ]; then + . /etc/os-release + # Just support Ubuntu 24.04 for now + if [ $ID == "ubuntu" ] && [ $VERSION_ID == "24.04" ]; then + echo "OS supported." + else + echo "OS not supported." + exit 1 + fi + else + echo "OS not supported." + exit 1 + fi +} + +detect_installed_components() { + local OGNODE=0 + for component in "${OPENGNSYS_COMPONENTS[@]}"; do + if [ -f "${OPENGNSYS_BASE}/${component}/installer/config.json" ]; then + echo "Component $component is installed." + INSTALLED_COMPONENTS+=($component) + OGNODE=1 + else + echo "Component $component is not installed." + fi + done + if [ $OGNODE -eq 0 ]; then + echo "No OpenGnsys components installed." + else + echo "Installed components:" "${INSTALLED_COMPONENTS[@]}" + fi +} + + +# Assume taht all components are at the same release version, get the first installed compoenent and return its version +get_og_installed_version() { + local component=$1 + local version=$(jq -r '.release' ${OPENGNSYS_BASE}/${component}/installer/config.json) + echo $version +} + +start_stop_component() { + local component=$1 + local action=$2 + case $component in + ogCore) + handle_ogcore $action + ;; + ogGui) + handle_oggui $action + ;; + ogDhcp) + handle_ogdhcp $action + ;; + ogBoot) + handle_ogboot $action + ;; + ogRepository) + handle_ogrepository $action + ;; + *) + echo "Component $component not found." + ;; + esac +} + + +stop_installed_services() { + echo "Stopping services..." + for component in "${INSTALLED_COMPONENTS[@]}"; do + echo "Stopping component $component..." + start_stop_component $component stop + done +} + +start_installed_services() { + echo "Starting services..." + for component in "${INSTALLED_COMPONENTS[@]}"; do + echo "Starting component $component..." + start_stop_component $component start + done +} + +handle_ogboot() { + case $1 in + stop) + echo "Stopping ogBoot..." + systemctl stop nginx + systemctl stop tftpd-hpa + systemctl stop smbd + systemctl stop nmbd + ;; + start) + echo "Starting ogBoot..." + systemctl start nginx + systemctl start tftpd-hpa + systemctl start smbd + systemctl start nmbd + ;; + *) + echo "Invalid action." + ;; + esac +} + +handle_ogdhcp() { + case $1 in + stop) + echo "Stopping ogDhcp..." + systemctl stop kea-dhcp4-server + systemctl stop kea-ctrl-agent + ;; + start) + echo "Starting ogDhcp..." + systemctl start kea-dhcp4-server + systemctl start kea-ctrl-agent + ;; + *) + echo "Invalid action." + ;; + esac +} + +handle_ogrepository() { + case $1 in + stop) + echo "Stopping ogRepository..." + systemctl stop smbd + systemctl stop nmbd + systemctl stop ogrepo-api + ;; + start) + echo "Starting ogRepository..." + systemctl start smbd + systemctl start nmbd + systemctl start ogrepo-api + ;; + *) + echo "Invalid action." + ;; + esac +} + +handle_ogcore() { + case $1 in + stop) + echo "Stopping ogCore..." + systemctl stop ogcore + ;; + start) + echo "Starting ogCore..." + systemctl start ogcore + ;; + *) + echo "Invalid action." + ;; + esac +} + +handle_oggui() { + case $1 in + stop) + echo "Stopping ogGui..." + systemctl stop oggui-app + ;; + start) + echo "Starting ogGui..." + systemctl start oggui-app + ;; + *) + echo "Invalid action." + ;; + esac +} + + +update_installed_components() { + local version=$1 + echo "Updating components to version $version..." + for component in "${INSTALLED_COMPONENTS[@]}"; do + echo "Updating component $component..." + update_component $component $version + done +} + + +#### Main + +check_os +detect_installed_components +installed_version=$(get_og_installed_version "${INSTALLED_COMPONENTS[0]}") +select_version_to_update +stop_installed_services +update_installed_components $installed_version +start_installed_services + + diff --git a/openGnsys-installer.sh b/openGnsys-installer.sh deleted file mode 100644 index 16a9893..0000000 --- a/openGnsys-installer.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash - - -CONFIGS_DIR=/tmp/opengnsys-installer-configs -rm -rf $CONFIGS_DIR -mkdir -p $CONFIGS_DIR - -# Paso 1: Seleccionar los componentes -components=$(yad --list --title="Seleccionar componentes" \ - --text="Selecciona los componentes que deseas configurar:" \ - --checklist --multiple \ - --column="Seleccionar" --column="Componente" \ - FALSE "ogCore" \ - FALSE "ogGui" \ - FALSE "ogDhcp" \ - FALSE "ogBoot" \ - --width=400 --height=300 --center) - -# Verificar si el usuario seleccionó algún componente -if [[ -z "$components" ]]; then - yad --info --text="No seleccionaste ningún componente. Saliendo..." --center - exit 1 -fi - -for component in $components; do - selected_component=$(echo "$component" | cut -d '|' -f 2) - # Pedir la configuración específica para cada componente seleccionado - - - # Dividir la configuración en IP y ruta del fichero - config_file="config_${selected_component}.json" - case $selected_component in - "ogCore") - config=$(yad --form --title="Configuración para $selected_component" \ - --field="Usuario administrador":TEXT \ - --field="Contraseña":H \ - --field="Tag del contenedor":TEXT \ - "ogadmin" "" "latest" \ - --width=400 --height=200 --center) - user=$(echo "$config" | cut -d '|' -f 1) - password=$(echo "$config" | cut -d '|' -f 2) - container_tag=$(echo "$config" | cut -d '|' -f 3) - echo "{\"username\": \"$user\", \"password\": \"$password\", \"container_version\": \"$container_tag\" }" > $CONFIGS_DIR/"$config_file" - ;; - "ogGui") - config=$(yad --form --title="Configuración para $selected_component" \ - --field="IP del servidor de ogCore" \ - --field="Tag del contenedor":TEXT \ - --width=400 --height=200 --center) - ogcore_ip=$(echo "$config" | cut -d '|' -f 1) - container_version=$(echo "$config" | cut -d '|' -f 2) - echo "{\"ogcore_ip\": \"$ogcore_ip\" , \"container_version\": \"$container_version\" }" > $CONFIGS_DIR/"$config_file" - ;; - "ogDhcp") - config=$(yad --form --title="Configuración para $selected_component" \ - --field="Configuración IP servidor de Boot" \ - --field="Interfaces Boot" \ - --width=400 --height=200 --center) - ogbootIP=$(echo "$config" | cut -d '|' -f 1) - interfaces=$(echo "$config" | cut -d '|' -f 2) - json_array_interfaces=$(echo "$interfaces" | jq -R 'split(",")') - echo "{\"ogbootIP\": \"$ogbootIP\", \"interfaces\": \"$json_array_interfaces\"}" > $CONFIGS_DIR/"$config_file" - ;; - "ogBoot") - config=$(yad --form --title="Configuración para $selected_component" \ - --field="ogCore Ip Server" \ - --field="ogCore Server" \ - --field="ogCore Dir" \ - --field="ogBoot GitRepo" \ - --field="ogBoot Samba User" \ - --field="ogBoot Samba Pass" \ - --width=400 --height=200 --center) - ogcore_ip=$(echo "$config" | cut -d '|' -f 1) - ogcore_server=$(echo "$config" | cut -d '|' -f 2) - ogcore_dir=$(echo "$config" | cut -d '|' -f 3) - ogboot_gitrepo=$(echo "$config" | cut -d '|' -f 4) - ogboot_samba_user=$(echo "$config" | cut -d '|' -f 5) - ogboot_samba_pass=$(echo "$config" | cut -d '|' -f 6) - echo "{\"ogcore_ip\": \"$ogcore_ip\", \"ogcore_server\": \"$ogcore_server\", \"ogcore_dir\": \"$ogcore_dir\", \"ogboot_gitrepo\": \"$ogboot_gitrepo\", \"ogboot_samba_user\": \"$ogboot_samba_user\", \"ogboot_samba_pass\": \"$ogboot_samba_pass\"}" > $CONFIGS_DIR/"$config_file" - ;; - esac - - # Verificar si los campos no están vacíos - # if [[ -z "$server_ip" || -z "$config_path" ]]; then - # yad --error --text="Debes proporcionar la IP del servidor y la ruta del fichero para $selected_component." --center - # exit 1 - # fi - - # Guardar la configuración en un archivo (cada componente tiene su archivo JSON) - config_file="./${selected_component}_config.json" - echo "{\"server_ip\": \"$server_ip\", \"config_path\": \"$config_path\"}" > "$config_file" - - # Mostrar un mensaje de éxito - yad --info --text="Configuración guardada en $config_file para $selected_component." --center - -done - - -# # Una vez se ha configurado todo, se puede proceder a la instalación de los componentes -# # Ejecutar la instalación con calamares y enviar el log a un archivo - -# #calamares > installer.log 2>&1 & disown -sudo calamares > installer.log 2>&1