diff options
24 files changed, 249 insertions, 1 deletions
diff --git a/.claude/settings.local.json b/.claude/settings.local.json index eb8ba96..0031e6f 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json | |||
| @@ -2,7 +2,9 @@ | |||
| 2 | "permissions": { | 2 | "permissions": { |
| 3 | "allow": [ | 3 | "allow": [ |
| 4 | "Bash(rm:*)", | 4 | "Bash(rm:*)", |
| 5 | "Bash(chmod:*)" | 5 | "Bash(chmod:*)", |
| 6 | "Bash(mkdir:*)", | ||
| 7 | "Bash(mv:*)" | ||
| 6 | ], | 8 | ], |
| 7 | "deny": [] | 9 | "deny": [] |
| 8 | }, | 10 | }, |
diff --git a/docker_build/Dockerfile b/containers/docker_build/Dockerfile index 16f74d6..16f74d6 100644 --- a/docker_build/Dockerfile +++ b/containers/docker_build/Dockerfile | |||
diff --git a/docker_build/Dockerfile.gpu b/containers/docker_build/Dockerfile.gpu index 7ed08a5..7ed08a5 100644 --- a/docker_build/Dockerfile.gpu +++ b/containers/docker_build/Dockerfile.gpu | |||
diff --git a/docker_build/ssh-keys/macm4-resident.pub b/containers/docker_build/ssh-keys/macm4-resident.pub index fbccb4f..fbccb4f 100644 --- a/docker_build/ssh-keys/macm4-resident.pub +++ b/containers/docker_build/ssh-keys/macm4-resident.pub | |||
diff --git a/docker_build/vimrc b/containers/docker_build/vimrc index 36583bc..36583bc 100644 --- a/docker_build/vimrc +++ b/containers/docker_build/vimrc | |||
diff --git a/podman_launch_devenv.py b/containers/podman_launch_devenv.py index 3d0b5b0..3d0b5b0 100755 --- a/podman_launch_devenv.py +++ b/containers/podman_launch_devenv.py | |||
diff --git a/rocky-ssh-deployment.yaml b/containers/rocky-ssh-deployment.yaml index bb6c37f..bb6c37f 100644 --- a/rocky-ssh-deployment.yaml +++ b/containers/rocky-ssh-deployment.yaml | |||
diff --git a/rocky-ssh-gpu-deployment.yaml b/containers/rocky-ssh-gpu-deployment.yaml index 062ccae..062ccae 100644 --- a/rocky-ssh-gpu-deployment.yaml +++ b/containers/rocky-ssh-gpu-deployment.yaml | |||
diff --git a/tests/test_base_container.sh b/containers/tests/test_base_container.sh index b5115ec..b5115ec 100755 --- a/tests/test_base_container.sh +++ b/containers/tests/test_base_container.sh | |||
diff --git a/tests/test_gpu_container.sh b/containers/tests/test_gpu_container.sh index 593f927..593f927 100755 --- a/tests/test_gpu_container.sh +++ b/containers/tests/test_gpu_container.sh | |||
diff --git a/setup/core/install-packages.sh b/setup/core/install-packages.sh new file mode 100755 index 0000000..dd3e69d --- /dev/null +++ b/setup/core/install-packages.sh | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # Install core packages | ||
| 4 | sudo dnf install -y epel-release | ||
| 5 | #sudo dnf group install -y "Development Tools" | ||
| 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 | ||
| 8 | |||
| 9 | sudo dnf install -y gcc gcc-c++ | ||
| 10 | sudo dnf install -y java-latest-openjdk-devel | ||
| 11 | #sudo dnf install -y asio-devel boost-devel openssl-devel | ||
| 12 | |||
| 13 | # Execute all package installation scripts | ||
| 14 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| 15 | for script in "$SCRIPT_DIR/packages"/*.sh; do | ||
| 16 | if [ -f "$script" ]; then | ||
| 17 | "$script" | ||
| 18 | fi | ||
| 19 | done | ||
| 20 | |||
| 21 | #install packages ml | ||
| 22 | #pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 | ||
| 23 | #pip3 install transformers | ||
| 24 | |||
| 25 | #sudo yum install -y python3-openstackclient s3fs-fuse awscli | ||
| 26 | #pip install jupyterlab python-swiftclient | ||
| 27 | #sudo dnf update -y | ||
diff --git a/setup/core/packages/install_claude.sh b/setup/core/packages/install_claude.sh new file mode 100755 index 0000000..bf47cd2 --- /dev/null +++ b/setup/core/packages/install_claude.sh | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # Install Node.js via nvm and Claude Code | ||
| 4 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash | ||
| 5 | export NVM_DIR="$HOME/.nvm" | ||
| 6 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
| 7 | nvm install 22 | ||
| 8 | npm install -g @anthropic-ai/claude-code \ No newline at end of file | ||
diff --git a/setup/core/packages/install_rust.sh b/setup/core/packages/install_rust.sh new file mode 100755 index 0000000..ec484a4 --- /dev/null +++ b/setup/core/packages/install_rust.sh | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # Install Rust and Cargo tools | ||
| 4 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
| 5 | echo '[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"' >> ~/.bashrc | ||
| 6 | source "$HOME/.cargo/env" | ||
| 7 | cargo install cargo-clone-crate cargo-edit cargo-info evcxr_jupyter bacon du-dust \ No newline at end of file | ||
diff --git a/setup/core/ssh.sh b/setup/core/ssh.sh new file mode 100755 index 0000000..c8fb49d --- /dev/null +++ b/setup/core/ssh.sh | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config | ||
| 4 | echo "AllowTcpForwarding yes" | sudo tee -a /etc/ssh/sshd_config | ||
| 5 | echo "GatewayPorts yes" | sudo tee -a /etc/ssh/sshd_config | ||
| 6 | echo "AllowAgentForwarding yes" | sudo tee -a /etc/ssh/sshd_config | ||
| 7 | |||
| 8 | git clone https://git.noml.ch/keys ~/keys | ||
| 9 | ~/keys/add-ssh-keys.sh | ||
diff --git a/setup/core/vim.sh b/setup/core/vim.sh new file mode 100755 index 0000000..883a75e --- /dev/null +++ b/setup/core/vim.sh | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | cd "$(dirname "${BASH_SOURCE[0]}")" || exit | ||
| 4 | |||
| 5 | cat << EOF >> /etc/vimrc | ||
| 6 | augroup netcat_clipboard | ||
| 7 | au! | ||
| 8 | au TextYankPost * call system("openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023", @") | ||
| 9 | augroup END | ||
| 10 | |||
| 11 | " Enable line wrapping | ||
| 12 | set wrap | ||
| 13 | |||
| 14 | " Optional: Make wrapped lines easier to read by indenting them | ||
| 15 | set breakindent | ||
| 16 | set breakindentopt=shift:1 | ||
| 17 | |||
| 18 | syntax on | ||
| 19 | set mouse=a | ||
| 20 | set expandtab | ||
| 21 | set shiftwidth=4 | ||
| 22 | set softtabstop=4 | ||
| 23 | set tabstop=4 | ||
| 24 | set noautoindent | ||
| 25 | set nosmartindent | ||
| 26 | filetype plugin indent on | ||
| 27 | |||
| 28 | set laststatus=2 " permanent status bar | ||
| 29 | set statusline=%F " shows full file path | ||
| 30 | |||
| 31 | if (has("termguicolors")) | ||
| 32 | set termguicolors | ||
| 33 | endif | ||
| 34 | |||
| 35 | "colorscheme murphy | ||
| 36 | colorscheme zellner | ||
| 37 | |||
| 38 | " Ctrl+A: Move to the beginning of the line in INSERT mode | ||
| 39 | inoremap <C-a> <Home> | ||
| 40 | |||
| 41 | " Ctrl+E: Move to the end of the line in INSERT mode | ||
| 42 | inoremap <C-e> <End> | ||
| 43 | |||
| 44 | " Ctrl+A: Move to the beginning of the line in NORMAL mode | ||
| 45 | nnoremap <C-a> 0 | ||
| 46 | |||
| 47 | " Ctrl+E: Move to the end of the line in NORMAL mode | ||
| 48 | nnoremap <C-e> $ | ||
| 49 | |||
| 50 | set number | ||
| 51 | setlocal regexpengine=2 | ||
| 52 | set paste | ||
| 53 | set foldcolumn=12 | ||
| 54 | |||
| 55 | |||
| 56 | EOF | ||
| 57 | |||
| 58 | |||
| 59 | |||
diff --git a/setup/git/set-global_user.sh b/setup/git/set-global_user.sh new file mode 100755 index 0000000..30e11eb --- /dev/null +++ b/setup/git/set-global_user.sh | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | git config --global user.email "hc@email.ch" | ||
| 2 | git config --global user.name "hc" | ||
diff --git a/setup/git/tools/git-ssh-wrapper.sh b/setup/git/tools/git-ssh-wrapper.sh new file mode 100755 index 0000000..dc23334 --- /dev/null +++ b/setup/git/tools/git-ssh-wrapper.sh | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | ssh -v -A -o ForwardAgent=yes "$@" | ||
diff --git a/setup/git/tools/usefulbutnotthatusefulidkwhattodo b/setup/git/tools/usefulbutnotthatusefulidkwhattodo new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/setup/git/tools/usefulbutnotthatusefulidkwhattodo | |||
diff --git a/setup/port-forward/persistent-ssh.sh b/setup/port-forward/persistent-ssh.sh new file mode 100755 index 0000000..36d14dd --- /dev/null +++ b/setup/port-forward/persistent-ssh.sh | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | echo "selinux command is untested. copy paste systemd file if you want" | ||
| 4 | echo "reboot afterwards(selinux unset, need reboot to take effect, or just do sudo setenforce 0 for temp unset)" | ||
| 5 | echo "make sure /root/m exists" | ||
| 6 | echo "remember to change the remote port or host if needed" | ||
| 7 | |||
| 8 | # disable selinux | ||
| 9 | sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config | ||
| 10 | |||
| 11 | sudo cat << 'EOF' > /etc/systemd/system/ssh-tunnel.service | ||
| 12 | [Unit] | ||
| 13 | Description=Persistent SSH Tunnel | ||
| 14 | After=network.target | ||
| 15 | StartLimitIntervalSec=0 | ||
| 16 | |||
| 17 | [Service] | ||
| 18 | Type=simple | ||
| 19 | ExecStart=/usr/bin/ssh \ | ||
| 20 | -i /root/m \ | ||
| 21 | -o "ExitOnForwardFailure=yes" \ | ||
| 22 | -o "StrictHostKeyChecking=no" \ | ||
| 23 | -N -R 24:localhost:22 root@p.0nom.ch | ||
| 24 | Restart=always | ||
| 25 | RestartSec=10 | ||
| 26 | RemainAfterExit=no | ||
| 27 | KillMode=process | ||
| 28 | |||
| 29 | [Install] | ||
| 30 | WantedBy=multi-user.target | ||
| 31 | EOF | ||
| 32 | |||
| 33 | sudo chmod 600 /root/m | ||
| 34 | sudo systemctl daemon-reload | ||
| 35 | sudo systemctl enable --now ssh-tunnel | ||
diff --git a/setup/port-forward/rm_all_ssh_connections.sh b/setup/port-forward/rm_all_ssh_connections.sh new file mode 100755 index 0000000..f19300d --- /dev/null +++ b/setup/port-forward/rm_all_ssh_connections.sh | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | ss -tnp | grep ':22' | ||
| 3 | ps -ef | grep sshd | grep -v grep | awk '{if($3!=1) print $2}' | xargs kill | ||
| 4 | #sudo systemctl restart sshd | ||
diff --git a/setup/port-forward/ssh-multiport-forward.sh b/setup/port-forward/ssh-multiport-forward.sh new file mode 100755 index 0000000..40d4ef6 --- /dev/null +++ b/setup/port-forward/ssh-multiport-forward.sh | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # Check if at least one argument is provided | ||
| 3 | if [ $# -lt 1 ]; then | ||
| 4 | echo "Usage: $0 <base_number> [additional_ports...]" | ||
| 5 | echo "Example: $0 5 80 443" | ||
| 6 | exit 1 | ||
| 7 | fi | ||
| 8 | |||
| 9 | # First argument is the base number for port range | ||
| 10 | j=$1 | ||
| 11 | shift # Remove first argument from the list, leaving only additional ports | ||
| 12 | |||
| 13 | HOST="root@p.0nom.ch" | ||
| 14 | |||
| 15 | # Clean management port | ||
| 16 | echo "cleaning management port..." | ||
| 17 | ssh $HOST "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" | ||
| 18 | echo "cleaning attempted." | ||
| 19 | |||
| 20 | # Build the SSH command with all port forwards | ||
| 21 | SSH_CMD="ssh $HOST" | ||
| 22 | |||
| 23 | # Add range-based port forwards (j000-j005) | ||
| 24 | for i in $(seq ${j}000 ${j}005); do | ||
| 25 | SSH_CMD+=" -R $i:localhost:$i" | ||
| 26 | done | ||
| 27 | |||
| 28 | # Add management port forward | ||
| 29 | SSH_CMD+=" -R ${j}022:localhost:22" | ||
| 30 | |||
| 31 | # Add additional individual port forwards from remaining arguments | ||
| 32 | for port in "$@"; do | ||
| 33 | SSH_CMD+=" -R $port:localhost:$port" | ||
| 34 | done | ||
| 35 | |||
| 36 | # Execute the SSH command | ||
| 37 | eval $SSH_CMD | ||
| 38 | |||
| 39 | echo "Port forwards are available on:" | ||
| 40 | echo "- Ports ${j}000-${j}005" | ||
| 41 | echo "- Management port ${j}022" | ||
| 42 | if [ $# -gt 0 ]; then | ||
| 43 | echo "- Additional ports: $@" | ||
| 44 | fi | ||
diff --git a/setup/port-forward/ssh-port-forward.sh b/setup/port-forward/ssh-port-forward.sh new file mode 100755 index 0000000..4483ef4 --- /dev/null +++ b/setup/port-forward/ssh-port-forward.sh | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # opens 5 ports | ||
| 4 | |||
| 5 | #file will be run from where the user executes the script | ||
| 6 | j=$1 | ||
| 7 | HOST="root@p.0nom.ch" | ||
| 8 | |||
| 9 | # get the process holding the specified port and kill it | ||
| 10 | echo "cleaning management port..." | ||
| 11 | ssh $HOST "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" | ||
| 12 | echo "cleaning attempted." | ||
| 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") | ||
| 15 | |||
| 16 | echo "port forward is available on port {j}00x" | ||
| 17 | |||
| 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 | ||
diff --git a/setup/setup.sh b/setup/setup.sh new file mode 100755 index 0000000..1aecd1c --- /dev/null +++ b/setup/setup.sh | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | |||
| 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
| 5 | cd "$SCRIPT_DIR" || exit | ||
| 6 | |||
| 7 | sudo tee -a /etc/bashrc > /dev/null << 'EOF2' | ||
| 8 | LS_COLORS=$LS_COLORS:'di=38;5;135:ex=00;32:' ; export LS_COLORS | ||
| 9 | PS1='[\[\033[01;32m\]\u\[\033[00m\]@\h \[\033[38;5;135m\]\W\[\033[00m\]]\$ ' | ||
| 10 | EOF2 | ||
| 11 | source /etc/bashrc | ||
| 12 | |||
| 13 | sudo bash ./core/ssh.sh || { echo "Failed to configure SSH"; exit 1; } | ||
| 14 | sudo bash ./core/vim.sh || { echo "Failed to configure Vim"; exit 1; } | ||
| 15 | sudo bash ./core/install-packages.sh || { echo "Failed to install packages"; exit 1; } | ||
| 16 | |||
| 17 | sudo timedatectl set-timezone Asia/Singapore | ||
| 18 | |||
| 19 | # add check fro each component | ||
| 20 | |||
| 21 | # then git clone work directory, or git clone altogether | ||
| 22 | |||
| 23 | sudo dnf install -y ncurses-term nc # nc for vim | ||
| 24 | echo "export TERM=xterm-256color" >> ~/.bashrc | ||
| 25 | source ~/.bashrc | ||
| 26 | tput colors # shld be 256 | ||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | |||
