From 534225c1351996f616b7b194a9938c55d91c8176 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 11:06:11 +0800 Subject: [PATCH 1/7] [misc] use kubectl without sudo --- devel/k3s.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/devel/k3s.sh b/devel/k3s.sh index 38fe1a6..234395d 100755 --- a/devel/k3s.sh +++ b/devel/k3s.sh @@ -19,6 +19,7 @@ CF_API_KEY=$5 # install ks3 ssh "$SSH" ' if ! command -v k3s >/dev/null ; then + export K3S_KUBECONFIG_MODE="644" export INSTALL_K3S_MIRROR=cn export INSTALL_K3S_VERSION=v1.20.0-k3s2 export INSTALL_K3S_EXEC="--tls-san '"$IP"' --node-external-ip '"$IP"' --disable traefik --default-local-storage-path /data" From 527f52b1796be6857f6de943843e2aaf7cb4b93a Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 11:22:04 +0800 Subject: [PATCH 2/7] [bugfix] certificates lost after system reboot --- devel/k3s/traefik-dpy.yaml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/devel/k3s/traefik-dpy.yaml b/devel/k3s/traefik-dpy.yaml index 062f92d..4d09e7a 100644 --- a/devel/k3s/traefik-dpy.yaml +++ b/devel/k3s/traefik-dpy.yaml @@ -44,9 +44,9 @@ spec: spec: serviceAccountName: traefik-ingress-controller containers: - - name: traefik - image: traefik:v2.3.6 - args: + - name: traefik + image: traefik:v2.3.6 + args: - --api.insecure - --accesslog - --entrypoints.web.Address=:80 @@ -54,11 +54,19 @@ spec: - --providers.kubernetescrd - --certificatesresolvers.myresolver.acme.tlschallenge - --certificatesresolvers.myresolver.acme.email=EMAIL - - --certificatesresolvers.myresolver.acme.storage=acme.json - ports: + - --certificatesresolvers.myresolver.acme.storage=/data/acme.json + ports: - name: web containerPort: 80 - name: websecure containerPort: 443 - name: admin containerPort: 8080 + volumeMounts: + - name: data + mountPath: /data + volumes: + - name: data + hostPath: + path: /data/traefik + type: DirectoryOrCreate From 92b889c36aee6036af591b7b8a3d09992fda6edf Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 11:48:11 +0800 Subject: [PATCH 3/7] [misc] shorten Buffer shortcut --- cli/vim/init.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/vim/init.vim b/cli/vim/init.vim index 64919b7..2db8f3c 100644 --- a/cli/vim/init.vim +++ b/cli/vim/init.vim @@ -234,7 +234,7 @@ let g:fugitive_no_maps=1 nnoremap :call fzf#vim#files(trim(system("git rev-parse --show-toplevel \|\| pwd"))) nnoremap gco :call fzf#run({'source': 'git branch \| cut -c 3-; git tag -l', 'sink': '!git checkout'}) nnoremap gm :call fzf#run({'source': 'git branch \| cut -c 3-', 'sink': '!git merge'}) -nnoremap ls :Buffers +nnoremap b :Buffers " ==== gruvbox configuration ==== From c59ea9601b107445f6ba29f140234ed7cb001bee Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 11:48:41 +0800 Subject: [PATCH 4/7] [feature] add dotfiles/bin to path --- cli/fish/config.fish | 2 +- cli/fish/functions/append_paths.fish | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/fish/config.fish b/cli/fish/config.fish index 8edf169..2f1fbd9 100644 --- a/cli/fish/config.fish +++ b/cli/fish/config.fish @@ -53,7 +53,7 @@ if status is-interactive alias dt='date "+%Y%m%d-%H%M%S"' # === PATH and file sourcing - append_paths ~/.yarn/bin + append_paths ~/.yarn/bin ~/dotfiles/bin source_files /usr/share/autojump/autojump.fish /usr/local/share/autojump/autojump.fish \ ~/.profile.fish diff --git a/cli/fish/functions/append_paths.fish b/cli/fish/functions/append_paths.fish index 67aa141..58e8c12 100644 --- a/cli/fish/functions/append_paths.fish +++ b/cli/fish/functions/append_paths.fish @@ -1,6 +1,6 @@ function append_paths for f in $argv - test -e $f && set -gx PATH $f $PATH + test -e $f && ! contains $f $PATH && set -gx PATH $f $PATH end end From 3a46ca0e6787f2507f0265638f6cf7dea67f450c Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 15:30:01 +0800 Subject: [PATCH 5/7] [bugfix] ubuntu release env-var / bat not working --- cli/basic.sh | 7 ------- cli/fish.sh | 16 ++++------------ cli/fish/config.fish | 2 +- cli/vim.sh | 2 +- devel/deeplearning.sh | 6 +++--- env.sh | 10 ++++++++-- gui/office.sh | 8 ++++---- 7 files changed, 21 insertions(+), 30 deletions(-) diff --git a/cli/basic.sh b/cli/basic.sh index 531364a..73b81f3 100755 --- a/cli/basic.sh +++ b/cli/basic.sh @@ -14,13 +14,6 @@ case "$PM" in openssh-client \ curl wget \ man sudo - if [ -f /etc/lsb-release ]; then - set -a - . /etc/lsb-release - set +a - export DISTRIB_RELEASE_MAJOR=${DISTRIB_RELEASE%.*} - export DISTRIB_RELEASE_MINOR=${DISTRIB_RELEASE#.*} - fi ;; pacman) sudo pacman -S --noconfirm --needed \ diff --git a/cli/fish.sh b/cli/fish.sh index 0f5352b..c4138ea 100755 --- a/cli/fish.sh +++ b/cli/fish.sh @@ -7,13 +7,15 @@ DIR=$(dirname "$(readlink -f "$0")") log 'Setting up shell' case "$PM" in apt) - sudo add-apt-repository ppa:fish-shell/release-3 -y + sudo add-apt-repository ppa:fish-shell/release-3 -y -n pm_update sudo apt install fish silversearcher-ag -y + echo DISTRIB_RELEASE_MAJOR: $DISTRIB_RELEASE_MAJOR + echo DISTRIB_RELEASE: $DISTRIB_RELEASE if [ "$DISTRIB_RELEASE_MAJOR" -gt 19 ] || [ "$DISTRIB_RELEASE" = "19.10" ]; then sudo apt install dash bat -y fi - lnsf /usr/bin/batcat /usr/bin/bat + sudo ln -sf /usr/bin/batcat /usr/bin/bat intorepo https://github.com/junegunn/fzf.git "$HOME/.fzf" ./install --all exitrepo @@ -39,16 +41,6 @@ case "$PM" in esac -if has_cmd bat; then - log 'Setting up bat' - BAT_THEMES="$(bat --config-dir)/themes" - BAT_GRUVBOX="$BAT_THEMES/gruvbox" - if [ ! -d "$BAT_GRUVBOX" ]; then - mkdir -p "$BAT_THEMES" - git_clone https://github.com/peaceant/gruvbox.git "$BAT_GRUVBOX" - fi -fi - # only for local machine with gui if [ -z "$SSH_CLIENT" ] && [ -n "$DISPLAY" ] && has_cmd dash; then log 'Setting up dash as default shell' diff --git a/cli/fish/config.fish b/cli/fish/config.fish index 2f1fbd9..9dbb831 100644 --- a/cli/fish/config.fish +++ b/cli/fish/config.fish @@ -23,7 +23,7 @@ if status is-interactive set -gx LS_COLORS 'ow=34;42;40' # === bat configuration - set -gx BAT_THEME 'gruvbox' + set -gx BAT_THEME 'OneHalfDark' set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'" # === dict.sh configuration diff --git a/cli/vim.sh b/cli/vim.sh index 65d2d79..eb9acc7 100755 --- a/cli/vim.sh +++ b/cli/vim.sh @@ -29,7 +29,7 @@ if ! has_cmd "$VIM"; then #fi # gui-common is required for clipboard integration - sudo add-apt-repository ppa:jonathonf/vim -y + sudo add-apt-repository ppa:jonathonf/vim -y -n pm_update sudo apt install -y vim vim-gui-common if enhance_vim; then diff --git a/devel/deeplearning.sh b/devel/deeplearning.sh index e7b64b4..5f491ae 100755 --- a/devel/deeplearning.sh +++ b/devel/deeplearning.sh @@ -19,9 +19,9 @@ case "$PM" in sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 sudo apt-key adv --fetch-keys \ https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub - sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" - sudo apt-get update - sudo apt-get -y install cuda + sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" -y -n + pm_update + sudo apt -y install cuda elif [ "$DISTRIB_RELEASE" = "20.04" ]; then sudo apt install nvidia-cuda-toolkit else diff --git a/env.sh b/env.sh index 372d601..e2aafc6 100755 --- a/env.sh +++ b/env.sh @@ -80,7 +80,7 @@ enhance_vim() { pm_update() { # skip updation on daily basis TSFILE=/tmp/apt_updated_at_$(date +%Y%m%d) - CHECKSUM=$(md5sum $(find /etc/apt -type f | sort)) + CHECKSUM=$(md5sum /etc/apt/sources.list /etc/apt/sources.list.d/*.list | sort | md5sum) grep -qF "$CHECKSUM" "$TSFILE" && return case "$PM" in apt) @@ -107,6 +107,13 @@ if [ "$PM" = "n/a" ]; then echo "Unsupported Package Manager" exit 1 fi +if [ -f /etc/lsb-release ]; then + set -a + . /etc/lsb-release + set +a + export DISTRIB_RELEASE_MAJOR=${DISTRIB_RELEASE%.*} + export DISTRIB_RELEASE_MINOR=${DISTRIB_RELEASE#.*} +fi log "Environments" echo " PM : $PM" @@ -114,4 +121,3 @@ echo " DIR : $DIR" echo " PDIR : $PDIR" echo " PREFIX : $PREFIX" echo " GITHUB_PROXY : $GITHUB_PROXY" - diff --git a/gui/office.sh b/gui/office.sh index b9f49c8..a979a5c 100755 --- a/gui/office.sh +++ b/gui/office.sh @@ -8,10 +8,10 @@ log 'Settingup office tools: libreoffice keepassxc nextcloud chrome zathura gimp case "$PM" in apt) - sudo add-apt-repository -y ppa:libreoffice/libreoffice-7-0 - sudo add-apt-repository -y ppa:phoerious/keepassxc - sudo add-apt-repository -y ppa:nextcloud-devs/client - sudo apt update + sudo add-apt-repository -y -n ppa:libreoffice/libreoffice-7-0 + sudo add-apt-repository -y -n ppa:phoerious/keepassxc + sudo add-apt-repository -y -n ppa:nextcloud-devs/client + pm_update sudo apt install -y \ google-chrome-stable \ zathura zathura-pdf-poppler sxiv \ From 61077969dfe83ef743aebbcd94119b343e2d8e2c Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 15:30:45 +0800 Subject: [PATCH 6/7] [feature] \n \p for move between quickfix --- cli/vim/init.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/vim/init.vim b/cli/vim/init.vim index 2db8f3c..633982a 100644 --- a/cli/vim/init.vim +++ b/cli/vim/init.vim @@ -81,6 +81,10 @@ au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red au Syntax * match ExtraWhitespace /\s\+$/ nnoremap es :%s/\s\+$//g +" location jumping +nnoremap n :cnext +nnoremap p :cprev + " auto install vim-plug if has('nvim') if has('win32') From c4415a89fa2831fce16ce081e29edb5446752783 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 15:31:07 +0800 Subject: [PATCH 7/7] [feature] working with k8s pod easily --- bin/kp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 bin/kp diff --git a/bin/kp b/bin/kp new file mode 100755 index 0000000..0d178e2 --- /dev/null +++ b/bin/kp @@ -0,0 +1,16 @@ +#!/bin/sh + +POD=$(sudo kubectl get pod | grep -P "^$2" | awk '{print $1}') +CTN=$3 + + +case $1 in + sh) + kubectl exec -it $POD ${CTN+"-c$CTN"} -- sh + ;; + d) # describe pod + kubectl describe pod $POD + ;; + e) # watch event of pod + kubectl get event -w --field-selector=involvedObject.name=$POD +esac