diff --git a/setup/config.zsh b/setup/config.zsh index 93cfbba..9cdc3e5 100644 --- a/setup/config.zsh +++ b/setup/config.zsh @@ -1,6 +1,8 @@ function SETUP__CONFIG() { STATUS 'starting application configuration' + GENERATE_INITIAL_LOCAL_CONFIG + SCWRYPTS system/config/update || return 1 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__ENV zsh || return 1 #CONFIG__RC zsh || return 2 @@ -40,47 +59,27 @@ CONFIG__VIM() { CONFIG__RC vim || return 1 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() { - STATUS "configuring system applications" - 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 + SCWRYPTS dotwryn system setup } ##################################################################### diff --git a/setup/os.zsh b/setup/os.zsh index 2e2b0ea..157c114 100644 --- a/setup/os.zsh +++ b/setup/os.zsh @@ -97,17 +97,14 @@ INSTALL_MANAGED__arch() { return 0 } - STATUS "checking for $TARGET" - - yay -Qq | grep -q "^$TARGET$\|^$TARGET-git$" && { - SUCCESS "found installation of '$TARGET'" + yay -Qq 2>/dev/null | grep -q "^$TARGET$\|^$TARGET-git$" && { + SUCCESS "found '$TARGET'" } || { - WARNING "'$TARGET' not found" - STATUS "installing '$TARGET'" yay -Syu --noconfirm $TARGET \ && SUCCESS "successfully installed '$TARGET'" \ - || ERROR "failed to install '$TARGET'" + || ERROR "failed to install '$TARGET'" \ + ; } } diff --git a/setup/run b/setup/run index bf002f6..890ead5 100755 --- a/setup/run +++ b/setup/run @@ -23,14 +23,14 @@ source ./requirements.zsh || exit 1 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__GIT || FAIL 2 'failed to set up git (see above)' SETUP__CONFIG || FAIL 3 'failed to set up program configuration (see above)' } 2>&1 | tee --append "$LOGFILE" -INFO "installation complete: $(date)" 2>> "$LOGFILE" +STATUS "installation complete: $(date)" 2>> "$LOGFILE" ################################################################################ yN 'keep logfile?' \