#!/bin/bash ######################################################################### # # cb-install # # Copyright by toolarium, all rights reserved. # # This file is part of the toolarium common-build. # # The common-build is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # The common-build is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Foobar. If not, see . # ######################################################################### # define defaults [ -z "$CB_DEVTOOLS_NAME" ] && CB_DEVTOOLS_NAME=devtools [ -z "$CB_DEVTOOLS" ] && CB_DEVTOOLS="$HOME/$CB_DEVTOOLS_NAME" #[ -z "`echo $OSTYPE | sed 's/cygwin.*//'`" ] && CLASSSEP=";" || CLASSSEP=":" # define parameters CB_LINE="------------------------------------------------------------------------------------------------------------------------" CB_LINEHEADER=".: " PN=$(basename "$0") #REL_PROG_PATH="${0%/*}" #ABS_PROG_PATH=$(cd -- "`dirname $0`" && pwd) #PN_BASE="${PN%*.sh}" CB_FORCE_INSALL=false CB_INSTALL_ONLY_STABLE=true CB_INSTALLER_SILENT=false CB_INSTALLER_VERSION="1.0.4" CB_JSON="$CB_HOME/bin/cb-json" CB_RELEASE_URL="https://api.github.com/repos/toolarium/common-build/releases" # GitHub API auth (avoids rate limiting on CI) CB_GITHUB_AUTH="" CB_GITHUB_AUTH_WGET="" if [ -n "$GITHUB_TOKEN" ]; then CB_GITHUB_AUTH="-H \"Authorization: token $GITHUB_TOKEN\"" CB_GITHUB_AUTH_WGET="--header=\"Authorization: token $GITHUB_TOKEN\"" fi CB_JSON_SCRIPT_URL="https://raw.githubusercontent.com/toolarium/common-build/master/bin/cb-json" FULLTIMESTAMP="date '+%Y%d%m%H%M%S'" USER_FRIENDLY_FULLTIMESTAMP="date '+%d.%m.%Y %H:%M:%S'" ! [ -n "$USER" ] && USER=root && export USER ! [ -n "$CB_TEMP" ] && CB_TEMP="/tmp/cb-$USER" ! [ -r "$CB_TEMP" ] && mkdir "$CB_TEMP" >/dev/null 2>&1 export CB_TEMP cbErrorTemp=$(mktemp $CB_TEMP/toolarium-common-build_error.XXXXXXXXX) CB_OS="$(uname | tr '[:upper:]' '[:lower:]')" CB_OS=$(echo "$CB_OS" | awk '{print substr($0, 0, 7)}') case $CB_OS in 'linux') CB_OS="linux";; 'freebsd') CB_OS="freebsd";; 'windows') CB_OS="windows";; 'mac') CB_OS="mac";; 'darwin') CB_OS="mac";; 'sunos') CB_OS="solaris";; 'cygwin') CB_OS="cygwin";; 'cygwin_') CB_OS="cygwin";; 'mingw32') CB_OS="cygwin";; 'mingw64') CB_OS="cygwin";; 'aix') CB_OS="aix";; *) ;; esac ######################################################################### # Check if the binary exists ######################################################################### CB_HAS_WHEREIS= CB_HAS_WHICH= existBinary() { if [ -z "$CB_HAS_WHEREIS" ]; then eval whereis whereis >/dev/null 2>&1 [ $? -eq 0 ] && CB_HAS_WHEREIS=true || CB_HAS_WHEREIS=false fi if [ "$CB_HAS_WHEREIS" = "false" ]; then if [ -z "$CB_HAS_WHICH" ]; then which which >/dev/null 2>&1 [ $? -eq 0 ] && CB_HAS_WHICH=true || CB_HAS_WHICH=false fi if [ "$CB_HAS_WHICH" = "false" ]; then echo "${CB_LINEHEADER}Can not find which nor whereis command!" return 1 fi fi if [ "$CB_HAS_WHEREIS" = "true" ]; then if [ "$CB_OS" = "mac" ]; then result=$(whereis "$1" 2>/dev/null) else result=$(whereis -b "$1" 2>/dev/null | awk '{print $2}') fi result="${result##*.exe}" [ -n "$result" ] && echo "$result" [ -n "$result" ] && return 0 || return 1 else result=$(which "$1" 2>/dev/null) result="${result##*.exe}" [ -n "$result" ] && echo "$result" [ $? -eq 0 ] && return 0 || return 1 fi } ######################################################################### # Get the file size (gnu linux: stat -c %s, max: stat -f %z) ######################################################################### getFileSize() { set -- $(\ls -dn "$1") && echo $5; } ######################################################################### # Get the current shell ######################################################################### getCurrentShell() { if [ -z "${HTTP_REQUEST_CLI##*curl*}" ]; then CMD="curl -fsSL http://www.in-ulm.de/~mascheck/various/whatshell/whatshell.sh | sh" else CMD="wget -q -O - /dev/null http://www.in-ulm.de/~mascheck/various/whatshell/whatshell.sh | sh" fi currentShell=$(eval $CMD | awk '{print $1}') if [ -z $currentShell ]; then [ "$(echo ${SHELL##*/})" = "zsh" ] && currentShell=".zshrc" [ "$(echo ${SHELL##*/})" = "ash" ] && currentShell=".ashrc" [ "$(echo ${SHELL##*/})" = "bash" ] && currentShell=".bashrc" fi echo $currentShell } ######################################################################### # Usage ######################################################################### Usage() { echo "$PN - toolarium common build installer v$CB_INSTALLER_VERSION" echo "usage: $PN [OPTION]" echo "" echo "Overview of the available OPTIONs:" echo " -h, --help Show this help message." echo " -v, --version Print the version information." echo " --silent Suppress the console output." echo " --force Force to reinstall the common-build." echo " --draft Also considers draft / pre-release versions." echo "" } ######################################################################### # Version ######################################################################### Version() { echo "$CB_LINE" echo "toolarium common build installer $CB_INSTALLER_VERSION" echo "$CB_LINE" echo "" } ######################################################################### # installationSuccess ######################################################################### installationSuccess() { msgInfo="or type in . ~/.bashrc" [ "$(echo ${SHELL##*/})" = "zsh" ] && msgInfo="or type in . ~/.zshrc" [ "$(echo ${SHELL##*/})" = "ash" ] && msgInfo="or type in . ~/.ashrc" [ "$(echo ${SHELL##*/})" = "bash" ] && msgInfo="or type in . ~/.bashrc" if [ "$CB_INSTALLER_SILENT" = "false" ]; then echo "${CB_LINEHEADER}Successfully installed toolarium-common-build $releaseVersion." echo "${CB_LINEHEADER}The \$PATH is extended and you can start working with the command cb." echo "" read -p "Press any key to continue..." inputHowTo echo "" eval $CB_HOME/bin/include/how-to.sh 2>/dev/null | more echo "" echo "$CB_LINE" echo "${CB_LINEHEADER}Please re-login $msgInfo, before you start." [ -n "$(existBinary unzip)" ] || echo "${CB_LINEHEADER}Missing package unzip, please install it before you continue!" [ -n "$(existBinary find)" ] || echo "${CB_LINEHEADER}Missing package find, please install it before you continue!" #[ -n "$(existBinary xz)" ] || echo "${CB_LINEHEADER}Missing package xz, please install it before you continue!" echo "$CB_LINE" echo "" fi } ######################################################################### # installationFailed ######################################################################### installationFailed() { echo "$CB_LINE" echo "Failed installation: $1" [ -r "$cbErrorTemp" ] && cat "$cbErrorTemp" 2>/dev/null echo "$CB_LINE" } ######################################################################### # checkInternetConnection ######################################################################### checkInternetConnection() { [ -z "$CB_ONLINE_ADDRESS" ] && CB_ONLINE_ADDRESS="8.8.8.8" [ -z "$CB_ONLINE_ADDRESS_PORT" ] && CB_ONLINE_ADDRESS_PORT="53" [ -z "$CB_ONLINE_TIMEOUT" ] && CB_ONLINE_TIMEOUT="2" timeout "$CB_ONLINE_TIMEOUT bash" -c "/dev/null 2>&1 && CB_OFFLINE=true || CB_OFFLINE=false [ "$CB_OFFLINE" = "true" ] && installationFailed "No internet connection detected." && exit 1 } ######################################################################### # checkHttpRequestCLI ######################################################################### checkHttpRequestCLI() { [ -n "$(existBinary curl)" ] && echo $(existBinary curl) && return [ -n "$(existBinary wget)" ] && echo $(existBinary wget) && return echo "" } ######################################################################### # get newest cb json support ######################################################################### getCBJson() { if ! [ -x "$CB_JSON" ]; then CB_JSON="$CB_TEMP/cb-json" export CB_JSON [ -z "${HTTP_REQUEST_CLI##*curl*}" ] && CMD="curl -# -sSL" || CMD="wget -q -O - /dev/null" CMD="$CMD $CB_JSON_SCRIPT_URL 2>\"$cbErrorTemp\" > $CB_JSON" echo "${CB_LINEHEADER}Get json support..." eval $CMD && chmod 755 $CB_JSON fi } ######################################################################### # getLatestRelease ######################################################################### getLatestRelease() { [ -z "${HTTP_REQUEST_CLI##*curl*}" ] && CMD="curl -# -fsSL $CB_GITHUB_AUTH" || CMD="wget -q --header=\"Accept: application/json\" $CB_GITHUB_AUTH_WGET -O -" CMD="$CMD $CB_RELEASE_URL 2>\"$cbErrorTemp\" | $CB_JSON" [ "$1" = "true" ] && CMD="$CMD --filter \"prerelease=false\"" CMD="$CMD --value --name name" version=$(eval "$CMD") [ $? -eq 0 ] && echo "$version" || echo "" } ######################################################################### # getRelease ######################################################################### getRelease() { [ -z "${HTTP_REQUEST_CLI##*curl*}" ] && CMD="curl -# -fsSL $CB_GITHUB_AUTH" || CMD="wget -q --header=\"Accept: application/json\" $CB_GITHUB_AUTH_WGET -O -" CMD="$CMD $CB_RELEASE_URL 2>\"$cbErrorTemp\" | $CB_JSON --filter \"name=(v)?$1\\\"\" --value --name name" version=$(eval "$CMD" 2>>"$cbErrorTemp") [ $? -eq 0 ] && echo "$version" || echo "" } ######################################################################### # getReleaseDownloadUrl ######################################################################### getReleaseDownloadUrl() { [ -z "${HTTP_REQUEST_CLI##*curl*}" ] && CMD="curl -# -fsSL $CB_GITHUB_AUTH" || CMD="wget -q --header=\"Accept: application/json\" $CB_GITHUB_AUTH_WGET -O -" CMD="$CMD $CB_RELEASE_URL 2>\"$cbErrorTemp\" | $CB_JSON" [ "$1" = "true" ] && CMD="$CMD --filter \"prerelease=false\"" CMD="$CMD --filter \"name=(v)?$1\\\"\" --value --name tarball_url" downloadUrl=$(eval "$CMD" 2>>"$cbErrorTemp") [ $? -eq 0 ] && echo "$downloadUrl" || echo "" } ######################################################################### # downloadRelease ######################################################################### downloadRelease() { [ -z "${HTTP_REQUEST_CLI##*curl*}" ] && CMD="curl -# -SsL $CB_GITHUB_AUTH \"$1\" -o \"$2\"" || CMD="wget -q $CB_GITHUB_AUTH_WGET -O \"$2\" \"$1\"" eval "$CMD" 2>"$cbErrorTemp" } ######################################################################### # error handler ######################################################################### errorhandler() { [ -n "$DEBUG" ] && echo "${CB_LINEHEADER}ERROR on line #$LINENO, last command: $BASH_COMMAND" exithandler } ######################################################################### # exit handler ######################################################################### exithandler() { rm $CB_TEMP/cb-json >/dev/null 2>&1 rm -f "$cbErrorTemp" >/dev/null 2>&1 } ######################################################################### # update the shell initialisation ######################################################################### updateShellInitialisation() { [ -z "$1" ] && return shellProfile="$1" # in case it does not exist, just create empty file ! [ -f "$shellProfile" ] && touch "$shellProfile" >/dev/null 2>&1 && chmod +r+w "$shellProfile" >/dev/null 2>&1 if [ -w "$shellProfile" ]; then backupFileName="${shellProfile}_cb-$(eval $FULLTIMESTAMP)" cp "$shellProfile" "$backupFileName" >/dev/null 2>&1 && chmod +r "$backupFileName" >/dev/null 2>&1 shellResult=$(cat "$shellProfile" | grep 'toolarium-common-build support') if [ -z "$shellResult" ]; then [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Modify file $shellProfile" echo "" >> "$shellProfile" echo "# toolarium-common-build support" >> "$shellProfile" echo "$CB_SHELL_INITIALISATION_CMD" >> "$shellProfile" else newFileName="${shellProfile}_cb-new" rm -f "$newFileName" >/dev/null 2>&1 #TEST: CB_HOME="$CB_HOME/aa" CB_HOME_ESCAPED=$(echo "$CB_HOME" | sed 's/\//\\\//g;s/ /\\ /g') [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Update file $shellProfile" cat "$shellProfile" | sed "s/CB_HOME\=.*\&/CB_HOME\=\"$CB_HOME_ESCAPED\"\ \&\&/g" > "$newFileName" chmod --reference="$shellProfile $newFileName" >/dev/null 2>&1 chmod +r+w "$newFileName" >/dev/null 2>&1 mv -f "$newFileName" "$shellProfile" >/dev/null 2>&1 fi if [ -n "$CB_DEVTOOLS_INITIALISATION_CMD" ]; then devtoolsMarker="# toolarium-common-build devtools support" if grep -Fxq "$CB_DEVTOOLS_INITIALISATION_CMD" "$shellProfile" 2>/dev/null; then : # already up-to-date elif grep -Fxq "$devtoolsMarker" "$shellProfile" 2>/dev/null; then newFileName="${shellProfile}_cb-new" rm -f "$newFileName" >/dev/null 2>&1 [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Update devtools initialisation in $shellProfile" awk -v marker="$devtoolsMarker" -v cmd="$CB_DEVTOOLS_INITIALISATION_CMD" ' replace_next { print cmd; replace_next=0; next } { print } $0 == marker { replace_next=1 } ' "$shellProfile" > "$newFileName" chmod --reference="$shellProfile" "$newFileName" >/dev/null 2>&1 chmod +r+w "$newFileName" >/dev/null 2>&1 mv -f "$newFileName" "$shellProfile" >/dev/null 2>&1 else [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Add devtools initialisation to $shellProfile" echo "" >> "$shellProfile" echo "$devtoolsMarker" >> "$shellProfile" echo "$CB_DEVTOOLS_INITIALISATION_CMD" >> "$shellProfile" fi fi if ! [ -n "$(diff "$backupFileName" "$shellProfile" 2>/dev/null)" ]; then # no change — remove the backup entirely rm -f "$backupFileName" >/dev/null 2>&1 else # change detected — keep the 3 most recent backups in place, # move any older ones to $CB_HOME/backup/ backupDir="$CB_HOME/backup" ! [ -d "$backupDir" ] && mkdir -p "$backupDir" >/dev/null 2>&1 # list all backups for this profile, newest first; skip the 3 # most recent and move the rest oldBackups=$(ls -1t "${shellProfile}_cb-"* 2>/dev/null | tail -n +4) if [ -n "$oldBackups" ]; then echo "$oldBackups" | while IFS= read -r f; do [ -n "$f" ] && mv -f "$f" "$backupDir/" >/dev/null 2>&1 done fi fi else echo "${CB_LINEHEADER}Can not set CB_HOME in $shellProfile, it's write protected." fi } ######################################################################### # main ######################################################################### trap 'exithandler $?; exit' 0 trap 'errorhandler $?; exit' 1 2 3 15 CB_INSTALL_PARAMETERS= # check curl while [ $# -gt 0 ] do case "$1" in -h) Usage; exit 0;; --help) Usage; exit 0;; -v) Version; exit 0;; --version) Version; exit 0;; --silent) CB_INSTALLER_SILENT=true;; --force) CB_FORCE_INSALL=true;; --draft) CB_INSTALL_ONLY_STABLE=false;; *) CB_INSTALL_PARAMETERS="$CB_INSTALL_PARAMETERS $1";; esac shift done if [ "$CB_INSTALLER_SILENT" = "false" ]; then CB_VERSION_INFO= machineName=$(hostname 2>/dev/null) ! [ -n "$machineName" ] && machineName="$HOSTNAME" [ -n "$CB_VERSION" ] && CB_VERSION_INFO=" $CB_VERSION" echo "$CB_LINE" echo "${CB_LINEHEADER}Thank you for installing toolarium-common-build$CB_VERSION_INFO on $machineName" echo "${CB_LINEHEADER}Use $CB_DEVTOOLS path as devtools folder, $(eval "$USER_FRIENDLY_FULLTIMESTAMP")" echo "$CB_LINE" read -p "Press any key to continue..." input echo "" fi HTTP_REQUEST_CLI=$(checkHttpRequestCLI) ! [ -n "$HTTP_REQUEST_CLI" ] && installationFailed "Either curl or wget is required, please install it before you continue!" && exit 1 ! [ -n "$(existBinary tar)" ] && installationFailed "Missing package tar, please install it before you continue!" && exit 1 ! [ -n "$(existBinary unzip)" ] && installationFailed "Missing package unzip, please install it before you continue!" && exit 1 ! [ -n "$(existBinary find)" ] && echo "${CB_LINEHEADER}Missing package find, please install it before you continue!" && exit 1 ! [ -n "$(existBinary diff)" ] && echo "${CB_LINEHEADER}Missing package diff, please install it before you continue!" && exit 1 checkInternetConnection if [ "$CB_INSTALLER_SILENT" = "false" ]; then [ -z "$CB_INSTALL_PARAMETERS" ] && echo "${CB_LINEHEADER}Check newest version of toolarium-common-build..." [ -n "$CB_INSTALL_PARAMETERS" ] && echo "${CB_LINEHEADER}Check version ${CB_INSTALL_PARAMETERS# *} of toolarium-common-build..." fi # check common build json support getCBJson CB_VERSION= if [ -n "$CB_INSTALL_PARAMETERS" ]; then CB_VERSION=$CB_INSTALL_PARAMETERS [ "${CB_VERSION#v*}" = "$CB_VERSION" ] || CB_VERSION="v$CB_VERSION" releaseVersion=$(getRelease $CB_VERSION) else releaseVersion=$(getLatestRelease $CB_INSTALL_ONLY_STABLE) fi [ -z "$releaseVersion" ] && installationFailed "Could not get remote release information." && exit 1 [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Latest version of common-build is $releaseVersion, select download link" downloadUrl=$(getReleaseDownloadUrl $releaseVersion) [ -z "$downloadUrl" ] && installationFailed "Could not get download url of verison $releaseVersion." && exit 1 rm -f "$cbErrorTemp" >/dev/null 2>&1 CB_VERSION_NAME="toolarium-common-build-$releaseVersion" # create directories ! [ -d "$CB_DEVTOOLS" ] && mkdir "$CB_DEVTOOLS" >/dev/null 2>&1 && echo "${CB_LINEHEADER}Create directory $CB_DEVTOOLS" CB_DEV_REPOSITORY="$CB_DEVTOOLS/.repository" ! [ -d "$CB_DEV_REPOSITORY" ] && mkdir "$CB_DEV_REPOSITORY" >/dev/null 2>&1 # download toolarium-common-build [ "$CB_FORCE_INSALL" = "true" ] && rm -f "$CB_DEV_REPOSITORY/$CB_VERSION_NAME.tgz" >/dev/null 2>&1 if [ -r "$CB_DEV_REPOSITORY/$CB_VERSION_NAME.tgz" ]; then [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Found already downloaded version, $CB_DEV_REPOSITORY/$CB_VERSION_NAME.tgz" else [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Install $CB_VERSION_NAME" downloadRelease "$downloadUrl" "$CB_DEV_REPOSITORY/$CB_VERSION_NAME.tgz" # in case we donwload a new version we also extract new ! [ -r "$CB_DEV_REPOSITORY/$CB_VERSION_NAME.tgz" ] && installationFailed "Could not download version $releaseVersion." && exit 1 [ $(getFileSize "$CB_DEV_REPOSITORY/$CB_VERSION_NAME.tgz") -gt 0 ] && rm -rf "$CB_DEVTOOLS/$CB_VERSION_NAME" >/dev/null 2>&1 fi if ! [ -r "$CB_DEVTOOLS/$CB_VERSION_NAME" ]; then [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Extract $CB_VERSION_NAME.tgz in $CB_DEVTOOLS..." tar -zxf "$CB_DEV_REPOSITORY/$CB_VERSION_NAME.tgz" -C "$CB_DEV_REPOSITORY/" >/dev/null 2>&1 tarContentName=$(find "$CB_DEV_REPOSITORY" -type d -name 'toolarium-common-build-*' -print 2>/dev/null) mv "$tarContentName" "$CB_DEVTOOLS/$CB_VERSION_NAME" >/dev/null 2>&1 # remove unecessary files (keep docs/ - it ships the release documentation) rm "$CB_DEVTOOLS/$CB_VERSION_NAME/.gitattributes" >/dev/null 2>&1 rm "$CB_DEVTOOLS/$CB_VERSION_NAME/.gitignore" >/dev/null 2>&1 rm "$CB_DEVTOOLS/$CB_VERSION_NAME/README.md" >/dev/null 2>&1 rm "$CB_DEVTOOLS/$CB_VERSION_NAME/CLAUDE.md" >/dev/null 2>&1 rm -rf "$CB_DEVTOOLS/$CB_VERSION_NAME/.git" >/dev/null 2>&1 rm -rf "$CB_DEVTOOLS/$CB_VERSION_NAME/.github" >/dev/null 2>&1 rm -rf "$CB_DEVTOOLS/$CB_VERSION_NAME/.claude" >/dev/null 2>&1 rm -rf "$CB_DEVTOOLS/$CB_VERSION_NAME/testdata" >/dev/null 2>&1 rm -rf "$CB_DEVTOOLS/$CB_VERSION_NAME/test" >/dev/null 2>&1 rm -rf "$CB_DEVTOOLS/$CB_VERSION_NAME/bin/testing" >/dev/null 2>&1 # be sure we have proper permissions chmod -R +x "$CB_DEVTOOLS/$CB_VERSION_NAME/bin" >/dev/null 2>&1 mkdir "$CB_DEVTOOLS/$CB_VERSION_NAME/current" >/dev/null 2>&1 fi if ! [ "$CB_HOME" = "$CB_DEVTOOLS/$CB_VERSION_NAME" ]; then # read previous version CB_HOME_PREVIOUS="" CB_PREVIOUS_VERSION_NAME="" if [ -n "$CB_HOME" ] && [ -d "$CB_HOME" ] && [ -n "$(existBinary cb)" ]; then CB_HOME_PREVIOUS="$CB_HOME" CB_PREVIOUS_VERSION_NAME=$(cb --version 2>/dev/null | grep "toolarium" | awk '{print $4}') [ -n "$CB_PREVIOUS_VERSION_NAME" ] && [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Found previous version $CB_PREVIOUS_VERSION_NAME: $CB_HOME_PREVIOUS" fi [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Set CB_HOME to $CB_DEVTOOLS/$CB_VERSION_NAME" export CB_HOME="$CB_DEVTOOLS/$CB_VERSION_NAME" export PATH="$CB_HOME/bin:$PATH" CB_SHELL_INITIALISATION_CMD="export CB_HOME=\"$CB_HOME\" && export PATH=\"\$CB_HOME/bin:\$PATH\"" CB_DEVTOOLS_INITIALISATION_CMD="source cb --setenv > /dev/null" [ -n "$(existBinary bash)" ] && updateShellInitialisation "$HOME/.bashrc" [ -n "$(existBinary ash)" ] && updateShellInitialisation "$HOME/.ashrc" [ -n "$(existBinary zsh)" ] && updateShellInitialisation "$HOME/.zshrc" if [ -n "$(existBinary fish)" ]; then if ! [ -d "$HOME/.config/fish/" ]; then mkdir -p "$HOME/.config/fish/" >/dev/null 2>&1 chmod -R 750 "$HOME/.config" >/dev/null 2>&1 fi CB_SHELL_INITIALISATION_CMD="export CB_HOME=\"$CB_HOME\" ; and export PATH=\"\$CB_HOME/bin:\$PATH\"" #CB_DEVTOOLS_INITIALISATION_CMD="export PATH=\"\${PATH}:\$(cb --setenv|sed 's/^.*(//;s/).*//g'|xargs|sed 's/ /:/g')\"" CB_DEVTOOLS_INITIALISATION_CMD="" updateShellInitialisation "$HOME/.config/fish/config.fish" fi if [ -n "$(existBinary nu)" ]; then if ! [ -d "$HOME/.config/nushell/" ]; then mkdir -p "$HOME/.config/nushell/" >/dev/null 2>&1 chmod -R 750 "$HOME/.config" >/dev/null 2>&1 fi nuHelperFile="$HOME/.config/nushell/cb-setenv.nu" [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Create Nushell helper $nuHelperFile" cat > "$nuHelperFile" </dev/null 2>&1 envNuFile="$HOME/.config/nushell/env.nu" ! [ -f "$envNuFile" ] && touch "$envNuFile" >/dev/null 2>&1 if [ -w "$envNuFile" ]; then if ! grep -q 'cb-setenv.nu' "$envNuFile" 2>/dev/null; then [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Add source line to $envNuFile" echo "" >> "$envNuFile" echo "# toolarium-common-build support" >> "$envNuFile" echo "source ~/.config/nushell/cb-setenv.nu" >> "$envNuFile" fi fi fi # take over symbol link and config if [ -d "$CB_HOME_PREVIOUS/current" ]; then [ "$CB_INSTALL_SILENT" = "false" ] && echo "${CB_LINEHEADER}Copy symbolic link..." ( cd "$CB_HOME_PREVIOUS/current" ; tar cf - . ) | ( cd "$CB_HOME/current" ; tar xf - ) fi if [ -r "$CB_HOME_PREVIOUS/conf/tool-version-installed.properties" ]; then [ "$CB_INSTALLER_SILENT" = "false" ] && echo "${CB_LINEHEADER}Copy tool-version-installed.properties..." cp "$CB_HOME_PREVIOUS/conf/tool-version-installed.properties" "$CB_HOME/conf/tool-version-installed.properties" >/dev/null 2>&1 fi fi installationSuccess ######################################################################### # EOF #########################################################################