2024-02-21 13:25:54 -08:00
|
|
|
#!/bin/bash
|
|
|
|
# assumes that bash is installed
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# use this to improve same below
|
|
|
|
# install_shell_base () {
|
|
|
|
# # TODO have a cross distro package install
|
|
|
|
# [[ ! $(which git) ]] && apt-get install --no-install-recommends git -y
|
|
|
|
# [[ ! $EUID -eq 0 ]] && { echo ERROR script must be run as root; return; }
|
|
|
|
# local user
|
|
|
|
# [[ $1 == "-u" ]] && user=$2 && shift 2
|
|
|
|
# local dir=${2:-/shell}
|
|
|
|
# local repo=${1:-base}
|
|
|
|
# local rpath=$dir/$repo
|
|
|
|
# mkdir -p $rpath
|
|
|
|
# # TODO set git host via option or env var
|
|
|
|
# git clone https://git.kebler.net/bash/shell-$repo.git $rpath
|
|
|
|
# chown -R ${user:-1000}:${user:-1000} $rpath
|
|
|
|
# chmod -R +r $rpath
|
|
|
|
# }
|
|
|
|
|
|
|
|
# must! be run as sudo
|
|
|
|
install_shell_base () {
|
2024-02-27 18:55:57 -08:00
|
|
|
if [[ $BASH_SHELL_BASE ]] && [[ -d $BASH_SHELL_BASE ]]; then
|
2024-02-21 13:25:54 -08:00
|
|
|
echo appears that UCI shell base is already installed at $BASH_SHELL_BASE
|
|
|
|
echo upgrade instead using: 'module_load uci-shell-install; update_shell_base'
|
2024-02-27 18:55:57 -08:00
|
|
|
[[ $1 == "-f" ]] && { shift; echo forcing reinstall; } || return 1
|
2024-02-21 13:25:54 -08:00
|
|
|
fi
|
|
|
|
if [[ ! $BASH_SHELL_GIT_URL ]]; then
|
|
|
|
echo BASH_SHELL_GIT_URL must be set before install can proceed
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
# TODO have a cross distro package install
|
|
|
|
module_load distro
|
|
|
|
set_distro
|
|
|
|
|
|
|
|
[[ ! $(command -v git) ]] && echo git must be installed first && $INSTALL_PKGS git
|
|
|
|
# TODO, avoid which in all scripts. or put which in environment if not on machine
|
|
|
|
[[ ! $(command -v which) ]] && echo 'which' must be installed first && $INSTALL_PKGS which
|
|
|
|
echo $USER, $EUID
|
|
|
|
[[ ! $EUID -eq 0 ]] && { echo ERROR script must be run as root; return 2; }
|
|
|
|
echo I am ROOT, now running script
|
|
|
|
echo UCI user: $1
|
|
|
|
# TODO make the repo and clone values dynamic or bundle current base on sending machine a archive
|
|
|
|
mkdir -p /shell/base
|
|
|
|
git clone $BASH_SHELL_GIT_URL/shell-base.git /shell/base
|
|
|
|
chown -R ${1:-$1000}:${1:-1000} /shell
|
|
|
|
chmod -R +r /shell
|
|
|
|
|
|
|
|
echo /bin/bash /shell/base/install/install.sh ${1:-1000}
|
|
|
|
}
|
|
|
|
|
|
|
|
# # if script was executed then call the function
|
|
|
|
( return 0 2>/dev/null ) || install_shell_base $@
|
|
|
|
|
|
|
|
|
|
|
|
install_shell_host () {
|
2024-02-21 14:46:44 -08:00
|
|
|
if [[ -d $BASH_SHELL_HOST/modules ]]; then
|
2024-02-21 13:25:54 -08:00
|
|
|
echo appears that UCI shell host repo is already installed at $BASH_SHELL_HOST
|
|
|
|
echo upgrade instead using: 'module_load uci-shell-install; update_shell_host'
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [[ ! $BASH_SHELL_GIT_URL ]]; then
|
|
|
|
echo BASH_SHELL_GIT_URL must be set before install can proceed
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
export BASH_SHELL_HOST=$(dirname $BASH_SHELL_BASE)/host
|
|
|
|
if mkdir -p $BASH_SHELL_HOST; then
|
2024-02-21 14:46:44 -08:00
|
|
|
if git clone $BASH_SHELL_GIT_URL/shell-host.git $BASH_SHELL_HOST; then
|
2024-02-21 13:25:54 -08:00
|
|
|
chown -R ${1:-$USER}:${1:-$USER} $BASH_SHELL_HOST
|
|
|
|
chmod -R +r $BASH_SHELL_HOST
|
2024-02-21 14:46:44 -08:00
|
|
|
export BASH_SHELL_HOSTNAME=$(dirname $BASH_SHELL_BASE)/$(hostnamectl hostname)
|
2024-02-21 13:25:54 -08:00
|
|
|
mkdir -p $BASH_SHELL_HOSTNAME/load
|
|
|
|
echo note: use $BASH_SHELL_HOSTNAME/load directory to load modules and other stuff from at prompt.
|
|
|
|
fi
|
|
|
|
fi
|
2024-02-24 08:01:41 -08:00
|
|
|
bash $BASH_SHELL_HOST/distro/distro.inst
|
2024-02-21 13:25:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
install_shell_network () {
|
2024-02-21 14:46:44 -08:00
|
|
|
if [[ -d $BASH_SHELL_NETWORK/modules ]]; then
|
2024-02-21 13:25:54 -08:00
|
|
|
echo appears that UCI shell network repo is already installed at $BASH_SHELL_NETWORK
|
|
|
|
echo upgrade instead using: 'module_load uci-shell-install; update_shell_network'
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [[ ! $BASH_SHELL_GIT_URL ]]; then
|
|
|
|
echo BASH_SHELL_GIT_URL must be set before install can proceed
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
export BASH_SHELL_NETWORK=$(dirname $BASH_SHELL_BASE)/network
|
|
|
|
if mkdir -p $BASH_SHELL_NETWORK; then
|
2024-02-21 14:46:44 -08:00
|
|
|
if git clone $BASH_SHELL_GIT_URL/shell-network.git $BASH_SHELL_NETWORK; then
|
2024-02-21 13:25:54 -08:00
|
|
|
chown -R ${1:-$USER}:${1:-$USER} $BASH_SHELL_NETWORK
|
|
|
|
chmod -R +r $BASH_SHELL_NETWORK
|
|
|
|
fi
|
2024-02-24 08:01:41 -08:00
|
|
|
fi
|
2024-02-21 13:25:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
update_shell_base () {
|
|
|
|
cd $BASH_SHELL_BASE || { echo not directory $BASH_SHELL_ANY_HOST; return 2; }
|
|
|
|
if [[ ! $BASH_SHELL_GIT_REMOTE ]]; then
|
|
|
|
echo WARNING: BASH_SHELL_GIT_REMOTE is not set will use \'origin\'
|
|
|
|
fi
|
2024-02-24 08:05:00 -08:00
|
|
|
git pull ${BASH_SHELL_GIT_REMOTEE:-origin} master
|
2024-02-21 13:25:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
update_shell_host () {
|
2024-02-24 08:01:41 -08:00
|
|
|
[[ ! -d $BASH_SHELL_HOST/modules ]] && echo uci shell host repo not installed, run install_shell_host first && return 1
|
|
|
|
cd $BASH_SHELL_HOST || { echo not directory $BASH_SHELL_HOST; return 2; }
|
|
|
|
git pull ${BASH_SHELL_GIT_REMOTE:-origin} master
|
2024-02-21 13:25:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
update_shell_network () {
|
2024-02-24 08:01:41 -08:00
|
|
|
[[ ! -d $BASH_SHELL_NETWORK/modules ]] && echo uci shell host repo not installed, run install_shell_host first && return 1
|
2024-02-21 13:25:54 -08:00
|
|
|
cd $BASH_SHELL_NETWORK || { echo not directory $BASH_SHELL_NETWORK; return 2; }
|
2024-02-24 08:01:41 -08:00
|
|
|
git pull ${BASH_SHELL_GIT_REMOTE:-origin} master
|
2024-02-21 13:25:54 -08:00
|
|
|
}
|