From f3e46227d8c71b8fa0599eb8b9916bb4833bac63 Mon Sep 17 00:00:00 2001 From: Federico Torres Date: Sat, 1 Mar 2025 16:56:21 -0300 Subject: [PATCH 1/7] fix: check if remote-install.sh is being run as root --- scripts/remote-install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/remote-install.sh b/scripts/remote-install.sh index cdc8b3de..67664789 100644 --- a/scripts/remote-install.sh +++ b/scripts/remote-install.sh @@ -38,6 +38,13 @@ function log { } lsb_release -d | grep "LTS" > /dev/null + +if [ "$EUID" -ne 0 ] +then + echo "This script must be run as root" + exit 1 +fi + if [ $? != 0 ] then echo "This script can only be run on a Linux Ubuntu LTS release" From f722816849fbb3b2c85b327aa2c2f9ce11d341e9 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 2 Mar 2025 22:27:53 +0700 Subject: [PATCH 2/7] Improvements for remote-install.sh * Use apt-add-repository to install repository * Add option to not upgrade the system * Check if Python version is >= 3.9 when installing from ppa-v3 repository --- scripts/remote-install.sh | 77 ++++++++++++--------------------------- 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/scripts/remote-install.sh b/scripts/remote-install.sh index 67664789..c63fcd0b 100644 --- a/scripts/remote-install.sh +++ b/scripts/remote-install.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2024 GNS3 Technologies Inc. +# Copyright (C) 2025 GNS3 Technologies Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ function help { echo "--with-i386-repository: Add the i386 repositories required by IOU i386 images. This is not needed for recent x86_64 IOU images." >&2 echo "--with-welcome: Install GNS3-VM welcome.py script" >&2 echo "--without-kvm: Disable KVM, required if system do not support it (limitation in some hypervisors and cloud providers). Warning: only disable KVM if strictly necessary as this will degrade performance" >&2 + echo "--without-system-upgrade: Do not upgrade the system" >&2 echo "--unstable: Use the GNS3 unstable repository" >&2 echo "--custom-repository : Use a custom repository" >&2 echo "--help: This help" >&2 @@ -59,6 +60,7 @@ USE_VPN=0 USE_IOU=0 I386_REPO=0 DISABLE_KVM=0 +NO_SYSTEM_UPGRADE=0 WELCOME_SETUP=0 TEMP=`getopt -o h --long with-openvpn,with-iou,with-i386-repository,with-welcome,without-kvm,unstable,custom-repository:,help -n 'gns3-remote-install.sh' -- "$@"` @@ -92,6 +94,10 @@ while true ; do DISABLE_KVM=1 shift ;; + --without-system-upgrade) + NO_SYSTEM_UPGRADE=1 + shift + ;; --unstable) REPOSITORY="unstable" shift @@ -109,68 +115,33 @@ while true ; do esac done +if [ "$REPOSITORY" == "ppa-v3" ] +then + if ! python3 -c 'import sys; assert sys.version_info >= (3,9)' > /dev/null 2>&1; then + echo "GNS3 version >= 3.0 requires Python 3.9 or later" + exit 1 + fi +fi + # Exit in case of error set -e export DEBIAN_FRONTEND="noninteractive" UBUNTU_CODENAME=`lsb_release -c -s` -log "Add GNS3 repository" +log "Updating system packages, installing curl and software-properties-common" +apt update +apt install -y curl software-properties-common -if [ ! -f "/etc/apt/sources.list.d/ubuntu.sources" ] +if [ $NO_SYSTEM_UPGRADE == 0 ] then - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B83AAABFFBD82D21B543C8EA86C22C2EC6A24D7F - cat < /etc/apt/sources.list.d/gns3.list -deb http://ppa.launchpad.net/gns3/ppa/ubuntu $UBUNTU_CODENAME main -deb-src http://ppa.launchpad.net/gns3/ppa/ubuntu $UBUNTU_CODENAME main -EOFLIST - -else - - cat < /etc/apt/sources.list.d/gns3-ppa.sources -Types: deb -URIs: https://ppa.launchpadcontent.net/gns3/$REPOSITORY/ubuntu/ -Suites: $UBUNTU_CODENAME -Components: main -Signed-By: - -----BEGIN PGP PUBLIC KEY BLOCK----- - . - mQINBGY0jSYBEADMH5CvX8ZVX4XzAxdQ2CmF7t86IjFnQgtI18Q19nVnpKEGNyB5 - pgotDMzkhGnxuhvz2zE9PZhd8VgkodB81V607d/Dy8FfI7t1BVQhLvJDx0H/q6RE - n2y9WxiuBzT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/AkOmouYiF+qaYDFGZDfWhK - p1HFmd1kt7YdgxsmoKoFJkbt1bBdcFJLV0Jcad5sfArg2aFDYf2giMxAw4iQ+9jc - MCuwWxiqWicPqJ5erNTzVfayBkjuZqBDVTO9wmG3DL4QmNosIBS7kq+NGrT8Ql22 - FqYfdIZJDlKVtJKHK8eKJSB0dbFawV2h5p/CvQlIm6nthg5FzOyjvCkPkvxvveq+ - SuNxFEscumFCgo7j7RMWHW9HWK3TUvMmYLMVjxL8kXyCwknp9GklBQHA/IPxRa/2 - eFqqkmVbmNAoMzzw5wqa/BPcFEbgn+E+TFyZqbzp0F4QzPJZFkz16SA= - =xnj5 - -----END PGP PUBLIC KEY BLOCK----- -EOFLIST - + log "Upgrading system packages" + apt upgrade --yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" fi -log "Updating system packages and installing curl" -apt update -apt install -y curl - -log "Upgrading packages" -apt upgrade --yes --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" +log "Adding GNS3 repository ppa:gns3/$REPOSITORY" +# use sudo -E to preserve proxy config +sudo -E apt-add-repository -y "ppa:gns3/$REPOSITORY" log "Installing the GNS3 server and its dependencies" apt install -y gns3-server From 2ecd2cfe3b5ec7cf2103ae83a344a987802bd101 Mon Sep 17 00:00:00 2001 From: NAKNAO-nnct Date: Sat, 8 Mar 2025 13:59:05 +0900 Subject: [PATCH 3/7] update Ubuntu24.04 --- Dockerfile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 455d4dfd..ddf177cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,27 @@ # Dockerfile for GNS3 server development -FROM ubuntu:18.04 +FROM ubuntu:24.04 -ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_FRONTEND=noninteractive # Set the locale -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US:en +ENV LC_ALL=en_US.UTF-8 + +# this environment is externally managed +ENV PIP_BREAK_SYSTEM_PACKAGES=1 RUN apt-get update && apt-get install -y software-properties-common RUN add-apt-repository ppa:gns3/ppa RUN apt-get update && apt-get install -y \ locales \ python3-pip \ - python3-dev \ + python3-dev \ qemu-system-x86 \ qemu-kvm \ - libvirt-bin \ - x11vnc + libvirt-daemon-system libvirt-clients \ + x11vnc RUN locale-gen en_US.UTF-8 @@ -32,4 +35,4 @@ RUN pip3 install --no-cache-dir -r /server/requirements.txt EXPOSE 3080 -CMD python3 -m gns3server +CMD [ "python3", "-m", "gns3server", "--port", "3080"] From 21ebb934f44b4c385662da12ca03d0513a8d5826 Mon Sep 17 00:00:00 2001 From: NAKNAO-nnct Date: Sat, 8 Mar 2025 14:08:42 +0900 Subject: [PATCH 4/7] add compose.yaml --- compose.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 compose.yaml diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..cb0343af --- /dev/null +++ b/compose.yaml @@ -0,0 +1,7 @@ +services: + gen3-server: + build: + context: . + dockerfile: Dockerfile + ports: + - "8001:3080" From 00bf1c028be9b2337137fb30d5ad03ad4d774e38 Mon Sep 17 00:00:00 2001 From: NAKNAO-nnct Date: Sat, 8 Mar 2025 14:11:42 +0900 Subject: [PATCH 5/7] Update README to Run Docker Compose --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 059a1238..d61e4298 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,12 @@ For development, you can run the GNS3 server in a container bash scripts/docker_dev_server.sh ``` +#### use Docker Compose + +``` {.bash} +docker compose up -d +``` + ### Run as daemon (Unix only) You will find init sample scripts for various systems inside the init From e262a46cfd53a5408368865f275726aabf71f6e8 Mon Sep 17 00:00:00 2001 From: NAKNAO-nnct Date: Sat, 8 Mar 2025 20:19:37 +0900 Subject: [PATCH 6/7] rm space --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ddf177cb..b4379e7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,4 +35,4 @@ RUN pip3 install --no-cache-dir -r /server/requirements.txt EXPOSE 3080 -CMD [ "python3", "-m", "gns3server", "--port", "3080"] +CMD ["python3", "-m", "gns3server", "--port", "3080"] From 018598a30007ea38dfe8bd35271ac5468753d8e6 Mon Sep 17 00:00:00 2001 From: NAKNAO-nnct Date: Sat, 8 Mar 2025 20:22:06 +0900 Subject: [PATCH 7/7] refactor --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b4379e7b..afef0689 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,4 +35,4 @@ RUN pip3 install --no-cache-dir -r /server/requirements.txt EXPOSE 3080 -CMD ["python3", "-m", "gns3server", "--port", "3080"] +CMD [ "python3", "-m", "gns3server", "--port", "3080" ]