diff options
| -rwxr-xr-x | containers/podman_launch_devenv.py | 53 | ||||
| -rwxr-xr-x | setup/core/install-packages.sh | 2 | ||||
| -rwxr-xr-x | setup/port-forward/ssh-port-forward.sh | 2 |
3 files changed, 2 insertions, 55 deletions
diff --git a/containers/podman_launch_devenv.py b/containers/podman_launch_devenv.py deleted file mode 100755 index 3d0b5b0..0000000 --- a/containers/podman_launch_devenv.py +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | """ | ||
| 3 | Rocky SSH Container Launcher | ||
| 4 | |||
| 5 | Manual build command: | ||
| 6 | podman build -f docker_build/Dockerfile -t rocky_dev:latest . | ||
| 7 | |||
| 8 | Usage: | ||
| 9 | python3 podman_launch_devenv.py # Build and launch container | ||
| 10 | python3 podman_launch_devenv.py --list # List running rocky-dev containers | ||
| 11 | python3 podman_launch_devenv.py --cleanup # Stop and remove all containers | ||
| 12 | """ | ||
| 13 | import subprocess, argparse, os, glob | ||
| 14 | |||
| 15 | def run(cmd): return subprocess.run(cmd, shell=True, capture_output=True, text=True) | ||
| 16 | |||
| 17 | def build(): | ||
| 18 | if not glob.glob("docker_build/ssh-keys/*.pub"): os.makedirs("docker_build/ssh-keys", exist_ok=True); open("docker_build/ssh-keys/dummy.pub", "w").write("# dummy") | ||
| 19 | result = run("podman build -f docker_build/Dockerfile -t rocky_dev:latest .") | ||
| 20 | if os.path.exists("docker_build/ssh-keys/dummy.pub"): os.remove("docker_build/ssh-keys/dummy.pub") | ||
| 21 | return result.returncode == 0 | ||
| 22 | |||
| 23 | def launch(): | ||
| 24 | port = str(args.port) if args.port else run("shuf -i 10000-65000 -n 1").stdout.strip() | ||
| 25 | result = run(f"podman run -d -p {port}:22 --privileged --name rocky_dev-{port} rocky_dev:latest") | ||
| 26 | if result.returncode == 0: | ||
| 27 | ip = run("hostname -I | awk '{print $1}'").stdout.strip() or "localhost" | ||
| 28 | print(f"🐳 SSH: ssh root@{ip} -p {port}") | ||
| 29 | print(f"🐚 Shell: podman exec -it rocky_dev-{port} /bin/bash") | ||
| 30 | print(f"💡 Tip: For direct shell without port forwarding, use: podman run -it rocky_dev:latest /bin/bash") | ||
| 31 | return result.returncode == 0 | ||
| 32 | |||
| 33 | parser = argparse.ArgumentParser(epilog=""" | ||
| 34 | Manual build commands: | ||
| 35 | Build: podman build -f docker_build/Dockerfile -t rocky_dev:latest . | ||
| 36 | Rebuild: podman rmi rocky_dev:latest && podman build -f docker_build/Dockerfile -t rocky_dev:latest . | ||
| 37 | """, formatter_class=argparse.RawDescriptionHelpFormatter) | ||
| 38 | parser.add_argument("command", nargs="?", choices=["run", "list", "cleanup"], help="Command to execute") | ||
| 39 | parser.add_argument("-p", "--port", type=int) | ||
| 40 | args = parser.parse_args() | ||
| 41 | |||
| 42 | if args.command == "list": print(run("podman ps --filter name=rocky_dev").stdout or "No containers") | ||
| 43 | elif args.command == "cleanup": [run(f"podman stop {c} && podman rm {c}") for c in run("podman ps -a --filter name=rocky_dev --format '{{.Names}}'").stdout.split()] | ||
| 44 | elif args.command == "run": | ||
| 45 | if run("podman images -q rocky_dev").stdout: | ||
| 46 | print("found rocky_dev container! starting with a random public port to ssh... ") | ||
| 47 | launch() | ||
| 48 | else: | ||
| 49 | print("❌ Image rocky_dev:latest not found") | ||
| 50 | else: | ||
| 51 | print("Usage: python3 podman_launch_devenv.py {run|list|cleanup} [-p PORT]") | ||
| 52 | print("🐚 Shell: podman exec -it rocky_dev-<port> /bin/bash") | ||
| 53 | print("💡 Tip: For direct shell without port forwarding, use: podman run -it rocky_dev:latest /bin/bash") | ||
diff --git a/setup/core/install-packages.sh b/setup/core/install-packages.sh index dd3e69d..fb0a75d 100755 --- a/setup/core/install-packages.sh +++ b/setup/core/install-packages.sh | |||
| @@ -6,7 +6,7 @@ sudo dnf install -y epel-release | |||
| 6 | sudo dnf install -y nc openssl bat autossh tmux htop tar bmon gzip tree wget curl plocate nano vim unzip net-tools git python3 python3-pip make wireguard-tools usbutils yum | 6 | sudo dnf install -y nc openssl bat autossh tmux htop tar bmon gzip tree wget curl plocate nano vim unzip net-tools git python3 python3-pip make wireguard-tools usbutils yum |
| 7 | sudo dnf install -y xclip | 7 | sudo dnf install -y xclip |
| 8 | 8 | ||
| 9 | sudo dnf install -y gcc gcc-c++ | 9 | sudo dnf install -y gcc gcc-c++ openssl-devel |
| 10 | sudo dnf install -y java-latest-openjdk-devel | 10 | sudo dnf install -y java-latest-openjdk-devel |
| 11 | #sudo dnf install -y asio-devel boost-devel openssl-devel | 11 | #sudo dnf install -y asio-devel boost-devel openssl-devel |
| 12 | 12 | ||
diff --git a/setup/port-forward/ssh-port-forward.sh b/setup/port-forward/ssh-port-forward.sh index 4483ef4..c4cb0a8 100755 --- a/setup/port-forward/ssh-port-forward.sh +++ b/setup/port-forward/ssh-port-forward.sh | |||
| @@ -13,7 +13,7 @@ echo "cleaning attempted." | |||
| 13 | 13 | ||
| 14 | ssh $HOST $(for i in $(seq ${j}000 ${j}005); do echo "-R $i:localhost:$i"; done; echo "-R ${j}022:localhost:22") | 14 | ssh $HOST $(for i in $(seq ${j}000 ${j}005); do echo "-R $i:localhost:$i"; done; echo "-R ${j}022:localhost:22") |
| 15 | 15 | ||
| 16 | echo "port forward is available on port {j}00x" | 16 | echo "port forward is available on ports ${j}000-${j}005, ssh on ${j}022" |
| 17 | 17 | ||
| 18 | #ideally port forward from 2 onwards, there seems to be a problem for 1000(or just change all to j001) | 18 | #ideally port forward from 2 onwards, there seems to be a problem for 1000(or just change all to j001) |
| 19 | #jupyter lab --port=2001 --ip=0.0.0.0 | 19 | #jupyter lab --port=2001 --ip=0.0.0.0 |
