ignored archive

refactor docker
added languages
added/refactor btrbk library
added sudoers
master
David Kebler 2023-12-14 17:29:19 -08:00
parent ed853fdf99
commit f4d2fe1c08
68 changed files with 281 additions and 1361 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
archive/

View File

@ -22,6 +22,7 @@ chromium_() {
[[ $1 == -u ]] && exe=/opt/bin/ungoogled-chromium && shift
[[ $1 == -v ]] && exe=/opt/vivaldi/vivaldi && shift
[[ $1 == -c ]] && exe=/usr/bin/chromium && shift
[[ $1 == -m ]] && exe=/opt/mqttbox/chrome-linux/chrome-wrapper && shift
echo execuatble to be used: $exe
if [[ ! -f $exe ]]; then
echo chromium/chrome not installed at $exe

View File

@ -1,25 +1,35 @@
#!/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 "$@"
CODE_BIN=/opt/vscode/bin/code
VSCODIUM_BIN=$(command -v code-oss)
local home=/opt/vscode;local code=-codium
local exts; local user; local bin=$VSCODIUM_BIN
[[ $1 == "-c" ]] && code=-code && bin=$CODE_BIN && shift 1
if [[ $1 == "-h" ]]; then
home=$2
shift 2
else
home=${VSCODE_HOME:-$home}/${USER}$code
fi
exts=$home/extensions
user=$home/data
if [[ -x $bin ]]; then
if ! mkdir -p ${home} ; then
echo "unable to set vscode home at $home, aborting"
return 1
else
echo "saving vscode user data and extentions to $home"
fi
echo $bin --user-data-dir=$user --extensions-dir=$exts "$@"
$bin --user-data-dir=$user --extensions-dir=$exts "$@"
else
echo "can't find binary $bin"
fi
}
# # if script was executed then call the function
(return 0 2>/dev/null) || vscode $@

View File

@ -1,4 +0,0 @@
command -v docker >/dev/null 2>&1 || return
alias bashly='docker run --rm -it --volume "$PWD:/app" dannyben/bashly'
alias bashly-update='docker pull dannyben/bashly:latest'

View File

@ -1,26 +0,0 @@
#!/bin/bash
module_load notify
_ch=$(command -v _chromium)
if [[ $_ch ]]; then
ch=$(dirname "$_ch")/chromium
## if chromium exits probably an update to so move again
msg="new version availabe, run: sudo mv $ch $_ch"
[[ -f $ch ]] && llog $msg && notify-send $msg
export CHROME_CONFIG_HOME="/opt/chromium"
# chmod +x $BASH_SHELL_HOST/all/modules/chromium.sh
ln -sf $BASH_SHELL_HOST/all/modules/chromium.sh /opt/bin/chromium
llog "chromium sucessfully set up on $HOSTNAME"
login_notify "chromium sucessfully set up on $HOSTNAME"
else
# echo no _chromium
ch=$(command -v chromium)
if [[ $ch ]];then
llog "chromium availabe, need to run this command and log in again"
login_notify "chromium availabe but need to run this command and log in again"
llog "sudo mv $ch $(dirname $ch)/_chromium"
login_notify "sudo mv $ch $(dirname $ch)/_chromium"
else
llog "Warning: ungoogled chromimum not installed on $HOSTNAME"
login_notify "Warning: ungoogled chromimum not installed on $HOSTNAME"
fi
fi

View File

@ -1,2 +0,0 @@
alias gspa="git subrepo push --all"
alias gpom="git pull origin master" # update repo from default remove

View File

@ -1,29 +0,0 @@
sudo rclone.bin
chmod 775 rclone.bin
touch $INSTALL_DIR/rclone
touch $INSTALL_DIR/rclone.conf
mkdir $INSTALL_DIR/cache 2> /dev/null || true
echo '#!/bin/bash' > $INSTALL_DIR/rclone
CMD=$(echo $INSTALL_DIR/rclone.bin \
--config=$INSTALL_DIR/rclone.conf \
--cache-dir=$INSTALL_DIR/cache \
'$@' \
)
echo "$CMD" >> $INSTALL_DIR/rclone
chown :sudo rclone
chmod 775 rclone
rm $BIN_DIR/rclone
ln -s $INSTALL_DIR/rclone $BIN_DIR/rclone
echo -e "rclone customized command can be launched from $(command -v rclone) \n $CMD"
echo -e "uncustomized rclone can be run from $INSTALL_DIR/rclone.bin"
cd ..
#update version variable post install
version=`rclone --version 2>>errors | head -n 1`
printf "\n${last_version} has successfully installed."
printf '\nNow run "rclone config" to set up remotes. Check https://rclone.org/docs/ for more details.\n\n'
return 0
}

View File

@ -1,5 +0,0 @@
#!/bin/bash
# where public keys are stored. default is $HOME/.ssh
# export SSH_PUB_KEYS=/data/secure/pubkeys
# default user for any ssh
export SSH_USER=sysadmin

View File

View File

@ -7,6 +7,10 @@ alias pmi="sudo pacman -S --needed"
alias pmr="sudo pacman -Rs"
alias pmua="sudo pacman -Syu"
alias pms="pacman -Ss"
alias pml="pacman -Qe"
alias pmlg="pacman -Qe | grep"
# https://unix.stackexchange.com/a/409903/201387
alias pmlf="comm -23 <(pacman -Qqett | sort | uniq) <(pacman -Qqg base-devel | sort | uniq)"
alias pkgst="pacman -Qi"
alias pkgi="pacman -Si"

View File

@ -1,13 +0,0 @@
# apt package manager
# TODO only add if apt is package manager
alias installa="sudo apt-get install"
alias reinstall="sudo apt install --reinstall"
# change depending on distro - need to have backports loaded in apt sources
# FYI can just load individual binaries from the wiki using deb files say from testing or unstable
alias remove="sudo apt-get remove"
alias aremove="sudo apt-get autoremove"
alias purge="sudo apt-get purge"
alias update="sudo apt-get update"
alias pkgst="apt policy"
alias esources='sudo nano /etc/apt/sources.list.d/'
alias ppa='sh -c '\''sudo add-apt-repository ppa:$1/ppa'\'' _'

View File

@ -1,120 +0,0 @@
#!/bin/bash
add_ppa () {
if [ $EUID != 0 ]; then
echo calling with sudo
sudo bash -c "$(declare -f add_ppa); add_ppa $*"
else
VERSION=jammy
KEYSDIR=/etc/apt/trusted.gpg.d
KEYSERVER=keyserver.ubuntu.com
declare OPTION; declare OPTARG; declare OPTIND
while getopts 'v:p:s:k:c:d:oi' OPTION; do
echo processing: option:$OPTION argument:$OPTARG index:$OPTIND remaining:${@:$OPTIND}
case "$OPTION" in
i)
INSTALL=true
;;
v)
VERSION=$OPTARG
;;
p)
PACKAGE=$OPTARG
;;
c)
CMD=$OPTARG
;;
d)
KEYSDIR=$OPTARG
;;
s)
KEYSERVER=$OPTARG
;;
o)
# overwrite any exising public key
KEYOVERWRITE=true
;;
*) echo unknown run option -$OPTARG
echo "USAGE: add-ppa <options> package/branch (e.g. git-core/ppa)"
echo "available options -v <ubnutu version name - default Jammy>; -p <apt install package name if not the same>"
;;
esac
done
shift $((OPTIND - 1))
#check input
if [ -z ${1+x} ]; then
echo "No ppa provided!"
return 1
fi
LAUNCHPAD="https://ppa.launchpadcontent.net"
DEV=$(echo $1 | cut -d ':' -f 2 | cut -d '/' -f1 )
PACKAGE=${PACKAGE:-$DEV}
CMD=${CMD:-$PACKAGE}
BRANCH=${2:-$(echo $1| cut -d '/' -f 2)}
URL="$LAUNCHPAD/$DEV/$BRANCH/ubuntu $VERSION main"
echo "*********** Adding PPA Repository ************"
echo DEVELOPER: $DEV
echo BRANCH: $BRANCH
echo PACKAGE: $PACKAGE
echo COMMAND: $CMD
echo URL: $URL
if [[ -t 0 ]]; then
read -n 1 -p "do you want to continue [y]=>" REPLY
[[ $REPLY != "y" ]] && return 0
fi
echo -e "\n*********************************************"
#create source list file
echo "deb $URL" > /etc/apt/sources.list.d/$DEV.list
echo "***** added /etc/apt/sources.list.d/$DEV.list with****"
cat /etc/apt/sources.list.d/$DEV.list
echo "*********************************************"
KEYFILE=$KEYSDIR/$DEV.gpg
[[ $KEYOVERWRITE ]] && rm $KEYFILE
if [ ! -f $KEYFILE ]; then
# using an update error to grab key id
KEY_ERROR=/tmp/${DEV}_key_error
touch $KEY_ERROR
apt-get update > /dev/null 2> $KEY_ERROR
cat $KEY_ERROR
KEY=$(sed -n 's/^.*NO_PUBKEY //p' "$KEY_ERROR" | head -1)
# echo Reposity Public Key Settings
# echo KEYS DIRECTORY: $KEYSDIR
# echo KEY SERVER: $KEYSERVER
# echo KEY: $KEY
if [ ! $KEY ]; then
echo can not determine $DEV/$BRANCH key sign
echo "removing file: /etc/apt/sources.list.d/$DEV.list and aborting"
rm /etc/apt/sources.list.d/$DEV.list
return 1
fi
echo downloading and saving public key $KEY for $DEV/$BRANCH to $KEYFILE
gpg --keyserver $KEYSERVER --recv $KEY
gpg --export $KEY > $KEYFILE
else
echo " >>>>>> $KEYFILE already exists, using that key $KEY <<<<<"
fi
echo ppa repo $DEV/$BRANCH for package $PACKAGE now registered, updating...
apt-get update 1> /dev/null
if [[ $INSTALL ]]; then
echo installing $PACKAGE
[[ -t 0 ]] && apt policy $PACKAGE
apt-get install $PACKAGE -y
$CMD --version
fi
fi
}
# # if script was executed then call the function
(return 0 2>/dev/null) || add_ppa $@

View File

@ -1,14 +0,0 @@
#!/bin/bash
command -v multipass >/dev/null 2>&1 || return
# [[ ! -f /snap/bin/multipass ]] && return
alias mpls="multipass list"
alias mp="multipass"
alias mpl="multipass_launch"
alias mps="multipass shell"
alias mpssh="multipass_ssh"
alias mprm="multipass_remove"
alias mph="multipass --help"
alias mpscr="multipass_ssh_script"
alias mprd="sudo snap restart multipass.multipassd"

View File

@ -1,93 +0,0 @@
#!/bin/bash
command -v multipass >/dev/null 2>&1 || return
multipass_launch () {
subdir=${MULTIPASS_HOME:-multipass}
[[ $1 ]] && name="-n $1"
if [[ $2 ]]; then
file="$HOME/$subdir/cloud-init/$2.yaml"
if [[ -f $file ]]; then
init="--cloud-init $file"
else
echo no cloud init file $file
return 1
fi
fi
echo running: multipass launch $name $init
multipass launch $name $init
}
multipass_remove () {
[[ ! $1 ]] && echo must supply an instance name && return 1
module_load confirm
confirm "delete and purge instance $1?" || return 1
multipass delete -p $1
}
multipass_get_sshid () {
dest=${1:-$HOME/.ssh/multipass_key}
[[ -f $dest ]] && echo $dest && return 0
src=${SNAP_VAR:-/var/snap}/multipass/common/data/multipassd/ssh-keys/id_rsa
[[ ! -f $src ]] && return 1
sudo cp $src $dest
sudo chown $USER:$USER $dest
chmod 600 $dest
echo $dest
}
multipass_get_ip () {
[[ ! $1 ]] && return 1
json=$(multipass info --format json $1 2> /dev/null)
[[ ! $json ]] && return 2
ip=$(echo "$json" | jq -r .info.$1.ipv4[0] 2> /dev/null)
[[ $ip = "null" ]] && return 3
[[ $ip ]] && echo $ip || return 4
return 0
}
multipass_ssh_options () {
id=$(multipass_get_sshid)
[[ $? -gt 0 ]] && return 1
echo -o IdentitiesOnly=yes -o IdentityFile=$id
return 0
}
multipass_ssh_cmd () {
[[ ! $1 ]] && { echo must supply name of instance name; return 1; }
ip=$(multipass_get_ip $1)
[[ ! $ip ]] && { echo "no ip for instance $1"; return 2; }
user=${2:-ubuntu}
opts=$(multipass_ssh_options)
[[ ! $opts ]] && return 3
echo $opts $user@$ip
return 0
}
multipass_ssh () {
cmd=$(multipass_ssh_cmd $@) || { echo failed: $cmd;return $?; }
echo ssh $cmd
ssh $cmd
}
multipass_scp () {
[[ $1 = "-u" ]] && user=$2 && shift 2 || user=ubuntu
[[ ! $1 ]] && echo must supply name of instance name && return 1
ip=$(multipass_get_ip $1)
[[ ! $ip ]] && echo "no ip for instance $1, aborting" && return
id=$(multipass_get_sshid)
cat $id
return
echo sudo scp -i $id -r $2 $user@$ip:$3
sudo scp -i $id $2 $user@$ip:$3
}
multipass_ssh_script () {
cmd=$(multipass_ssh_cmd $2) || { echo failed: $cmd;return $?; }
module_load remote
remote_script $1 "$cmd"
}

View File

@ -1,4 +0,0 @@
#!/bin/bash
command -v snap >/dev/null 2>&1 || return

View File

@ -1,4 +0,0 @@
#!/bin/bash
command -v snap >/dev/null 2>&1 || return

View File

@ -1,6 +0,0 @@
#!/bin/bash
command -v snap >/dev/null 2>&1 || return
path_append /snap/bin

View File

@ -1,5 +0,0 @@
#!/bin/bash
command -v docker >/dev/null 2>&1 || return
docker_terminal () {
docker exec -it $1 /bin/sh
}

1
docker/docker.inst Executable file
View File

@ -0,0 +1 @@
ln -s $BASH_SHELL_ANY_HOST/docker/docker $BASH_SHELL_HOST/load

View File

@ -0,0 +1,16 @@
#!/bin/bash
command -v docker >/dev/null 2>&1 || return
docker_terminal () {
docker exec -it $1 /bin/sh
}
docker_latest_image() {
image=$1
major=${2:-1}
tokenUri="https://auth.docker.io/token"
data=("service=registry.docker.io" "scope=repository:$image:pull")
token="$(curl --silent --get --data-urlencode ${data[0]} --data-urlencode ${data[1]} $tokenUri | jq --raw-output '.token')"
listUri="https://registry-1.docker.io/v2/$image/tags/list"
curl --silent --get -H "Accept: application/json" -H "Authorization: Bearer $token" $listUri \
| jq --raw-output ".tags[] | select(. | startswith(\"$major.\"))" | sort -V | sed -n \$p
}

View File

@ -1,39 +0,0 @@
#!/bin/bash
command -v docker >/dev/null 2>&1 || return
aws_docker () {
local cred
local profile
local profile_env
if [[ $1 == "--cred" ]]; then
cred=$2
shift 2
else
cred=${HOME}/.aws
fi
if [[ $1 == "--profile" ]]; then
profile=$2
shift 2
else
profile=${AWS_PROFILE}
fi
[[ ! $(cat $cred/config 2> /dev/null | grep ${profile}]) ]] && echo no profile ${profile} in $cred/config && return
[[ $profile ]] && profile_env="--env AWS_PROFILE=${profile}"
# echo credentials directory $cred
# echo using profile $profile
[[ ! -f $cred/credentials ]] && echo no credentails file at $cred/credentails && return
# echo remaining args: $@
docker run --rm -it -v ${cred}:/root/.aws --env AWS_PAGER="" ${profile_env} -v $(pwd):/aws amazon/aws-cli "$@"
}
aws_docker-update () {
docker pull amazon/aws-cli:latest
}
_alt_=$([[ $(command -v aws >/dev/null 2>&1) ]] || echo d)
alias aws${_alt_}='aws_docker'
alias aws${_alt_}-update='aws_docker_update'
unset _alt_

View File

@ -1,3 +0,0 @@
if command -v npm >/dev/null 2>&1; then
alias gterm="GNOME_TERMINAL_SCREEN='' gnome-terminal"
fi

View File

@ -1,3 +0,0 @@
#todo check for ubuntu first, need script from docker build
module_load add-ppa
add_ppa -i -c backintime -p backintime-qt ppa:bit-team/testing

View File

@ -1,7 +0,0 @@
DIR="$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
BIN=${1:-/opt/bin/bmount}
ln -s $DIR/bind-mount.sh $BIN
sudo chown root:sudo $DIR/bind-mount.sh
sudo chmod 771 $DIR/bind-mount.sh
echo "%users $HOSTNAME=(ALL) NOPASSWD:SETENV: /bin/bash $BIN" | sudo tee /etc/sudoers.d/bmount
sudo chmod 440 /etc/sudoers.d/bmount

View File

@ -1,227 +0,0 @@
#!/bin/bash
# shellcheck disable=SC2016
# set -e
# golang_install remove
# golang_ install -e m
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
}
golang_install () {
## START INSTALL
PLATFORM=$(get_platform)
if [ -z "$PLATFORM" ]; then
echo "Your operating system is not supported by this install script."
return 1
fi
module_load block
[ ! "$(module_loaded block)" ] && echo unable to load block module, exiting && return 1
module_load confirm
declare ENV_TYPE="u" # Which shell repo for the block
declare ENV_FILE # override shell repo location
# u=user h=host n=network b=base
# by default it is installed in userspace
# local versions of these
declare goroot
declare gopath
local force
declare OPTION
declare OPTARG
declare OPTIND
while getopts 're:f:r:p:' OPTION; do
# echo $OPTION $OPTARG
case "$OPTION" in
r)
force=true
;;
f)
ENV_FILE=$OPTARG
echo explicing setting block to $ENV_FILE
;;
e)
ENV_TYPE=$OPTARG
echo
;;
r)
goroot=$OPTARG
echo setting root $goroot
;;
p)
gopath=$OPTARG
echo setting path $gopath
;;
*)
echo unknown option $OPTION
;;
esac
done
shift $(( OPTIND - 1 ))
if [[ ! $ENV_FILE ]]; then
FILE=lang/go
case $ENV_TYPE in
# h=host m=machine n=network b=base
"h")
[[ -d $BASH_SHELL_HOST/$(hostname) ]] && ENV_FILE=$BASH_SHELL_HOST/$(hostname)/$FILE
;&
"m")
[[ -d $BASH_SHELL_HOST/all ]] && ENV_FILE=$BASH_SHELL_HOST/all/$FILE
;&
"n")
([[ -d $BASH_SHELL_NETWORK/$NETWORKNAME ]] && [[ ! $ENV_FILE ]]) && ENV_FILE=$BASH_SHELL_NETWORK/$NETWORKNAME/$FILE
;&
"b")
([[ -d $BASH_SHELL_BASE ]] && [[ ! $ENV_FILE ]]) && ENV_FILE=$BASH_SHELL_BASE/$FILE
;;
esac
[[ ! $ENV_FILE ]] && ENV_FILE=$HOME/.bashrc # default is userspace
ENV_TYPE="u"
fi
if [[ ! $goroot ]]; then
goroot=$GOROOT
if [[ ! $goroot ]]; then
[[ $ENV_TYPE = "u" ]] && goroot="$HOME/go" || goroot="/opt/go"
fi
fi
if [[ ! $gopath ]]; then
gopath=$GOPATH
if [[ ! $gopath ]]; then
[[ $ENV_TYPE = "u" ]] && gopath="$HOME/go/apps" || gopath="/opt/go/apps"
fi
fi
echo --- go environment settings are -----
echo GOROOT: $goroot
echo GOPATH: $gopath
echo ---------------------------------------
goenv=('export GOROOT='"$goroot"'\n'
'export PATH=$PATH:'"$goroot"'/bin\n'
'export GOPATH='"$gopath"'\n'
'export PATH=$PATH:'"$gopath"'/bin')
echo ==== envionrment block is ====
printf "${goenv[*]}\n"
echo =========================================
echo environment block file is $ENV_FILE
confirm Do you want to continue || return 1
set_block -f $ENV_FILE -n "Go Language Environment"
if [[ $1 = remove ]]; then
confirm Do you really want to remove the go installation? || return 1
remove_block
confirm Delete directory $gopath??? && rm -rf $gopath
confirm Delete directory $goroot??? && rm -rf $goroot
return 1
fi
# the github api doesn't show any release records to had to grab this way
VERSION=$(echo "$(wget -qO- https://github.com/golang/go/tags)" | sed -e 's/<[^>]*>//g'| sed '/^\s*$/d'| grep release-branch| awk '{ print $2 }'|grep -v runtime|sort -V|tail -1|cut -c 3-)
if [[ $(which go) ]]; then
INSTALLED_VERSION=$(echo $(go version)| awk '{print $3}' | cut -c 3-)
# INSTALLED_VERSION=1.15.2 # this is for testing, comment out for production
echo installed: $INSTALLED_VERSION available: $VERSION
if [ "$INSTALLED_VERSION" == "$VERSION" ]; then
if [[ ! $force ]]; then
echo Installed Version $INSTALLED_VERSION is current nothing to do, exiting
echo use -r flag to force reinstall
return 2
fi
fi
fi
if [ -d "$goroot" ]; then
echo "The Go install directory ($goroot) already exists. "
confirm Do you want to upgrade to $VERSION? || return 0
fi
echo installing version $VERSION ......
PACKAGE_NAME="go$VERSION.$PLATFORM.tar.gz"
TEMP_DIRECTORY=$(mktemp -d)
echo "Downloading $PACKAGE_NAME ..."
if hash wget 2>/dev/null; then
wget https://storage.googleapis.com/golang/$PACKAGE_NAME -O "$TEMP_DIRECTORY/go.tar.gz"
else
curl -o "$TEMP_DIRECTORY/go.tar.gz" https://storage.googleapis.com/golang/$PACKAGE_NAME
fi
if [ $? -ne 0 ]; then
echo "Download failed! Exiting."
return 1
fi
echo "Extracting File..."
mkdir -p "$goroot"
# TODO set correct permissions here if necessary
sudo tar -C "$goroot" --strip-components=1 -xzf "$TEMP_DIRECTORY/go.tar.gz"
echo done installing go binary and support files
rm -rf $TEMP_DIRECTORY
echo making go workspace directories
mkdir -p "${gopath}/"{src,pkg,bin}
# TODO set correct permission if all have access
echo "Configuring GO environment in: $ENV_FILE"
mkdir -p "$(dirname $ENV_FILE)"
touch "$ENV_FILE"
add_block
block_add_line "${goenv[*]}"
# echo ---------contents of $ENV_FILE------------------
# cat $ENV_FILE
# echo ------------------------------------------------
echo -e "\nGo $VERSION was installed into $goroot.\n(re)start a new shell environment to take effect"
echo NOTE: all files have root:root user:group, run a chown/chmod/setfacl commands if need be
return 0
}

View File

@ -1,142 +0,0 @@
#!/bin/bash
hugo_install() {
# inspried from this forum post https://discourse.gohugo.io/t/script-to-install-latest-hugo-release-on-macos-and-ubuntu/14774/10
# if you have run into github api anonymous access limits which happens during debugging/dev then add user and token here or sourced from a separate file
# . ~/githubapitoken
#GITHUB_USER=""
#GITHUB_TOKEN=""
if [ "$GITHUB_TOKEN" != "" ]; then
echo using access token with script
echo $GITHUB_USER $GITHUB_TOKEN
fi
EXTENDED=false
FORCE=false
EFILE=""
# options
# e - download and install the extended version
# c - use 'hugoe' as the install command for extended version otherwise 'hugo' will launch extended version
# f - force download/overwrite of same version
declare OPTION
declare OPTARG
declare OPTIND
while getopts 'ecf' OPTION; do
case "$OPTION" in
e)
echo "installing extended hugo"
EXTENDED=true
;;
c)
if [ $EXTENDED = true ]; then
EFILE="e"
echo using hugoe for extended command
fi
;;
f)
echo "FORCING download/overwrite"
FORCE=true
;;
esac
done
shift $((OPTIND - 1))
DEFAULT_BIN_DIR="/usr/local/bin"
# Single optional argument is directory in which to install hugo
BIN_DIR=${1:-"$DEFAULT_BIN_DIR"}
BIN_PATH="$(which hugo$EFILE)"
declare -A ARCHES
ARCHES=(["arm64"]="ARM64" ["aarch64"]="ARM64" ["x86_64"]="64bit" ["arm32"]="ARM" ["armhf"]="ARM")
ARCH=$(arch)
if [ -z "${ARCHES[$ARCH]}" ]; then
echo Your machine kernel architecture $ARCH is not supported by this script, aborting
exit 1
fi
INSTALLED="$(hugo$EFILE version 2>/dev/null | cut -d'v' -f2 | cut -c 1-6)"
CUR_VERSION=${INSTALLED:-"None"}
# echo $(curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep tag_name)
# NEW_VERSION="$(curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohugoio/hugo/releases/latest \
# | grep tag_name \
# | cut -d'v' -f2 | cut -c 1-6)"
NEW_VERSION=$(lastversion hugo)
echo "Hugo $([ $EXTENDED == true ] && echo "Extended"): Current Version : $CUR_VERSION => New Version: $NEW_VERSION"
# if [ -z "$NEW_VERSION" ]; then
# echo Unable to retrieve new version number - Likely you have reached github anonymous limit
# echo set environment variable $($GITHUB_USER) and $($GITHUB_TOKEN) and try again
# exit 1
# fi
[[ $NEW_VERSION = $CUR_VERSION ]] && [[ $FORCE = false ]] && echo Latest version already installed at $BIN_PATH && return 0
pushd /tmp/ >/dev/null
# curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohug#oio/hugo/releases/latest |
# grep "browser_download_url.*hugo.*._Linux-${ARCHES[$ARCH]}\.tar\.gz" |
URL=$(
lastversion hugo --format assets --filter Linux-${ARCHES[$ARCH]}\.tar\.gz |
if [ $EXTENDED = true ]; then
grep "_extended"
else
grep -v "_extended"
fi
# |
# cut -d ":" -f 2,3 |
# tr -d \"
)
echo $URL
echo "Installing version $NEW_VERSION $([ $EXTENDED == true ] && echo "Extended") "
echo "This machine's architecture is $ARCH"
echo "Downloading Tarball $URL"
wget --user=-u $GITHUB_USER --password=$GITHUB_TOKEN -q $URL
TARBALL=$(basename $URL)
# TARBALL="$(find . -name "*Linux-${ARCHES[$ARCH]}.tar.gz" 2>/dev/null)"
echo Expanding Tarball, $TARBALL
tar -xzf $TARBALL hugo
chmod +x hugo
if [ -w $BIN_DIR ]; then
echo "Installing hugo to $BIN_DIR"
mv hugo -f $BIN_DIR/hugo$EFILE
else
echo "installing hugo to $BIN_DIR (sudo)"
sudo mv -f hugo $BIN_DIR/hugo$EFILE
fi
rm $TARBALL
popd >/dev/null
echo Installing hugo $([ $EXTENDED == true ] && echo "extended") as hugo$EFILE
BIN_PATH="$(which hugo$EFILE)"
if [ -z "$BIN_PATH" ]; then
printf "WARNING: Installed Hugo Binary in $BIN_DIR is not in your environment path\nPATH=$PATH\n"
else
if [ "$BIN_DIR/hugo$EFILE" != "$BIN_PATH" ]; then
echo "WARNING: Just installed Hugo binary hugo$EFILE to, $BIN_DIR , conflicts with existing Hugo in $BIN_PATH"
echo "add $BIN_DIR to path and delete $BIN_PATH"
else
echo "--- Installation Confirmation ---"
printf "New Hugo binary version at $BIN_PATH is\n $($BIN_PATH version)\n"
fi
fi
}

View File

@ -1,53 +0,0 @@
#!/bin/bash
# module to load some remote desktop server
tigervnc_install () {
local usesudo
[[ $EUID -ne 0 ]] && usesudo=sudo
pass=$1
[[ ! $pass ]] && echo password argument required && return 1
# TODO check for binary and if not go grab it
user=$2
[[ $usesudo ]] && user=${user:-$USER} || user=${user:-$(getent passwd 1000 | cut -f 1 -d ":")}
echo creating password file with $pass for user $user
echo "=========================="
mkdir /home/$user/.vnc
echo $pass | vncpasswd -f > /home/$user/.vnc/passwd
chown -R $user:$user /home/$user/.vnc
chmod 0600 /home/$user/.vnc/passwd
ls -la /home/$user/.vnc/
server=/bin/x0vncserver
# server=/bin/vncserver
service=/etc/systemd/system/tigervnc.service
machine=$(hostname | tr '[:lower:]' '[:upper:]')
echo creating systemd service $service
cat <<EOF | $usesudo tee $service
[Unit]
# https://tigervnc.org/doc/x0vncserver.html
Description=tigervnc remote desktop server
After=multi-user.target
[Service]
Type=simple
# User=${user}
Environment="XAUTHORITY=/var/run/lightdm/root/:0"
Environment="HOME=/home/${user}"
# Environment="USER=${user}"
# -desktop $machine
ExecStart=$server -display :0 -rfbauth /home/${user}/.vnc/passwd
# -localhost no
# Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
cat $service
[[ ! $(cat $service 2>/dev/null) ]] && echo unable to create service file && return 2
$usesudo systemctl daemon-reload
$usesudo systemctl restart tigervnc
$usesudo systemctl enable tigervnc
$usesudo systemctl status tigervnc
}

View File

@ -1,59 +0,0 @@
#!/bin/bash
ungoogled_install() {
module_load confirm
module_load helpers
SDIR=$(adirname ${1:-$(dirname ${BASH_SOURCE[0]})})
if [[ ! $(which lastversion) ]]; then
echo lastversion is not installed
echo it is a required dependency for this script
echo see https://github.com/dvershinin/lastversion
return
fi
CUR_VERSION=$( /usr/bin/chromium -version | grep -oP '(?<=Chromium )[^ ]*')
_repo="Eloston/ungoogled-chromium-binaries"
NEW_VERSION=$(lastversion ${_repo})
echo "Ungoogled: Current Version : $CUR_VERSION => New Version: $NEW_VERSION"
[[ $NEW_VERSION = $CUR_VERSION ]] && [[ ! ${1} == "-f" ]] && echo Latest version is already installed
_temp=/tmp/ungoogled_chromium
echo $_temp to download deb and install
mkdir -p $_temp || exit &> /dev/null
pushd $_temp &> /dev/null || exit
echo downloading common deb
lastversion ${_repo} --format assets --filter common_ -d common.deb
lastversion ${_repo} --format assets --filter mium_.+amd64.deb -d chromium.deb
echo installing common libraries
sudo dpkg -i common.deb
echo installing ungoogled-chromium
sudo dpkg -i chromium.deb
echo done installing, removing $_temp
rm -r $_temp &> /dev/null || true
popd >/dev/null
confirm "do you want to install WidevineCDM for digital streaming rights?"
if [ $? -eq 0 ]; then
module_load widevine-install
widevine_install
fi
confirm "do you want to install the uci chromium start script in /opt/bin ?"
if [ $? -eq 0 ]; then
module_load chromium-install
chromium_install
fi
}
# # if script was executed then call the function
(return 0 2>/dev/null) || ungoogled_install $@

View File

@ -1,71 +0,0 @@
#!/bin/bash
# -eux
function confirm()
{
echo -n "$@ "
read -e answer
for response in y Y yes YES Yes Sure sure SURE OK ok Ok
do
if [ "_$answer" == "_$response" ]
then
return 0
fi
done
# Any answer other than the list above is considered a "no" answer
return 1
}
function widevine_install {
_chrome_ver=$( /usr/bin/chromium -version | grep -oP '(?<=Chromium )[^ ]*')
_l_target_dir=~/.local/lib/WidevineCdm
_target_dir=/usr/lib/chromium/WidevineCdm
_sudo="sudo"
if [[ "${1}" == "-l" ]]; then
_sudo=""
_target_dir=$_l_target_dir
shift
fi
echo "install widevineCDM for chromium version $_chrome_ver"
echo "into $_target_dir"
confirm "confirm (y/n)" || exit
_temp=/tmp/chromium_widevine
echo using $_temp to download deb and extract widevine
mkdir -p $_temp || exit &> /dev/null
pushd $_temp &> /dev/null || exit
# Download deb, which has corresponding Widevine version
# Support resuming partially downloaded (or skipping re-download) with -c flag
if [[ "${1}" == "-u" ]]; then
_un="un"
fi
_url=https://dl.google.com/linux/deb/pool/main/g/google-chrome-${_un}stable/google-chrome-${_un}stable_${_chrome_ver}-1_amd64.deb
echo downloading $_url
wget -c $_url || exit
# Unpack deb
rm -r unpack_deb &> /dev/null || true
mkdir -p unpack_deb
echo extracting package...
dpkg-deb -R google-chrome-stable_${_chrome_ver}-1_amd64.deb unpack_deb || exit
echo removing any old WidevineCDM installs at $_target_dir
$_sudo rm -r $_target_dir &> /dev/null || true
echo moving WidevineCDM to target $_target_dir
$_sudo mv unpack_deb/opt/google/chrome/WidevineCdm $_target_dir &> /dev/null || exit
[[ $_sudo ]] && $_sudo chown -R root:root $_target_dir
echo done, removing $_temp
rm -r $_temp &> /dev/null || true
popd &> /dev/null
}
# if script was executed then call the function
(return 0 2>/dev/null) || widevine_install $@

View File

@ -1,33 +0,0 @@
#!/usr/bin/env bash
# https://raw.githubusercontent.com/flathub/com.github.Eloston.UngoogledChromium/master/widevine-install.sh
# https://github.com/flathub/com.github.Eloston.UngoogledChromium
# Exit on error and forbid unset variables
set -eu
# Get latest WideVine Version by getting last line in https://dl.google.com/widevine-cdm/versions.txt
_widevine_ver="$(wget -qO- https://dl.google.com/widevine-cdm/versions.txt | tail -n1)"
# Get the architecture of the current machine
ARCH="$(uname -m)"
case "$ARCH" in
x86_64)
WIDEVINE_ARCH="x64"
CHROMIUM_ARCH="x64"
;;
*)
echo "The architecture $ARCH is not supported." >&2
exit 1
;;
esac
# Download WideVine into a temporary file and use trap to delete it on exit
widevine_zip="$(mktemp)"
trap 'rm -f "${widevine_zip:?}"' EXIT
wget -O "$widevine_zip" "https://dl.google.com/widevine-cdm/${_widevine_ver}-linux-${WIDEVINE_ARCH}.zip"
# Install WideVine from zip file into UngoogledChromium flatpak
_install_prefix="/opt/chromium/$1/WidevineCdm/${_widevine_ver}"
unzip -p "$widevine_zip" libwidevinecdm.so | install -Dm644 "/dev/stdin" "${_install_prefix}/_platform_specific/linux_$CHROMIUM_ARCH/libwidevinecdm.so"
unzip -p "$widevine_zip" manifest.json | install -m644 "/dev/stdin" "${_install_prefix}/manifest.json"
unzip -p "$widevine_zip" LICENSE.txt | install -m644 "/dev/stdin" "${_install_prefix}/LICENSE.txt"

View File

@ -1,6 +0,0 @@
#!/bin/bash
if [[ $(command -v code) ]]; then
export VSCODE_HOME="/opt/vscode"
chmod +x $BASH_SHELL_HOST/all/modules/vscode.sh
ln -sf $BASH_SHELL_HOST/all/modules/vscode.sh /opt/bin/vscode
fi

View File

@ -1,12 +0,0 @@
#!/bin/bash
log=$HOME/.session/session.log
&>> $log
echo $USER $HOME
echo "lightdm login setup $(date)"
# example commands to run when logging in, here binding some other directories for the user
#echo "binding chromium browsers to .browsers"
#/usr/bin/bindfs --map=sysadmin/$USER:@users/@$USER /opt/chromium/default $HOME/.browsers/default
# bind alternate downloads directory
#/usr/bin/bindfs --map=sysadmin/$USER:@users/@$USER /data/downloads $HOME/Downloads

View File

@ -1,9 +0,0 @@
#!/bin/bash
log=$HOME/.session/session.log
&>> $log
echo $USER $HOME
echo "lightdm logout cleanup $(date)"
# example complimentary cleanup here unmounting those mounted in session_login
#echo "un mounting chromium browsers from .browsers"
#/bin/fusermount -u $HOME/.browsers/default
#/bin/fusermount -u $HOME/Downloads

View File

@ -1,3 +0,0 @@
#!/bin/bash
# run the session login script manually, used for debugging
sudo -E HOME=$HOME USER=$USER ./session_login

View File

@ -1,4 +0,0 @@
#!/bin/bash
# run the session logout script manually, used for debugging
sudo -E HOME=$HOME USER=$USER /bin/bash session_logout

View File

@ -1,4 +0,0 @@
[Seat:*]
session-setup-script=/opt/session/lightdm-setup.sh
session-cleanup-script=/opt/session/lightdm-cleanup.sh

View File

@ -1,28 +0,0 @@
#!/bin/bash
function confirm()
{
echo -n "$@ "
read -e answer
for response in y Y yes YES Yes Sure sure SURE OK ok Ok
do
if [ "_$answer" == "_$response" ]
then
return 0
fi
done
# Any answer other than the list above is considered a "no" answer
return 1
}
if [[ -d $HOME/.session ]]; then
echo $HOME/.session folder already exists
confirm "!overwrite??? (y/n)" || exit
/bin/cp -r -f $HOME/.session/ $HOME/.session-saved/
echo saved copy first to $HOME/.session-saved
fi
echo copying .session from $(pwd) to $HOME
/bin/cp -r -f .session/ $HOME
echo setting execute permissions
chmod +x $HOME/.session/*

View File

@ -1,74 +0,0 @@
#!/bin/bash
loginout_install() {
module_load confirm
module_load helpers
[[ ! $(systemctl list-units | grep lightdm) ]] && echo lightdm not running on this machine, aborting && return
SDIR=$(adirname "${BASH_SOURCE[0]}")
# echo source directory: $SDIR
pushd $SDIR &> /dev/null || exit
[[ ! -d /etc/lightdm/lightdm.conf.d ]] && mkdir -p /etc/lightdm/lightdm.conf.d
echo copying 50-setup-cleanup.conf to /etc/lightdm/lightdm.conf.d
sudo cp -f 50-setup-cleanup.conf /etc/lightdm/lightdm.conf.d
if [[ ! -d /opt/session ]]; then
if [[ ! $(mkdir -p /opt/session) ]]; then
echo unable to make /opt/session with user $USER, elevating to sudo
_sudo="sudo"
[[ $($_sudo mkdir -p /opt/session) ]] && echo can not make /opt/session, aborting && return
fi
fi
echo copying lightdm-cleanup.sh and lightdm-setup.sh to /opt/session
$_sudo cp -f scripts/* /opt/session
echo setting execute permissions
$_sudo chmod -R +x /opt/session/*.sh
popd >/dev/null
_user=${1:-${USER}}
confirm "add a user .session folder for $_user" && add_user_session $1
}
function add_user_session {
module_load confirm
module_load helpers
SDIR=$(adirname "${BASH_SOURCE[0]}")
# echo source directory: $SDIR
pushd $SDIR &> /dev/null || exit
_user=${1:-${USER}}
[[ ! $(user_exists $_user) ]] && echo user $_user does not exist, aborting && return
_home=$(bash -c "cd ~$(printf %q $_user) && pwd")
echo making $_home/.session folder for $_user
# mkdir $USER/.session
sudo -H -E -u "$_user" -s /bin/bash cpy.session.sh
popd >/dev/null
# confirm "do you want to install WidevineCDM for digital streaming rights?"
# if [ $? -eq 0 ]; then
# module_load widevine-install
# widevine_install
# fi
}
# if script was executed then call the function
(return 0 2>/dev/null) || loginout_install $@

View File

@ -1,51 +0,0 @@
Lightdm (gdm) is the login manager for linux ubuntu and mint (by default)
If you need setup and cleanup that is ONLY done at lightdm login/logout then
one can run a script to setup and cleanup the session by
running the loginout-install script, requires sudo
`module_load loginout-install; loginout_install <user>` # default is current user
after loading common scripts this will ask if you want to add the .session folder for the user
or if you just need to add a user .session folder afterward
`module_load loginout-install; add_user_session <user>`
the script does this
in `/etc/lightdm/lightdm.conf.d` adds a file `50-setup-cleanup.conf`
```
[Seat:*]
session-cleanup-script=/opt/scripts/lightdm-cleanup.sh
session-setup-script=/opt/scripts/lightdm-setup.sh
```
in /opt/scripts put two files below and make sure they are +x executable
```
#!/bin/bash
#lightdm-setup.sh
echo "setup for ${USER}:${HOME} $(date)" >> /opt/scripts/lightdm.log
log=${HOME}/.session.log
if [[ -e $HOME/.session_login ]]; then su -c "/bin/bash $HOME/.session_login 1>>${log} 2>>${log} || true" $USER; fi
```
```
#!/bin/bash
#lightdm-cleanup.sh
echo "cleanup for ${USER}:${HOME} $(date)" >> /opt/scripts/lightdm.log
log=${HOME}/.session.log
if [[ -e $HOME/.session_logout ]]; then su -c "/bin/bash $HOME/.session_logout 1>>${log} 2>>${log} || true" $USER; fi
```
then in the user home puts
`.session_login` and `.session_logout` files both executable
in those you can do anything like bindfs and fusermount -u
make sure you restart lightdm or reboot
`sdr lightdm`

View File

@ -1,9 +0,0 @@
#!/bin/bash
_udir=${HOME}/.session
_uscript=${_udir}/session_logout
_log=${_udir}/session.log
_sdir=$(dirname "${BASH_SOURCE[0]}")
echo "${UID:-$(id -u)}:$(whoami) is running CLEANUP script in $_sdir for ${USER} sourcing ${_uscript}::$(date)" >> ${_sdir}/lightdm.log
if [[ -e ${_uscript} ]]; then
/bin/bash ${_uscript} 1>>${_log} 2>>${_log} || true
fi

View File

@ -1,9 +0,0 @@
#!/bin/bash
_udir=${HOME}/.session
_uscript=${_udir}/session_login
_log=${_udir}/session.log
_sdir=$(dirname "${BASH_SOURCE[0]}")
echo "${UID:-$(id -u)}:$(whoami) is running SETUP script in $_sdir for ${USER} sourcing ${_uscript}::$(date)" >> ${_sdir}/lightdm.log
if [[ -e ${_uscript} ]]; then
/bin/bash ${_uscript} 1>>${_log} 2>>${_log} || true
fi

View File

@ -1,7 +0,0 @@
# Install scripts for a new host machine
each file or folder in this directory can load another asset to a new host machine
the install_host function can be loaded which will allow easy install of these assets

1
lang/fnm/00-fnm.env Normal file
View File

@ -0,0 +1 @@
export FNM_DIR="/opt/node-fnm"

25
lang/fnm/fnm Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
if command -v fnm >/dev/null 2>&1; then
_fnmenv="$(fnm env --fnm-dir $FNM_DIR --use-on-cd)"
# echo "$_fnmenv"
# echo "---------"
eval "$_fnmenv"
if ! fnm use lts-latest >/dev/null 2>&1; then
echo the latest long term support version is not installed so installing
fnm install --lts
fvm use lts-lastest
echo current active version $(node --version)
fi
alias fnml="fnm use lts-latest"
# alias nvmil="nvm install --lts --latest-npm"
alias fnmu="fnm use"
alias fnmls="fnm ls"
alias fnmc="fnm current"
# echo added fnm to shell, $NVM_DIR
else
echo FATAL! fnm is not installed or in the path cannot add node via fnm to shell
fi

9
lang/fnm/fnm.inst Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
if command -v fnm >/dev/null 2>&1; then
mkdir -p $BASH_SHELL_HOST/load/coding
ln -s $BASH_SHELL_ANY_HOST/lang/fnm $BASH_SHELL_HOST/load/coding/00-fnm
ln -s -f $BASH_SHELL_ANY_HOST/lang/node $BASH_SHELL_HOST/load/coding/node
else
echo fnm has not been installed on this machine or is not in the path
echo do so and try again
fi

2
lang/fnm/fnm.uinst Executable file
View File

@ -0,0 +1,2 @@
rm -r $BASH_SHELL_HOST/load/coding/00-fnm
rm -r $BASH_SHELL_HOST/load/coding/node

View File

@ -1,11 +1,6 @@
#!/bin/bash
go_install () {
local latest_url="https://go.dev/VERSION?m=text"
## START INSTALL
@ -24,9 +19,12 @@ declare OPTION
declare OPTARG
declare OPTIND
while getopts 'fr:' OPTION; do
while getopts 'fv:r:' OPTION; do
# echo $OPTION $OPTARG
case "$OPTION" in
v)
VERSION=$OPTARG
;;
f)
force=true
;;
@ -65,7 +63,7 @@ echo go install and environment will be
printf "${goenv[*]}\n"
confirm Do you want to continue || return 1
VERSION=$(curl -s $latest_url | sed 's/^go//')
VERSION=${VERSION:-$(curl -s $latest_url | sed 's/^go//')}
if [[ $(which go) ]]; then
INSTALLED_VERSION=$(echo $(go version)| awk '{print $3}' | cut -c 3-)
# INSTALLED_VERSION=1.15.2 # this is for testing upgrade, comment out for production
@ -77,7 +75,7 @@ if [[ $(which go) ]]; then
return 2
fi
fi
confirm Do you want to upgrade || return 1
confirm Do you want to install || return 1
fi
echo installing version $VERSION ......

View File

@ -1,9 +1,7 @@
#!/bin/bash
if command -v node >/dev/null 2>&1; then
if command -v npm >/dev/null 2>&1; then
alias ndv="node --version"
alias ndw="command -v node"
path_append ./node_modules/.bin
# load in any node functions
module_load node
fi
fi

2
lang/node/node.sh → lang/node/node.lib Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/bin/bash
module_load confirm
rm_node_modules () {

View File

@ -1,5 +1,6 @@
#!/bin/bash
# echo loading npm aliasg
# command -v npm
if command -v npm >/dev/null 2>&1; then
# echo addding node langauge stuff
# gives access to packages with bin in a project

1
lang/node/readme.md Normal file
View File

@ -0,0 +1 @@
this gets loaded via one of the version managers (nvm,fnm,proto)

2
lang/nvm/00-nvm.env Normal file
View File

@ -0,0 +1,2 @@
export NVM_DIR="/opt/node-nvm"
export NVM_SCRIPTS_DIR="/usr/share/nvm"

22
lang/nvm/nvm Normal file
View File

@ -0,0 +1,22 @@
#!/bin/bash
echo adding nvm to shell
if [[ -f $NVM_SCRIPTS_DIR/init-nvm.sh ]]; then
mkdir -p $NVM_DIR
source $NVM_SCRIPTS_DIR/init-nvm.sh
fi
if command -v nvm >/dev/null 2>&1; then
# echo node version manager installed $NVM_DIR
if ! nvm use --lts >/dev/null 2>&1; then
echo a long term support version is not installed so installing $(nvm version-remote --lts)
nvm install --lts --latest-npm
nvm use --lts
echo current active version $(node --version)
fi
alias nvml="nvm use --lts"
alias nvmil="nvm install --lts --latest-npm"
alias nvmu="nvm use"
alias nvmls="nvm ls"
fi

3
lang/nvm/nvm.inst Executable file
View File

@ -0,0 +1,3 @@
mkdir -p $BASH_SHELL_HOST/load/coding
ln -s $BASH_SHELL_ANY_HOST/lang/nvm $BASH_SHELL_HOST/load/coding/00-nvm
ln -s -f $BASH_SHELL_ANY_HOST/lang/node $BASH_SHELL_HOST/load/coding/node

2
lang/nvm/nvm.uinst Executable file
View File

@ -0,0 +1,2 @@
rm -r $BASH_SHELL_HOST/load/coding/00-nvm
rm -r $BASH_SHELL_HOST/load/coding/node

13
lang/proto/proto Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
if command -v proto >/dev/null 2>&1; then
export PROTO_HOME=/opt/coding
mkdir -p $PROTO_HOME/shims
mkdir -p $PROTO_HOME/bin
module_load system-path
path_append "$PROTO_HOME/shims"
path_append "$PROTO_HOME/bin"
fi

3
lang/proto/proto.inst Executable file
View File

@ -0,0 +1,3 @@
mkdir -p $BASH_SHELL_HOST/load/coding
ln -s $BASH_SHELL_ANY_HOST/lang/proto $BASH_SHELL_HOST/load/coding/00-proto
ln -s $BASH_SHELL_ANY_HOST/lang/node $BASH_SHELL_HOST/load/coding/node

2
lang/proto/proto.uinst Executable file
View File

@ -0,0 +1,2 @@
rm -r $BASH_SHELL_HOST/load/coding/00-proto
rm -r $BASH_SHELL_HOST/load/coding/node

View File

@ -1,45 +0,0 @@
#!/bin/bash
function bumount {
echo "removing bind mount at $1"
notify-send "removing bind mount at ${1}" --icon=dialog-information -t 2000
fusermount -u "$1"
}
function bmount {
if [ "$1" == "-d" ]; then
bumount $2
else
# if [[ " ${array[@]} " =~ " ${value} " ]]; then
# # whatever you want to do when array contains value
# fi
# mp="${@: -2}"
echo mounting $@
bindfs $@
fi
}
# must have fuser and bindfs installed
# for use by sudoers
# ln -s $BASH_SHELL_HOST/all/modules/bind-mount/bind-mount.sh /opt/bin/bmount
# function xxbmount () {
# if [ "$1" == "-mp" ]; then
# MOUNTED=$(mountpoint "$2" | grep not)
# if [ -z "$MOUNTED" ]; then
# echo $2 is a mount point so bind mounting $2/$3 to $4
# notify-send "bind mounting ${2}/${3} to ${4}" --icon=dialog-information -t 2000
# bindfs "$2/$3" "$4"
# else
# notify-send "${2} not a mount point - Unable to bind mount ${2}/${3} to ${4}" --icon=dialog-error -t 2000
# fi
# else
# echo bind mounting $1 to $2
# notify-send "bind mounting ${1} to ${2}" --icon=dialog-information -t 2000
# bindfs "$1" "$2"
# fi
# }
# if script was executed then call the function
(return 0 2>/dev/null) || bmount $@

View File

@ -1,99 +1,101 @@
#!/bin/bash
#bmount () {}
# sudo bindfs -o allow_other -o map=root/1001:@root/@1001 /var/lib/docker/volumes /data/dvols
# echo loading bindfs
export BFS_MOUNT_DIR=${BFS_MOUNT_DIR:-/mnt/bfs}
if [ -v PS1 ]; then
alias drbu="dir_rebind_user"
alias dbu="dir_bind_user"
alias dbum="dir_bind_unmount"
alias rbfsu="dir_rebind_user"
alias rbfs="dir_rebind"
alias bfsu="dir_bind_user"
alias bfs="dir_bind"
alias bfsum="dir_bind_unmount"
alias bfse="bfs_vscode"
sudo mkdir $BFS_MOUNT_DIR 2> /dev/null
sudo chown $USER:$USER $BFS_MOUNT_DIR
fi
dir_rebind_user () {
local usesudo; local dir;local user;local group
# $1 new owner
# $2 dir
[ $# -lt 2 ] && echo minimum args needed to rebind are user and directory && return 1
[[ $EUID -ne 0 ]] && usesudo=sudo
[[ $(id -u $1 2> /dev/null) ]] || { echo user $1 does not exist can not continue; return 2; }
dir=$(realpath $2)
user=$(stat -c '%U' $dir)
group=$(stat -c '%G' $dir)
$usesudo bindfs --force-user=$1 --force-group=$1 --create-for-user=$user --create-for-group=$group --chown-ignore --chgrp-ignore $dir $dir
# echo use \'dir_rebind_user_remove $dir\' to remove
mounted () {
mountpoint "$1" &> /dev/null && echo yes || return 1
}
dir_bind_unmount () {
local usersudo
local usesudo
local mp=$1
[[ ! $(mounted $mp) ]] && echo no mountpoint at $mp && mp=$BFS_MOUNT_DIR/$(basename $mp)
[[ ! $(mounted $mp) ]] && echo no mountpoint at $mp either, aborting && return 1
[[ $EUID -ne 0 ]] && usesudo=sudo
$usesudo fusermount -u $1
if $usesudo fusermount -u $mp; then
echo unmounted $mp, removing empty mountpoint directory
rm -rf $mp
else
echo error, unable to unmount $mp
fi
}
dir_bind_user () {
local usesudo; local dir;local user;local group;local mp
[ $# -lt 3 ] && echo minimum 3 args needed to rebind are user, source directory and mountpoint && return 1
if [ $# -lt 3 ]; then
echo "minimum 3 args needed to rebind <user? <source dir> <mountpoint>"
echo passed were $@
return 1
fi
[[ $EUID -ne 0 ]] && usesudo=sudo
[[ $(id -u $1 2> /dev/null) ]] || { echo user $1 does not exist can not continue; return 2; }
dir=$(realpath $2)
mp=$3
[[ $(mounted $mp) ]] && echo something already mounted at $mp, aborting && return 1
if ! $usesudo mkdir -p $mp; then echo unable to make mountpoint aborting; return 2; fi
$usesudo chown $1:$1 $mp
user=$(stat -c '%U' $dir)
group=$(stat -c '%G' $dir)
user=$(stat -c '%u' $dir)
group=$(stat -c '%g' $dir)
$usesudo bindfs --force-user=$1 --force-group=$1 --create-for-user=$user --create-for-group=$group --chown-ignore --chgrp-ignore $dir $mp
# echo use \'dir_rebind_user_remove $dir\' to remove
[[ $? -gt 0 ]] && echo error in call to bindfs
if [[ $(mounted $mp) ]]; then
echo $dir has been mounted at $mp for user $1
echo "to unmount use: dir_bind_unmount $mp or bfsum $mp"
else
echo unable to mount $dir at $mp as user $user
fi
}
dir_bind () {
mp=${2:-$BFS_MOUNT_DIR/$(basename $1)}
dir_bind_user $USER $1 $mp
if [ -v PS1 ]; then
echo enter \"u\" when you ready to unmount, otherwise any other key will leave mounted
read -n1 ans
echo -e "\n"
[[ $ans == "u" ]] && dir_bind_unmount $mp
fi
}
# module_load bindfs && dir_bind_user david /mnt/datadrive/@images /data/images
dir_rebind () {
dir_bind_user $USER $1 $1
}
dir_rebind_user () {
dir_bind_user $1 $2 $2
}
bfs_vscode () {
mp=${2:-$BFS_MOUNT_DIR/$(basename $1)}
dir_bind_user $USER $1 $mp
/opt/bin/vscode $mp
if [ -v PS1 ]; then
echo when you ready to unmount FIRST close your vscode window then enter \"u\"
echo otherwise any other key will leave mounted
read -n1 ans
echo -e "\n"
[[ $ans == "u" ]] && dir_bind_unmount $mp
fi
}
(return 0 2>/dev/null) || dir_bind_user $@
# function bumount {
# echo "removing bind mount at $1"
# notify-send "removing bind mount at ${1}" --icon=dialog-information -t 2000
# fusermount -u "$1"
# }
# function bmount {
# if [ "$1" == "-d" ]; then
# bumount $2
# else
# if [[ " ${array[@]} " =~ " ${value} " ]]; then
# # whatever you want to do when array contains value
# fi
# mp="${@: -2}"
# echo mounting $@
# bindfs $@
# fi
# }
# must have fuser and bindfs installed
# for use by sudoers
# ln -s $BASH_SHELL_HOST/all/modules/bind-mount/bind-mount.sh /opt/bin/bmount
# function xxbmount () {
# if [ "$1" == "-mp" ]; then
# MOUNTED=$(mountpoint "$2" | grep not)
# if [ -z "$MOUNTED" ]; then
# echo $2 is a mount point so bind mounting $2/$3 to $4
# notify-send "bind mounting ${2}/${3} to ${4}" --icon=dialog-information -t 2000
# bindfs "$2/$3" "$4"
# else
# notify-send "${2} not a mount point - Unable to bind mount ${2}/${3} to ${4}" --icon=dialog-error -t 2000
# fi
# else
# echo bind mounting $1 to $2
# notify-send "bind mounting ${1} to ${2}" --icon=dialog-information -t 2000
# bindfs "$1" "$2"
# fi
# }

View File

@ -25,6 +25,12 @@ btrbk_conf () {
return 1
}
btrbk_clean () {
local file=$(btrbk_conf $1)
[[ ! $file ]] && return 1
sudo btrbk -c $file clean $2
}
btrbk_src () {
local file=$(btrbk_conf $1)
[[ ! $file ]] && return 1
@ -86,17 +92,19 @@ local snaps=$(sudo btrbk -c $file list source --format col:h:snapshot_name)
local dests=$(sudo btrbk -c $file list config --format col:h:snapshot_path | tail -1)
local dests+=" $(btrbk -c $file list target --format col:h:target_path)"
# todo distinguish local from remote destinations and deal with differently for latest link
# any pre snap tasks
for dest in $dests; do
if [[ ! -d $dest ]]; then
if confirm directory $dest does not exist, create; then
sudo mkdir -p $dest
else
echo destination $dest directory MUST exist aborting brtbk run
return 2
fi
fi
done
# for dest in $dests; do
# if [[ ! -d $dest ]]; then
# if confirm directory $dest does not exist, create; then
# sudo mkdir -p $dest
# else
# echo destination $dest directory MUST exist aborting brtbk run
# return 2
# fi
# fi
# done
echo using configuration file: $file
echo creating snapshots: $snaps

View File

@ -4,34 +4,31 @@ arch () {
uname -m
}
function get_chip_type() {
get_arch () {
local arch
arch=$(uname -m)
[[ ! $arch ]] && return 1
case $arch in
x86_64) binArch='amd64' ;;
armhf) binArch='armv6' ;;
armv7) binArch='armv7' ;;
aarch64) binArch='arm64' ;;
ppc64el|ppc64le) binArch='ppc64le' ;;
s390x) binArch='s390x' ;;
.*386.*) binArch='amd32' ;;
*) return 2 ;;\
esac;
echo $binArch
}
local ARCH
case $(arch) in
"x86_64")
ARCH=amd64
;;
"aarch64")
ARCH=arm64
;;
"armv8")
ARCH=arm64
;;
.*386.*)
ARCH=amd32
;;
*)
ARCH=arm32
;;
esac
echo $ARCH
function get_os () {
declare -l os
os=$(uname -s)
echo $os
}
function get_platform() {
echo $(uname -s)-$(get_chip_type)
echo $(get_os)-$(get_chip_type)
}
@ -75,3 +72,22 @@ get_distro() {
fi
fi
}
# function get_distro() {
# /bin/cp /etc/os-release /tmp/os-release.tmp
# if [[ $1 == "-d" ]]; then
# shift 1
# # docker run -it --name get_container_os --rm --entrypoint cat $1 /etc/os-release
# docker create --name dummy $1 > /dev/null
# docker cp -L dummy:/etc/os-release /tmp/os-release.tmp
# docker rm -f dummy > /dev/null
# # docker run -it --name get_container_os --rm --entrypoint cat $1 /etc/os-release > /tmp/container-os.tmp 2> /dev/null
# shift 1
# fi
# source /tmp/os-release.tmp
# declare valid=${@:-"alpine debian ubuntu"}
# # echo $ID $ID_LIKE
# [[ "${valid}" =~ $ID ]] && echo $ID && return 0
# [[ "${valid}" =~ $ID_LIKE ]] && echo $ID_LIKE && return 0
# return 1
# }

0
sudoers/20-dir Normal file → Executable file
View File

1
sudoers/20-ln Normal file
View File

@ -0,0 +1 @@
%sudo, %wheel ALL=(ALL) NOPASSWD:/bin/ln

1
sudoers/20-passwd Normal file
View File

@ -0,0 +1 @@
%sudo, %wheel ALL=(ALL) NOPASSWD:/bin/passwd