system init updates; auto create config for first-time local; auto-link sudo vimrc

This commit is contained in:
Wryn (yage) Wagner 2024-08-14 19:11:52 -06:00
parent a29a07c0aa
commit 74323b7568
3 changed files with 41 additions and 45 deletions

View File

@ -1,6 +1,8 @@
function SETUP__CONFIG() { function SETUP__CONFIG() {
STATUS 'starting application configuration' STATUS 'starting application configuration'
GENERATE_INITIAL_LOCAL_CONFIG
SCWRYPTS system/config/update || return 1 SCWRYPTS system/config/update || return 1
CONFIG__ZSH || return 2 CONFIG__ZSH || return 2
@ -15,6 +17,23 @@ function SETUP__CONFIG() {
##################################################################### #####################################################################
GENERATE_INITIAL_LOCAL_CONFIG() {
local HOSTNAME="$(hostnamectl --static)"
[ $HOSTNAME ] || return 0
mkdir -p "$DOTWRYN_PATH/bin/$HOSTNAME"
local ENV_DIR="$DOTWRYN_PATH/config/scwrypts/environments"
local GROUP
for GROUP in $(find "$ENV_DIR" -type f -name \*env.yaml | sed -n 's|.*/local\.\([^.]*\)\.env\.yaml|\1|p')
do
[ -f "$ENV_DIR/local.$HOSTNAME.$GROUP.env.yaml" ] \
|| cp "$ENV_DIR/local.altaria.$GROUP.env.yaml" "$ENV_DIR/local.$HOSTNAME.$GROUP.env.yaml"
done
}
#####################################################################
CONFIG__ZSH() { CONFIG__ZSH() {
#CONFIG__ENV zsh || return 1 #CONFIG__ENV zsh || return 1
#CONFIG__RC zsh || return 2 #CONFIG__RC zsh || return 2
@ -40,47 +59,27 @@ CONFIG__VIM() {
CONFIG__RC vim || return 1 CONFIG__RC vim || return 1
STATUS 'starting vim setup' STATUS 'starting vim setup'
SCWRYPTS --name system/vim/vundle/install --group scwrypts --type zsh || return 1 SCWRYPTS --name system/vim/vundle/install --group scwrypts --type zsh || return 2
CONFIG__VIM__LINK_SUPERUSER_RC
return 0
}
CONFIG__VIM__LINK_SUPERUSER_RC() {
sudo [ /root/.vimrc ] && return 0
echo "let $DOTWRYN=\"$DOTWRYN_PATH\"\nsource \"$DOTWRYN_PATH/vim/rc.vim\"" \
| sudo tee /root/.vimrc >/dev/null
sudo mkdir -p /root/.vim
sudo ln -s /home/w0ryn/.vim/bundle /root/.vim/bundle
} }
##################################################################### #####################################################################
CONFIG__SYSTEM() { CONFIG__SYSTEM() {
STATUS "configuring system applications" SCWRYPTS dotwryn system setup
local \
SYSTEM_APPLICATION \
SOURCE_DIR SOURCE_CONFIG \
SYSTEM_DIR SYSTEM_CONFIG \
;
for SOURCE_DIR in $(find "$DOTWRYN_PATH/config/system/" -mindepth 1 -maxdepth 1 -type d)
do
SYSTEM_APPLICATION="$(echo "$SOURCE_DIR" | sed 's|.*/||')"
case $SYSTEM_APPLICATION in
( ssh | sshd )
SYSTEM_DIR=/etc/ssh/${SYSTEM_APPLICATION}_config.d
;;
( * )
SYSTEM_DIR=''
;;
esac
[ "$SYSTEM_DIR" ] && sudo [ -d "$SYSTEM_DIR" ] \
|| continue
for SOURCE_CONFIG in $(find "$SOURCE_DIR" -mindepth 1 -maxdepth 1 -type f)
do
SYSTEM_CONFIG="$SYSTEM_DIR/$(basename -- "$SOURCE_CONFIG")"
sudo [ -f "$SYSTEM_CONFIG" ] && {
echo "detected existing config '$SYSTEM_CONFIG'; skipping"
continue
}
sudo ln -s "$SOURCE_CONFIG" "$SYSTEM_CONFIG"
done
done
} }
##################################################################### #####################################################################

View File

@ -97,17 +97,14 @@ INSTALL_MANAGED__arch() {
return 0 return 0
} }
STATUS "checking for $TARGET" yay -Qq 2>/dev/null | grep -q "^$TARGET$\|^$TARGET-git$" && {
SUCCESS "found '$TARGET'"
yay -Qq | grep -q "^$TARGET$\|^$TARGET-git$" && {
SUCCESS "found installation of '$TARGET'"
} || { } || {
WARNING "'$TARGET' not found"
STATUS "installing '$TARGET'" STATUS "installing '$TARGET'"
yay -Syu --noconfirm $TARGET \ yay -Syu --noconfirm $TARGET \
&& SUCCESS "successfully installed '$TARGET'" \ && SUCCESS "successfully installed '$TARGET'" \
|| ERROR "failed to install '$TARGET'" || ERROR "failed to install '$TARGET'" \
;
} }
} }

View File

@ -23,14 +23,14 @@ source ./requirements.zsh || exit 1
LOGFILE="$HOME/dotwryn-install.log" LOGFILE="$HOME/dotwryn-install.log"
INFO "installation start : $(date)" 2>> "$LOGFILE" STATUS "installation start : $(date)" 2>> "$LOGFILE"
{ {
SETUP__OS || FAIL 1 'failed to set up os-dependencies (see above)' SETUP__OS || FAIL 1 'failed to set up os-dependencies (see above)'
SETUP__GIT || FAIL 2 'failed to set up git (see above)' SETUP__GIT || FAIL 2 'failed to set up git (see above)'
SETUP__CONFIG || FAIL 3 'failed to set up program configuration (see above)' SETUP__CONFIG || FAIL 3 'failed to set up program configuration (see above)'
} 2>&1 | tee --append "$LOGFILE" } 2>&1 | tee --append "$LOGFILE"
INFO "installation complete: $(date)" 2>> "$LOGFILE" STATUS "installation complete: $(date)" 2>> "$LOGFILE"
################################################################################ ################################################################################
yN 'keep logfile?' \ yN 'keep logfile?' \