added some missing modules from initial commit

master
Kebler Network System Administrator 2022-02-21 12:42:22 -08:00
parent d3b61e15b7
commit 8ffd43d25e
6 changed files with 81 additions and 0 deletions

40
modules/machine.sh Normal file
View File

@ -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
}

16
modules/node.sh Normal file
View File

@ -0,0 +1,16 @@
module_load confirm
rm_node_modules () {
parent=${1:-$PWD}
echo finding node_modules folders within $parent
if command find . -name 'node_modules' -type d -prune 2>/dev/null;then
confirm continue with deleting? || return 1
command find . -name 'node_modules' -type d -prune -exec rm -r '{}' +
else
echo no folders to delete
fi
}
# if script was executed then call the function
(return 0 2>/dev/null) || rm_node_modules $@

25
modules/vscode.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
VSCODE_BIN=$(command -v code)
VSCODE_BIN=${VSCODE_BIN:-$(command -v codium)}
[[ $VSCODE_BIN ]] || {
echo "no vscode binary on machine"
exit
}
# set default home here
# can pass
vscode() {
#local home=$HOME
local home=/opt/vscode
home=${VSCODE_HOME:-$home}
[[ $1 == "-h" ]] && home=$2 && shift 2
mkdir -p ${home}/${USER}
[[ $? -ne 0 ]] && echo "unable to set vscode home at $home/$USER, aborting" && return 1
exts=${home}/${USER}/extensions
user=${home}/${USER}/data
echo $VSCODE_BIN --user-data-dir=$user --extensions-dir=$exts "$@"
$VSCODE_BIN --user-data-dir=$user --extensions-dir=$exts "$@"
}
# # if script was executed then call the function
(return 0 2>/dev/null) || vscode $@