reorganize and refactor host repo. Mostly now a way to install to specific host repo

master
Kebler Network System Administrator 2023-02-07 13:03:18 -08:00
parent 19dee68ea5
commit 4ad0c913b0
60 changed files with 465 additions and 266 deletions

1
.bash-shell-include Normal file
View File

@ -0,0 +1 @@
load

View File

@ -1,2 +0,0 @@
[[ -d "/opt/brew" ]] && path_append /opt/brew/bin
[[ -d /home/linuxbrew/.linuxbrew/bin ]] && path_append /home/linuxbrew/.linuxbrew/bin

2
archive/git Normal file
View File

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

5
archive/ssh.env Normal file
View File

@ -0,0 +1,5 @@
#!/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

@ -1,11 +1,12 @@
#!/bin/bash
# user to start MUST be first in arguments
# if not supplied then will use default
# improve and refactor
chromium_() {
local DEFAULT=/opt/chromium
local DEFAULT_USER=$HOME/.browsers
local DEFAULT_SNAP=$HOME/snap/chromium/common
module_load path
local path=/opt/chromium
local user_data_path=$HOME/.browsers
local snap_path=$HOME/snap/chromium/common
# set default exe here (no flag)
local exe="/usr/bin/chromium"
local snap
@ -15,7 +16,7 @@ chromium_() {
return
fi
[[ $1 == -d ]] && exe=/usr/bin/chromiium && shift
[[ $1 == -d ]] && exe=/usr/bin/chromium && shift
[[ $1 == -g ]] && exe=$(command -v google-chrome) && shift
[[ $1 == -s ]] && snap=true && exe=/snap/bin/chromium && shift
[[ $1 == -u ]] && exe=/opt/bin/ungoogled-chromium && shift
@ -40,20 +41,29 @@ chromium_() {
fi
fi
local dir
[[ ! $instance ]] && instance=chromium && unset CHROME_CONFIG_HOME
[[ $instance == "incognito" ]] && set -- "$@" "-incognito"
dir=${DEFAULT_USER}/$instance
dir=$([[ -d "$dir" ]] && echo $dir || echo "${CHROMIUM_HOME:-$DEFAULT}/$instance")
# exe="${exe/<dir>/$dir}"
if [[ $snap ]]; then
sdir=${DEFAULT_SNAP}/$instance
mkdir -p $sdir
fusermount -u $sdir
/usr/bin/bindfs $dir $sdir
dir=$sdir
fi
local dir
dir=$(isAbsPath $instance)
if [[ ! $dir ]]; then
dir=${user_data_path}/$instance
if [[ ! -d "$dir" ]]; then
dir="${CHROMIUM_HOME:-$path}/$instance"
[[ ! -d "$dir" ]] && [[ -d ${user_data_path} ]] && dir=${user_data_path}/$instance
fi
fi
if [[ $snap ]]; then
local bfs=$(command -v bindfs)
[[ ! $bfs ]] && echo bindfs not installed - exiting && return 3
sdir=${snap_path}/$instance
mkdir -p $sdir
fusermount -u $sdir
$bfs $dir $sdir
dir=$sdir
fi
mkdir -p $dir
echo $exe $@ --user-data-dir=$dir $url

View File

@ -0,0 +1,25 @@
#!/bin/bash
function chromium_install {
BASH_SHELL_HOST=${BASH_SHELL_HOST:-$(dirname $BASH_SHELL_BASE)/$(hostname)}
mkdir -p $BASH_SHELL_HOST/apps
local src
local target
local dir="$(dirname $(realpath "${BASH_SOURCE:-$0}"))"
local script=$dir/chromium.func
# todo call distro specific install
[[ ! -f $script ]] && echo can not find script chromium function $script && return 2
src=$BASH_SHELL_HOST/apps/chromium
echo installing chromium script to $src
cp $script $src
target=${1:-/opt/bin}/chromium
chmod +rx $src
ln -sf $src $target
echo link to $src created at $target
ls -la /opt/bin | grep chromium
echo with permissions
ls -la $src
}
# if script was executed then call the function
(return 0 2>/dev/null) || chromium_install $@

35
install/apps/vscode/vscode.inst Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# make generic for an app
function vscode_install {
BASH_SHELL_HOST=${BASH_SHELL_HOST:-$(dirname $BASH_SHELL_BASE)/$(hostname)}
mkdir -p $BASH_SHELL_HOST/apps
local src
local target
local dir="$(dirname $(realpath "${BASH_SOURCE:-$0}"))"
local script=$dir/vscode.func
# todo call distro specific install
[[ ! -f $script ]] && echo can not find script chromium function $script && return 2
src=$BASH_SHELL_HOST/apps/vscode
echo installing vscode to $src
cp $script $src
target=${1:-/opt/bin}/vscode
chmod +rx $src
ln -sf $src $target
echo link to $src created at $target
ls -la /opt/bin | grep vscode
echo with permissions
ls -la $src
}
code_install_deb() {
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -sudo apt update
sudo apt install code # or code-insiders
}
# if script was executed then call the function
(return 0 2>/dev/null) || vscode_install $@

View File

@ -0,0 +1,3 @@
#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

@ -0,0 +1,53 @@
#!/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
}

13
install/distro/debian/apt Normal file
View File

@ -0,0 +1,13 @@
# 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

@ -0,0 +1,3 @@
# https://remmina.org/how-to-install-remmina/#ubuntu
module_load add-ppa
add_ppa -i -c remmina -p \"remmina remmina-plugin-rdp remmina-plugin-secret\" ppa:remmina-ppa-team/remmina-next

View File

@ -1,2 +1,4 @@
#!/bin/bash
command -v docker >/dev/null 2>&1 || return
export DOCKER_COMPOSE_ROOT=/opt/containers

View File

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

22
install/lang/python/python.inst Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
declare dir="$(dirname $(realpath "${BASH_SOURCE:-$0}"))"
# todo call distro specific install
echo updating...
sudo apt-get update >/dev/null 2>&1
echo installing pip and venv for python3
sudo apt-get install python3-pip python3-venv -y >/dev/null
echo loading $dir/python.lib
source $dir/python.lib
echo available alias for pip use with sudo for libraries
alias | grep spip
mkdir -p /opt/python/apps/bin
echo always use pip with sudo for libraries, for apps use pipx
sudo -H python3 -m pip install pipx >/dev/null 2>&1
BASH_SHELL_HOST=${BASH_SHELL_HOST:-$(dirname $BASH_SHELL_BASE)/$(hostname)}
mkdir -p $BASH_SHELL_HOST/load
cp $dir/python.lib $BASH_SHELL_HOST/load/
echo installed pipx version $(pipx --version) at $(which pipx)
echo installing pypi apps to
env | grep PIP
echo available alias
alias | grep pipx

View File

@ -0,0 +1,59 @@
#!/bin/bash
command -v python3 >/dev/null 2>&1 || return
alias python3x="sudo -H python3 -m"
if command -v pyenv >/dev/null 2>&1; then
use_pyenv() {
if command -v pyenv >/dev/null 2>&1; then
export PYENV_ROOT="/opt/python/pyenv"
export PYENV_VERSION=${PYENV_VERSION:-3.8.7}
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
}
[[ $USE_PYENV ]] && use_pyenv
fi
if command -v pip3 >/dev/null 2>&1; then
module_load system-path
alias spip="sudo -H python3 -m pip"
alias spipi="sudo -H python3 -m pip install"
alias spipiu="sudo -H python3 -m pip install -U"
alias spipl="sudo -H python3 -m pip list"
alias spiplo="sudo -H python3 -m pip list --outdated"
alias pip3="sudo -H python3 -m pip"
path_append "/opt/python/bin"
spipua() {
module_load confirm
echo upgrading all base python packages - requires sudo access
# sudo -H python3.8 -m pip list --outdated
local List
local Ver=${1:-3.8}
List="$(sudo -H python$Ver -m pip list -o --format columns)"
echo "$List"
confirm "ATTENTION: upgrade all these packages at once??" || return 0
echo "$List" | cut -d' ' -f1 | xargs -n1 sudo -H python$Ver -m pip install -U
}
if command -v pipx >/dev/null 2>&1; then
path_append "/opt/python/apps/bin"
export PIPX_HOME=/opt/python/apps
export PIPX_BIN_DIR=$PIPX_HOME/bin
alias pipu="pipx upgrade"
alias pipua="pipx upgrade-all"
alias pipupip="pipx upgrade pipx"
alias pipi="pipx install"
alias pipr="pipx uninstall"
alias pipl="pipx list"
alias piplv="pipx list --verbose"
fi
fi

7
install/readme.md Normal file
View File

@ -0,0 +1,7 @@
# 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

View File

@ -1,58 +0,0 @@
#!/bin/bash
use_pyenv() {
if command -v pyenv >/dev/null 2>&1; then
export PYENV_ROOT="/opt/python/pyenv"
export PYENV_VERSION=${PYENV_VERSION:-3.8.7}
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
}
if command -v python3 >/dev/null 2>&1; then
# TODO make alias generating function for versions of python
alias python3x="sudo -H python3 -m"
alias spip="sudo -H python3 -m pip"
alias spipi="sudo -H python3 -m pip install"
alias spipiu="sudo -H python3 -m pip install -U"
alias spipl="sudo -H python3 -m pip list"
alias spiplo="sudo -H python3 -m pip list --outdated"
alias pip3="sudo -H python3 -m pip"
path_append "/opt/python/bin"
spipua() {
module_load confirm
echo upgrading all base python packages - requires sudo access
# sudo -H python3.8 -m pip list --outdated
local List
local Ver=${1:-3.8}
List="$(sudo -H python$Ver -m pip list -o --format columns)"
echo "$List"
confirm "ATTENTION: upgrade all these packages at once??" || return 0
echo "$List" | cut -d' ' -f1 | xargs -n1 sudo -H python$Ver -m pip install -U
}
fi
if command -v pipx >/dev/null 2>&1; then
path_append "/opt/python/apps/bin"
export PIPX_HOME=/opt/python/apps
export PIPX_BIN_DIR=$PIPX_HOME/bin
alias pipu="pipx upgrade"
alias pipua="pipx upgrade-all"
alias pipupip="pipx upgrade pipx"
alias pipi="pipx install"
alias pipr="pipx uninstall"
alias pipl="pipx list"
alias piplv="pipx list --verbose"
fi
[[ $USE_PYENV ]] && use_pyenv

120
modules/add-ppa.sh Executable file
View File

@ -0,0 +1,120 @@
#!/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,23 +1,6 @@
#!/bin/bash
# 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
# }
function bumount {
echo "removing bind mount at $1"
@ -38,5 +21,25 @@ function bmount {
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,50 +0,0 @@
#!/bin/bash
# user to start MUST be first in arguments
# if not supplied then will use default
chromium_() {
local DEFAULT=/opt/chromium
# local DEFAULT="$HOME/.local/share/chromium"
local exe="/usr/bin/chromium"
if [[ ! -f $exe ]]; then
echo deb chromium not installed, checking for flatpak version
flatpak=$(flatpak info com.github.Eloston.UngoogledChromium | grep error:)
if [[ $flatpak ]]; then
echo no flatpak version either - exiting && return 1
else
flatpak=true
exe="/usr/bin/flatpak run --branch=stable --arch=x86_64 --filesystem=<dir> --command=/app/bin/chromium --file-forwarding com.github.Eloston.UngoogledChromium @@u"
fi
fi
# an instance gets it's own directory
local instance=${CHROMIUM_INSTANCE}
[[ $1 && (! $1 == -*) ]] && instance=$1 && shift
[[ $1 && (! $1 == -*) ]] && url=$1 && shift
if [[ $instance =~ http[s]?:\/\/ ]]; then
url=$instance
instance=""
if [[ $url =~ ^-+ ]]; then
url=""
set -- "$@" $url
url=""
fi
fi
local dir
if [[ ! $instance ]]; then
unset CHROME_CONFIG_HOME
$HOME/.config/chromium
dir=$HOME/.config/chromium
exe="${exe/<dir>/$dir}"
echo starting chromium for $USER in
else
[[ $instance == "incognito" ]] && set -- "$@" "-incognito"
dir=${CHROMIUM_HOME:-$DEFAULT}/$instance
exe="${exe/<dir>/$dir}"
fi
echo $exe $@ --user-data-dir=$dir $url $([[ $flatpak ]] && echo "@@")
}
# # if script was executed then call the function
(return 0 2>/dev/null) || chromium_ $@

View File

@ -1,20 +0,0 @@
#!/bin/bash
function chromium_install {
source $BASH_SHELL_BASE/module.lib
module_load helpers
NAME="chromium"
DIR=$(adirname "$0")
BIN=${1:-/opt/bin/$NAME}
# [[ $(chown :users $DIR/$NAME.sh) ]] || sudo chown :users $DIR/$NAME.sh
[[ $(chmod 755 $DIR/$NAME.sh) ]] || sudo chmod 755 $DIR/$NAME.sh
ln -sf $DIR/$NAME.sh $BIN
echo link created
ls -la /opt/bin | grep chromium
echo with permissions
ls -la $DIR | grep chromium.sh
}
# if script was executed then call the function
(return 0 2>/dev/null) || chromium_install $@

View File

@ -1,66 +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
}
_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

View File

@ -1,40 +1,66 @@
#!/bin/bash
function get_platform () {
function get_platform() {
local OS
local ARCH
local PLATFORM
local OS
local ARCH
local PLATFORM
OS="$(uname -s)"
ARCH="$(uname -m)"
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
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
echo $PLATFORM
}
}
# function get_distro() {
# /bin/cp /etc/os-release /tmp/os-release.tmp
# source /etc/os-release
# declare valid=${@:-"arch alpine debian ubuntu"}
# [[ "${valid}" =~ $ID ]] && echo $ID && return 0
# [[ "${valid}" =~ $ID_LIKE ]] && echo $ID_LIKE && return 0
# return 1
# }
function get_release() {
}
get_distro() {
local file=/etc/upstream-release/lsb-release
local distro
if [[ -f $file ]]; then
$(cat $file | tr [:upper:] [:lower:] | grep -Poi '(debian|ubuntu|red hat|centos|arch|alpine)' | uniq)
return 0
else
$file=/etc/os-release
if [[ -f $file ]]; then
echo $(cat $file | tr [:upper:] [:lower:] | grep -Poi '(debian|ubuntu|red hat|centos|arch|alpine)' | uniq)
fi
}

View File

@ -1 +0,0 @@
/shell/any/host/tools

6
modules/trustedkeys.func Normal file
View File

@ -0,0 +1,6 @@
movekey() {
sudo apt-key export $1 | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/$2.gpg
}
alias showkeys="apt-key list"
alias filterkeys="apt-key list | grep -B1"