shell-base/modules/install-shell-repos.lib

48 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# assumes that bash is installed
#!/bin/bash
# must! be run as sudo
install_shell_repo () {
# 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/any}
local repo=${1:-host}
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
}
install_shell_host () {
module_load sudo
local user
[[ $1 == "-u" ]] && user="-u $2" && shift 2
Sudo install_shell_repo $user host $1
}
install_shell_network () {
module_load sudo
local user
[[ $1 == "-u" ]] && user="-u $2" && shift 2
Sudo install_shell_repo $user network $1
}
update_shell_host () {
cd $BASH_SHELL_ANY_HOST || { echo not directory $BASH_SHELL_ANY_HOST; return 2; }
git pull origin master
}
update_shell_network () {
cd $BASH_SHELL_ANY_NETWORK || { echo not directory $BASH_SHELL_ANY_NETWORK; return 2; }
git pull origin master
}