From 693983249a140a122dfe188296cb764e1d519ed9 Mon Sep 17 00:00:00 2001 From: David Kebler Date: Fri, 20 Nov 2020 15:48:57 -0800 Subject: [PATCH] moved language stuff and docker stuff to host/all --- all/lang/node | 54 ++++++++++++++++++++++++++++++++++ all/lang/pm2 | 9 ++++++ all/lang/python | 12 ++++++++ all/lang/yarn | 19 ++++++++++++ all/misc/docker/00-docker.env | 2 ++ all/misc/docker/01-docker | 4 +++ all/misc/docker/docker-compose | 30 +++++++++++++++++++ all/misc/docker/docker.alias | 31 +++++++++++++++++++ all/modules/machine.sh | 40 +++++++++++++++++++++++++ 9 files changed, 201 insertions(+) create mode 100644 all/lang/node create mode 100644 all/lang/pm2 create mode 100644 all/lang/python create mode 100644 all/lang/yarn create mode 100644 all/misc/docker/00-docker.env create mode 100644 all/misc/docker/01-docker create mode 100644 all/misc/docker/docker-compose create mode 100644 all/misc/docker/docker.alias create mode 100644 all/modules/machine.sh diff --git a/all/lang/node b/all/lang/node new file mode 100644 index 0000000..96016b2 --- /dev/null +++ b/all/lang/node @@ -0,0 +1,54 @@ +#!/bin/bash + +if command -v node >/dev/null 2>&1; then +# echo addding node langauge stuff +# gives access to packages with bin in a project +path_append ./node_modules/.bin +path_append /opt/node-global-apps/bin + + +export NPM_REGISTRY=https://npm.kebler.net +alias nr="npm run" +alias nrs="npm -s run" +alias nt="npm -s test" +alias ntw="npm -s run testw" +alias npms="npm start" +alias npmlag="npm la --silent --depth=0 --global" +alias npmla="npm la --silent --depth=0" +alias npmlaf="npm la --silent | grep" +alias npmlsg="npm ls --silent --depth=0 --global" +alias npmlsf="npm ls --silent grep" +alias npmlsa="npm ls --silent" +alias npmls="npm ls --silent --depth=0" +# just npm install for install without saving into package.json +alias npmi="npm install --save" +alias npmr="npm uninstall --save" +alias npmio="npm install --save-optional" +alias npmro="npm uninstall --save-optional" +alias npmidv="npm install --save-dev" +alias npmidvnd="npm install --save-dev --package-lock-only --no-package-lock" +alias npmrdv="npm uninstall --save-dev" +alias npmig="npm install -g" +alias snpmig="sudo npm install -g" +alias npmrg="npm uninstall -g" +alias snpmrg="npm uninstall -g" +alias npmunpm="echo npm installed version && npm --version && echo npm latest version available && npm view npm@latest version && echo any key to continue npm upgrade or break && read && npm install -g npm@latest" +alias npmua="npm --depth=9999 update" +alias npmug="npm-check -g -u" +alias npmu="npm-check -u" +alias npmcc="ncu -p -a -u" +alias npmcdvc="ncu -d -a -u" +alias npmc="ncu -p" +alias npma="npm-add-dependencies" +# will publish to whichever is the default registry - confusing so commented out +# alias npmpub="npm publish --access public" +alias npmlrepub="npm publish --registry http://localhost:4873 --force --access restricted" +alias npmlpub="npm publish --registry http://localhost:4873 --access restricted" +alias npmnrepub="npm publish --registry https://npm.kebler.net --force --access restricted" +alias npmnpub="npm publish --registry https://npm.kebler.net --access restricted" +alias npmjspub="npm publish --registry https://registry.npmjs.org --access public" +alias yalcpush="nodemon -x 'yalc push'" + +# else + # echo "node not installed, npm aliases not loaded" +fi diff --git a/all/lang/pm2 b/all/lang/pm2 new file mode 100644 index 0000000..6302697 --- /dev/null +++ b/all/lang/pm2 @@ -0,0 +1,9 @@ +alias pmi="sudo pm2 install" +alias pms="sudo pm2 start" +alias pmstp="sudo pm2 stop" +alias pmr="sudo pm2 delete" +alias pmra="sudo pm2 delete all" +alias pmstpa="sudo pm2 stop all" +alias pmv="sudo pm2 save" +alias pml="sudo pm2 list" +alias pmm="sudo pm2 monit" diff --git a/all/lang/python b/all/lang/python new file mode 100644 index 0000000..d5223bb --- /dev/null +++ b/all/lang/python @@ -0,0 +1,12 @@ +alias python3="python3.8" +alias spip="sudo -H python3.8 -m pip" +alias spipi="sudo -H python3.8 -m pip install" +alias spipiu="sudo -H python3.8 -m pip install -U" +alias spipl="sudo -H python3.8 -m pip list" +alias spiplo="sudo -H python3.8 -m pip list --outdated" +alias pipu="pipx upgrade" +alias pipua="pipx upgrade-all" +alias pipupip="pipx upgrade pipx" +alias pipi="pipx install" +alias pipl="pipx list" +alias piplv="pipx list --verbose" diff --git a/all/lang/yarn b/all/lang/yarn new file mode 100644 index 0000000..6b4f5ce --- /dev/null +++ b/all/lang/yarn @@ -0,0 +1,19 @@ +alias ycc="yarn cache clean" +alias yr="yarn run" +alias ys="yarn run start" +alias ya="yarn add" +# alias yu="yarn upgrade" +alias yrm="yarn remove" +alias yao="yarn add --optional" +alias yad="yarn add --dev" +alias yl="yarn list --depth=0" +alias ylp="yarn list --depth=0 --pattern" +alias yu="yarn upgrade-interactive" + +alias ylg="yarn global list --depth=0" +alias ylgp="yarn global list --depth=0 --pattern" +alias yag="yarn global add" +alias yrg="yarn global remove" +alias yug="yarn global upgrade-interactive" + +alias ypub="yarn publish --access public" diff --git a/all/misc/docker/00-docker.env b/all/misc/docker/00-docker.env new file mode 100644 index 0000000..6886770 --- /dev/null +++ b/all/misc/docker/00-docker.env @@ -0,0 +1,2 @@ +#!/bin/bash +export DOCKER_COMPOSE_ROOT=/opt/containers diff --git a/all/misc/docker/01-docker b/all/misc/docker/01-docker new file mode 100644 index 0000000..e248fe3 --- /dev/null +++ b/all/misc/docker/01-docker @@ -0,0 +1,4 @@ +#!/bin/bash +docker_terminal () { +docker exec -it $1 /bin/sh +} diff --git a/all/misc/docker/docker-compose b/all/misc/docker/docker-compose new file mode 100644 index 0000000..9178f78 --- /dev/null +++ b/all/misc/docker/docker-compose @@ -0,0 +1,30 @@ +#!/bin/bash + +# only source if docker and docker_compose are installed +command -v docker >/dev/null 2>&1 || return +command -v docker-compose >/dev/null 2>&1 || return + +function dkcmp () { + DIR=/opt/containers/$1 + cd $DIR || return + case $2 in + start ) + docker-compose up -d + ;; + stop ) + docker-compose down + ;; + remove ) + docker volume ls | grep $1 + docker-compose rm -s -v + ;; + restart ) + docker-compose down + docker-compose up -d + ;; + make ) + docker-compose up -d --force-recreate + ;; + esac + cd - >/dev/null 2>&1 || return +} diff --git a/all/misc/docker/docker.alias b/all/misc/docker/docker.alias new file mode 100644 index 0000000..bacd278 --- /dev/null +++ b/all/misc/docker/docker.alias @@ -0,0 +1,31 @@ +#!/bin/bash +command -v docker >/dev/null 2>&1 || return + +#docker - add users to docker group to avoid needing sudo +# run a command on a container +# if [ $(which docker)]; then + +alias dkcr="docker run" +# start a container +alias dkcs="docker start" +# restart all running containers +alias dkcrr="docker restart $(docker ps -q)" +# start all exited containers +alias dkcsu="docker start $(docker ps --filter "status=exited")" +# ls stopped, la all, l running +alias dkcls="docker ps --filter "status=exited"" +alias dkcla="docker ps -a " +alias dkcl="docker ps " +alias dkil="docker images --digests=true" +alias dkir="docker rmi $(docker images -q)" +alias dks="sudo service docker" +alias dkcstpa="docker stop $(docker ps -a -q)" +# remove unrunning containers +alias dkcrm="docker rm $(docker ps -a -q)" +# stop and remove +alias dkcsrm="docker rm -f $(docker ps -a -q)" +# cleans out unused/dangling aufs volumes - run this occasionally +alias dkclean="docker volume ls -qf dangling=true | xargs -r docker volume rm" +alias dkde="gksudo gedit /etc/default/docker" + +alias dkterm="docker_terminal" diff --git a/all/modules/machine.sh b/all/modules/machine.sh new file mode 100644 index 0000000..013829b --- /dev/null +++ b/all/modules/machine.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +function get_platform () { + + local OS + local ARCH + local PLATFORM + + OS="$(uname -s)" + ARCH="$(uname -m)" + + case $OS in + "Linux") + case $ARCH in + "x86_64") + ARCH=amd64 + ;; + "aarch64") + ARCH=arm64 + ;; + "armv6") + ARCH=armv6l + ;; + "armv8") + ARCH=arm64 + ;; + .*386.*) + ARCH=386 + ;; + esac + PLATFORM="linux-$ARCH" + ;; + "Darwin") + PLATFORM="darwin-amd64" + ;; + esac + + echo $PLATFORM + +}