#!/bin/bash : ' @vendor Chorke Academia, Inc. @web https://cdn.chorke.org/docs/academia @version 1.0.00 @since 1.0.00 ' :< ${FINOLOGY_ENV_PROFILE} # @vendor Chorke Academia, Inc. # @web https://cdn.chorke.org/docs/academia # @version 1.0.00 # since 1.0.00 # finology defaults env export FINOLOGY_HOME="${HOME}/.finology" if [[ ! "${PATH}" =~ "${FINOLOGY_HOME}/defaults/bin:" ]]&& [[ -d "${FINOLOGY_HOME}/defaults/bin" ]];then export PATH="${FINOLOGY_HOME}/defaults/bin:${PATH}" fi # finology concerns env EOF fi if [ -f "${FINOLOGY_ENV_PROFILE}" ]&&[ -s "${FINOLOGY_ENV_PROFILE}" ]&& [[ "${FINOLOGY_ENV_ENABLE}/env/set" == '/env/set' ]]&& [[ "${FINOLOGY_HOME}/env/set" == '/env/set' ]];then printf 'please relogin or exec "\033[0;32msource %s\033[0m"\n\n' "${FINOLOGY_ENV_PROFILE}" source "${FINOLOGY_ENV_PROFILE}" fi } function conf_shell_profile(){ if [ -f "${SHELL_ENV_PROFILE}" ]&& [ "$(grep -c 'FINOLOGY_ENV_ENABLE' ${SHELL_ENV_PROFILE})" == 0 ];then cat <<'EOF' >> ${SHELL_ENV_PROFILE} # finology defaults env export FINOLOGY_ENV_ENABLE='enable' if [[ "/env/${FINOLOGY_ENV_ENABLE}" == '/env/enable' ]]&& [ -f "${HOME}/.finology/defaults/env" ];then source "${HOME}/.finology/defaults/env" fi EOF fi if [ ! -f "${SHELL_ENV_PROFILE}" ];then cat <<'EOF' >> ${SHELL_ENV_PROFILE} # @vendor Chorke Academia, Inc. # @web https://cdn.chorke.org/docs/academia # @version 1.0.00 # since 1.0.00 # profile added by academia # system defaults env # finology defaults env export FINOLOGY_ENV_ENABLE='enable' if [[ "/env/${FINOLOGY_ENV_ENABLE}" == '/env/enable' ]]&& [ -f "${HOME}/.finology/defaults/env" ];then source "${HOME}/.finology/defaults/env" fi EOF fi } # distribution conf function conf_debian_zsh(){ SHELL_ENV_PROFILE="${HOME}/.zprofile/.zlogin" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.zshenv" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.zshrc" && conf_shell_profile } function conf_debian_bash(){ SHELL_ENV_PROFILE="${HOME}/.bash_profile" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.profile" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.bashrc" && conf_shell_profile } function conf_fedora_zsh(){ SHELL_ENV_PROFILE="${HOME}/.zprofile/.zlogin" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.zshenv" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.zshrc" && conf_shell_profile } function conf_fedora_bash(){ SHELL_ENV_PROFILE="${HOME}/.bash_profile" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.profile" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.bashrc" && conf_shell_profile } function conf_fedora_jailshell(){ printf '\njailshell \033[0;31mnot supported! \033[0m:(\n' exit 1 } function conf_darwin_zsh(){ SHELL_ENV_PROFILE="${HOME}/.zprofile/.zlogin" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.zshenv" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.zshrc" && conf_shell_profile } function conf_darwin_bash(){ SHELL_ENV_PROFILE="${HOME}/.bash_profile" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.profile" && conf_shell_profile SHELL_ENV_PROFILE="${HOME}/.bashrc" && conf_shell_profile } # distribution void function void_linux(){ if [ -f '/etc/os-release' ];then HOST_OS_ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') HOST_OS_ID_LIKE=$(grep -oP '(?<=^ID_LIKE=).+' /etc/os-release | tr -d '"') HOST_OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"') if [[ "${HOST_OS_ID}" =~ 'debian' ]]||[[ "${HOST_OS_ID_LIKE}" =~ 'debian' ]];then init_debian elif [[ "${HOST_OS_ID}" =~ 'fedora' ]]||[[ "${HOST_OS_ID_LIKE}" =~ 'fedora' ]];then init_fedora elif [[ "${HOST_OS_ID}" =~ 'opensuse' ]]||[[ "${HOST_OS_ID_LIKE}" =~ 'opensuse' ]];then init_opensuse else printf '\n%s \033[0;31mnot supported! \033[0m:(\n' "${HOST_OS_ID}" exit 1 fi else printf '\n/etc/os-release \033[0;31mnot found! \033[0m:(\n' exit 1 fi } function void_darwin(){ if [[ ! "$(which sed)" =~ 'gnu-sed/libexec/gnubin/sed' ]];then # printf 'gnu-sed \033[0;32mis configuring! \033[0m:)\n\n' if [ -x "$(command -v brew)" ];then if [ ! -f '/usr/local/opt/gnu-sed/libexec/gnubin/sed' ];then brew install gnu-sed fi else printf '\nHomebrew \033[0;31mnot found! \033[0m:(\n' exit 1 fi if [[ ! "${PATH}" =~ "gnu-sed/libexec/gnubin:" ]]&& [[ -f '/usr/local/opt/gnu-sed/libexec/gnubin/sed' ]];then export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:${PATH}" fi if [[ ! "$(which sed)" =~ 'gnu-sed/libexec/gnubin/sed' ]];then printf '\ngnu-sed \033[0;31mnot supported! \033[0m:(\n' exit 1 fi fi } # distribution init function init_debian(){ if [[ "${SHELL}" =~ 'zsh' ]];then conf_debian_zsh;fi if [[ "${SHELL}" =~ 'bash' ]];then conf_debian_bash;fi } function init_fedora(){ if [[ "${SHELL}" =~ 'zsh' ]];then conf_fedora_zsh;fi if [[ "${SHELL}" =~ 'bash' ]];then conf_fedora_bash;fi if [[ "${SHELL}" =~ 'jailshell' ]];then conf_fedora_jailshell;fi } function init_opensuse(){ printf '\nsuse \033[0;31mnot supported! \033[0m:(\n' # sudo zypper install -y curl exit 1 } # mainstream init function init_unkown(){ printf '\nos \033[0;31mnot supported! \033[0m:(\n' exit 1 } function init_solaris(){ printf '\nsolaris \033[0;31mnot supported! \033[0m:(\n' exit 1 } function init_msys(){ printf '\nmsys \033[0;31mnot supported! \033[0m:(\n' exit 1 } function init_linux(){ void_linux } function init_darwin(){ void_darwin if [[ "${SHELL}" =~ 'zsh' ]];then conf_darwin_zsh;fi if [[ "${SHELL}" =~ 'bash' ]];then conf_darwin_bash;fi } function init_cygwin(){ printf '\ncygwin \033[0;31mnot supported! \033[0m:(\n' exit 1 } function init_bsd(){ printf '\nbsd \033[0;31mnot supported! \033[0m:(\n' exit 1 } # startpoint function init(){ case "${OSTYPE}" in bsd*) init_bsd ;; cygwin*) init_cygwin ;; darwin*) init_darwin ;; linux*) init_linux ;; msys*) init_msys ;; solaris*) init_solaris ;; *) init_unkown ;; esac conf_finology_profile } init