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 @@ "permissions": { "allow": [ "Bash(rm:*)", - "Bash(chmod:*)" + "Bash(chmod:*)", + "Bash(mkdir:*)", + "Bash(mv:*)" ], "deny": [] }, 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 @@ +#!/bin/bash + +# Install core packages +sudo dnf install -y epel-release +#sudo dnf group install -y "Development Tools" +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 +sudo dnf install -y xclip + +sudo dnf install -y gcc gcc-c++ +sudo dnf install -y java-latest-openjdk-devel +#sudo dnf install -y asio-devel boost-devel openssl-devel + +# Execute all package installation scripts +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +for script in "$SCRIPT_DIR/packages"/*.sh; do + if [ -f "$script" ]; then + "$script" + fi +done + +#install packages ml +#pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 +#pip3 install transformers + +#sudo yum install -y python3-openstackclient s3fs-fuse awscli +#pip install jupyterlab python-swiftclient +#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 @@ +#!/bin/bash + +# Install Node.js via nvm and Claude Code +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +nvm install 22 +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 @@ +#!/bin/bash + +# Install Rust and Cargo tools +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +echo '[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"' >> ~/.bashrc +source "$HOME/.cargo/env" +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 @@ +#!/bin/bash + +echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config +echo "AllowTcpForwarding yes" | sudo tee -a /etc/ssh/sshd_config +echo "GatewayPorts yes" | sudo tee -a /etc/ssh/sshd_config +echo "AllowAgentForwarding yes" | sudo tee -a /etc/ssh/sshd_config + +git clone https://git.noml.ch/keys ~/keys +~/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 @@ +#!/bin/bash + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit + +cat << EOF >> /etc/vimrc +augroup netcat_clipboard + au! + au TextYankPost * call system("openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023", @") +augroup END + +" Enable line wrapping +set wrap + +" Optional: Make wrapped lines easier to read by indenting them +set breakindent +set breakindentopt=shift:1 + +syntax on +set mouse=a +set expandtab +set shiftwidth=4 +set softtabstop=4 +set tabstop=4 +set noautoindent +set nosmartindent +filetype plugin indent on + +set laststatus=2 " permanent status bar +set statusline=%F " shows full file path + +if (has("termguicolors")) + set termguicolors +endif + +"colorscheme murphy +colorscheme zellner + +" Ctrl+A: Move to the beginning of the line in INSERT mode +inoremap <C-a> <Home> + +" Ctrl+E: Move to the end of the line in INSERT mode +inoremap <C-e> <End> + +" Ctrl+A: Move to the beginning of the line in NORMAL mode +nnoremap <C-a> 0 + +" Ctrl+E: Move to the end of the line in NORMAL mode +nnoremap <C-e> $ + +set number +setlocal regexpengine=2 +set paste +set foldcolumn=12 + + +EOF + + + 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 @@ +git config --global user.email "hc@email.ch" +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 @@ +#!/bin/bash +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 @@ +#!/bin/bash + +echo "selinux command is untested. copy paste systemd file if you want" +echo "reboot afterwards(selinux unset, need reboot to take effect, or just do sudo setenforce 0 for temp unset)" +echo "make sure /root/m exists" +echo "remember to change the remote port or host if needed" + +# disable selinux +sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config + +sudo cat << 'EOF' > /etc/systemd/system/ssh-tunnel.service +[Unit] +Description=Persistent SSH Tunnel +After=network.target +StartLimitIntervalSec=0 + +[Service] +Type=simple +ExecStart=/usr/bin/ssh \ + -i /root/m \ + -o "ExitOnForwardFailure=yes" \ + -o "StrictHostKeyChecking=no" \ + -N -R 24:localhost:22 root@p.0nom.ch +Restart=always +RestartSec=10 +RemainAfterExit=no +KillMode=process + +[Install] +WantedBy=multi-user.target +EOF + +sudo chmod 600 /root/m +sudo systemctl daemon-reload +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 @@ +#!/bin/bash +ss -tnp | grep ':22' +ps -ef | grep sshd | grep -v grep | awk '{if($3!=1) print $2}' | xargs kill +#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 @@ +#!/bin/bash +# Check if at least one argument is provided +if [ $# -lt 1 ]; then + echo "Usage: $0 <base_number> [additional_ports...]" + echo "Example: $0 5 80 443" + exit 1 +fi + +# First argument is the base number for port range +j=$1 +shift # Remove first argument from the list, leaving only additional ports + +HOST="root@p.0nom.ch" + +# Clean management port +echo "cleaning management port..." +ssh $HOST "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" +echo "cleaning attempted." + +# Build the SSH command with all port forwards +SSH_CMD="ssh $HOST" + +# Add range-based port forwards (j000-j005) +for i in $(seq ${j}000 ${j}005); do + SSH_CMD+=" -R $i:localhost:$i" +done + +# Add management port forward +SSH_CMD+=" -R ${j}022:localhost:22" + +# Add additional individual port forwards from remaining arguments +for port in "$@"; do + SSH_CMD+=" -R $port:localhost:$port" +done + +# Execute the SSH command +eval $SSH_CMD + +echo "Port forwards are available on:" +echo "- Ports ${j}000-${j}005" +echo "- Management port ${j}022" +if [ $# -gt 0 ]; then + echo "- Additional ports: $@" +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 @@ +#!/bin/bash + +# opens 5 ports + +#file will be run from where the user executes the script +j=$1 +HOST="root@p.0nom.ch" + +# get the process holding the specified port and kill it +echo "cleaning management port..." +ssh $HOST "ss -tunlp | grep :${j}022 | awk '{print $NF}' | sed 's/.*pid=\([^,]*\).*/\1/' | head -n1 | xargs kill -9" +echo "cleaning attempted." + +ssh $HOST $(for i in $(seq ${j}000 ${j}005); do echo "-R $i:localhost:$i"; done; echo "-R ${j}022:localhost:22") + +echo "port forward is available on port {j}00x" + +#ideally port forward from 2 onwards, there seems to be a problem for 1000(or just change all to j001) +#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 @@ +#!/bin/bash + + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "$SCRIPT_DIR" || exit + +sudo tee -a /etc/bashrc > /dev/null << 'EOF2' +LS_COLORS=$LS_COLORS:'di=38;5;135:ex=00;32:' ; export LS_COLORS +PS1='[\[\033[01;32m\]\u\[\033[00m\]@\h \[\033[38;5;135m\]\W\[\033[00m\]]\$ ' +EOF2 +source /etc/bashrc + +sudo bash ./core/ssh.sh || { echo "Failed to configure SSH"; exit 1; } +sudo bash ./core/vim.sh || { echo "Failed to configure Vim"; exit 1; } +sudo bash ./core/install-packages.sh || { echo "Failed to install packages"; exit 1; } + +sudo timedatectl set-timezone Asia/Singapore + +# add check fro each component + +# then git clone work directory, or git clone altogether + +sudo dnf install -y ncurses-term nc # nc for vim +echo "export TERM=xterm-256color" >> ~/.bashrc +source ~/.bashrc +tput colors # shld be 256 + + + + |
