fix: change back to just 'shell' not .shell for user default shell directory as . is ignored by default,
feat: added 'user_exists' functionmaster
parent
a15a290328
commit
ec601fbb15
|
@ -29,7 +29,7 @@ if you include any of these environment variables all files in there directories
|
|||
# $BASH_SHELL_HOST/all
|
||||
# $BASH_SHELL_HOST/<hostname>
|
||||
# sourced via $HOME/.bashrc
|
||||
# $HOME/.shell or $HOME/BASH_SHELL_USER
|
||||
# $HOME/shell or $HOME/BASH_SHELL_USER
|
||||
|
||||
# within each of those directories if setup.sh exits it will be run
|
||||
# otherwise files will be sourced exactly like in the base
|
||||
|
@ -44,7 +44,7 @@ export BASH_SHELL_NETWORK=$BASH_SHELL/network
|
|||
# will use $BASH_SHELL_HOST/<hostname> unless specifically set
|
||||
export BASH_SHELL_HOST=$BASH_SHELL/host
|
||||
|
||||
# by default SHELL sources will be looked for under $HOME/.shell
|
||||
# by default SHELL sources will be looked for under $HOME/shell
|
||||
# but can be user set below to $HOME/$BASH_SHELL_USER
|
||||
# export BASH_SHELL_USER=<some directory under $HOME>
|
||||
if there is a script setup.sh in the root of these directoies it will be run. If not then all files no matter how deep will be sourced in alpha order order.
|
||||
|
|
4
load.sh
4
load.sh
|
@ -80,7 +80,7 @@ function shell_process_directory () {
|
|||
if [ -e "$DIR/$SUBDIR" ]; then
|
||||
# echo processing subdirectory $DIR/$SUBDIR
|
||||
# must quote all globs to avoid bash glob expansion which is likely on
|
||||
# TODO have default set of ignores plus check for .shell-ignore
|
||||
# TODO have default set of ignores plus check for shell-ignore
|
||||
# source_dir -p "archive" -x '"*.off" "*.md" "*TODO*" "LICENSE" "*.sample"' -d 0 $DIR/$SUBDIR
|
||||
# source_dir -p "archive" -x "$excludes" -d 0 $DIR/$SUBDIR
|
||||
source_dir -f "$IGNORE_FILE" -d 0 $DIR/$SUBDIR
|
||||
|
@ -103,7 +103,7 @@ unset BASH_SHELL_LOADED
|
|||
# add in any network directories
|
||||
declare networks
|
||||
source "$HOME/.bashrc"
|
||||
networks="$HOME/${BASH_SHELL_USER:-".shell"}/.networks"
|
||||
networks="$HOME/${BASH_SHELL_USER:-"shell"}/.networks"
|
||||
NETWORK_DOMAINS="$([[ -f $networks ]] && cat $networks) "
|
||||
# These will be loaded for all users
|
||||
networks="$BASH_SHELL_HOST/$(hostname)/.networks"
|
||||
|
|
|
@ -36,7 +36,7 @@ local DIRS
|
|||
local MODULE=$1
|
||||
# Precidence is user. current hosts, all hosts, current network, all networks, base
|
||||
DIRS=( \
|
||||
$([ $BASH_SHELL_USER ] && echo $HOME/$BASH_SHELL_USER || echo $HOME/.shell) \
|
||||
$([ $BASH_SHELL_USER ] && echo $HOME/$BASH_SHELL_USER || echo $HOME/shell) \
|
||||
$BASH_SHELL_HOST/$(hostname)
|
||||
$BASH_SHELL_HOST/all \
|
||||
$BASH_SHELL_NETWORK/$NETWORKNAME \
|
||||
|
|
|
@ -22,6 +22,10 @@ adirname() {
|
|||
echo "$(cd "$(dirname "$1")" >/dev/null 2>&1 ; pwd -P )"
|
||||
}
|
||||
|
||||
user_exists() {
|
||||
id -u $1 > /dev/null 2>&1
|
||||
[[ $? == 1 ]] || echo $1
|
||||
}
|
||||
|
||||
|
||||
chmod_dirs() {
|
||||
|
|
|
@ -34,9 +34,9 @@ for file in $files; do
|
|||
cmd="install -C -m 660 -o $_USER -g sudo $file $_USER_DIR"
|
||||
[[ $USER = "$_USER" ]] && eval $cmd || sudo -E -- bash -c "$cmd"
|
||||
done
|
||||
echo "the default user bash shell repo subdirecty is \`.shell\`"
|
||||
echo "the default user bash shell repo subdirecty is \`shell\`"
|
||||
echo "enter an alternative subdirectory under $_USER_DIR or just <enter> to accept default"
|
||||
read -e answer
|
||||
[[ ! $answer ]] && echo will source default user shell repo at $_USER_DIR/.shell && exit 0
|
||||
[[ ! $answer ]] && echo will source default user shell repo at $_USER_DIR/shell && exit 0
|
||||
sed -i '/[[ $BASH_SHELL_BASE_LOADED = true ]]/ i\ BASH_SHELL_USER='$answer'' $_USER_DIR/.bashrc
|
||||
echo will be processing user shell repo at $_USER_DIR/$answer
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
if ( [[ $SHELL_INTERACTIVE ]] );then
|
||||
if ( [[ $BASH_SHELL_BASE_LOADED = true ]] ) ; then
|
||||
# echo loading user shell sources
|
||||
export BASH_SHELL_USER=${BASH_SHELL_USER:-".shell"}
|
||||
export BASH_SHELL_USER=${BASH_SHELL_USER:-"shell"}
|
||||
[[ -d $HOME/$BASH_SHELL_USER ]] && shell_process_directory "$HOME/$BASH_SHELL_USER" ||\
|
||||
echo no user shell directory $HOME/$BASH_SHELL_USER to process, create one or clone a template
|
||||
fi
|
||||
|
|
|
@ -67,7 +67,7 @@ export BASH_SHELL_NETWORK=$([[ -d $parent/network ]] && echo $parent/network ||
|
|||
# or comment above and set explictly
|
||||
# export BASH_SHELL_NETWORK=<some directory>
|
||||
|
||||
# by default USER shell sources will be looked for under $HOME/.shell
|
||||
# by default USER shell sources will be looked for under $HOME/shell
|
||||
# but the default directory for all users can be set manually below
|
||||
# export BASH_SHELL_USER=<some directory under $HOME>
|
||||
# add this export to .bashrc for custom directory. This can be done during or after using the user setup script
|
||||
|
|
Reference in New Issue