#!/bin/bash : ' @vendor Chorke Academia, Inc. @web https://cdn.chorke.org/docs/academia @version 1.0.00 @since 1.0.00 ' :< ${MEMBER_ENV_PROFILE} # @vendor Chorke Academia, Inc. # @web https://cdn.chorke.org/docs/academia # @version 1.0.00 # since 1.0.00 # finology xpresscover env export FINOLOGY_XPRESSCOVER_HOME="${HOME}/.finology/xpresscover" if [[ ! "${PATH}" =~ "${FINOLOGY_XPRESSCOVER_HOME}/bin:" ]]&& [[ -d "${FINOLOGY_XPRESSCOVER_HOME}/bin" ]];then export PATH="${FINOLOGY_XPRESSCOVER_HOME}/bin:${PATH}" fi # system internal env EOF fi if [ -f "${MEMBER_ENV_PROFILE}" ]&&[ -s "${MEMBER_ENV_PROFILE}" ]&& [[ "${FINOLOGY_XPRESSCOVER_ENV_ENABLE}/env/set" == '/env/set' ]]&& [[ "${FINOLOGY_XPRESSCOVER_HOME}/env/set" == '/env/set' ]];then printf 'please relogin or exec "\033[0;32msource %s\033[0m"\n\n' "${MEMBER_ENV_PROFILE}" source "${MEMBER_ENV_PROFILE}" fi } function conf_finology(){ FINOLOGY_ENV_PROFILE="${HOME}/.finology/defaults/env" if [ -f "${FINOLOGY_ENV_PROFILE}" ]&& [ "$(grep -c 'FINOLOGY_XPRESSCOVER_ENV_ENABLE' ${FINOLOGY_ENV_PROFILE})" == 0 ];then cat <<'EOF' >> ${FINOLOGY_ENV_PROFILE} # finology xpresscover env export FINOLOGY_XPRESSCOVER_ENV_ENABLE='enable' if [[ "/env/${FINOLOGY_XPRESSCOVER_ENV_ENABLE}" == '/env/enable' ]]&& [ -f "${HOME}/.finology/xpresscover/env" ];then source "${HOME}/.finology/xpresscover/env" fi EOF fi if [ ! -f "${FINOLOGY_ENV_PROFILE}" ];then printf '%s \033[0;31mnot found! \033[0m:(\n\n' "${FINOLOGY_ENV_PROFILE}" exit 1 fi } # 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(){ conf_finology } function init_fedora(){ conf_finology } 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 conf_finology } 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 } # setup finology env function init_finology(){ bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/profile/finology.sh.txt') } # startpoint function init(){ init_finology 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_member } init