#!/usr/bin/env bash # # Author: Georg Voell - georg.voell@standby.cloud # Version: @(#)install-tools 3.3.0 19.01.2026 (c)2026 Standby.cloud # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ # # This script can be used free of charge. Use it as is or customize as needed. It is not guaranteed to be # error free and you will not be reimbursed for any damage it may cause. # #@ This script downloads basic tools for Oracle Cloud and installs them. #@ If tools are already installed, the script will try to update them. #@ #@Usage: install-tools [options] #@ Options: #@ -h, --help : Displays helptext. #@ -v, --version: Displays the version of the script. # # It uses 'yum' and 'rpm' packages where it is possible. # A log file 'install-tools' will be created in '/var/log'. # Installed tools with version will be created at '${HOME}/.tools-installed'. # # Supported platforms: # # Oracle Linux Server 7.x, 8.x and 9.x # Oracle Autonomous Linux Server 7.x, 8.x and 9.x # # Usage: # # This script is called by 'setup-tools'. To update scripts and tools, # use 'setup-tools update'. It is also possible to call this script directly: # # sudo su - # curl --silent https://standby.cloud/download/beta/install-tools | bash # # or download the script and make it executable e.g.: # # curl --silent https://standby.cloud/download/beta/install-tools -o /usr/local/bin/install-tools # chmod 700 /usr/local/bin/install-tools # # Update history: # # V 1.0.0 18.04.2020 New version # V 3.0.1 11.06.2020 Using library # V 3.0.2 16.09.2020 Use new download URL: https://standby.cloud/download # V 3.0.3 22.09.2020 Install tools for Debian (Ubuntu) # V 3.0.4 26.09.2020 Update repository tools only if asked for (in setup-tools) # V 3.0.5 31.01.2021 Install Ansible # V 3.0.6 03.09.2022 Minor changes while installing ZIPs # V 3.0.7 05.06.2023 Using Python3.8 if available and fixing problem during psm-cli installation # V 3.1.0 05.06.2023 New copyright # V 3.1.1 23.08.2023 Use oci-utils and ocifs, fix for python3.8 on Linux 8 # V 3.2.0 11.09.2024 New minor version # V 3.2.1 10.08.2025 Download from Objectstorage # V 3.2.2 18.08.2025 Removing rpm packages # V 3.3.0 19.01.2026 Revised with support of Claude Code # # Specify scriptname scriptname=$(echo "$0" | sed 's|^[-]*||') if [[ "$scriptname" = "bash" ]]; then scriptname="install-tools" fi # Specify home of library progdir=$(dirname "$scriptname") if [[ ! -r "${progdir}/lib.bash" ]]; then progdir="/usr/local/bin" if [[ ! -r "${progdir}/lib.bash" ]]; then if [[ "$SUDO_USER" != "" ]]; then export REALHOME=$(eval echo ~${SUDO_USER}) else export REALHOME="$HOME" fi progdir="${REALHOME}/.local/bin" if [[ ! -r "${progdir}/lib.bash" ]]; then lib=$(command -v lib.bash 2>/dev/null) if [[ "$lib" = "" ]]; then echo "Unexpected error: Unable to locate bash library 'lib.bash'." exit 1 else progdir=$(dirname "$lib") fi fi fi fi # Source Library source "${progdir}/lib.bash" # Define default variables instjava=false baseurl="https://standby.cloud/download" storageurl="https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/frcc4jd4wdkp/b/download/o" cdir=$(pwd) # Current working directory wdir="/tmp/tools" # Working directory # param="$(ToLower "$1")" curdate=$(date "+%Y-%m-%d %T") repodir="/etc/yum.repos.d" toolsname="tools" scriptsname="scripts" templatesname="templates" setupname="setup-tools" if [[ "$USER" = "root" ]]; then userhome="/usr/local" else userhome="${REALHOME}/.local" fi binfolder="${userhome}/bin" libfolder="${userhome}/lib" # lib64 manfolder="${userhome}/share/man" infofolder="${userhome}/share/info" appfolder="${userhome}/share/applications" templatesfolder="${userhome}/share/$templatesname" toolsfile="${infofolder}/installed-${toolsname}.txt" scriptsfile="${infofolder}/installed-${scriptsname}.txt" manfile="${infofolder}/installed-manuals.txt" manfile2="${infofolder}/installed-cmd-manuals.txt" templatesfile="${infofolder}/installed-${templatesname}.txt" zipsfile="${infofolder}/installed-zips.txt" libsfile="${infofolder}/installed-libs.txt" # cloudfile="${infofolder}/cloud.json" # Logfile if [[ "$LOGFILE" != "" ]]; then logfile="$LOGFILE" else if [[ "$USER" = "root" ]]; then if [[ ! -d "/var/log" ]]; then mkdir -p "/var/log" fi logfile="/var/log/${progstr}.log" else logfile="${REALHOME}/${progstr}.log" fi fi # Do extra cleanup function ExtraCleanup() { if [[ -d "$wdir" ]]; then rm -fR $wdir fi } # Download a filelist with tools to install function DownloadFileList() { filelist=${1} silent=${2} transfer --quiet ${baseurl}/lists/$filelist > ${wdir}/$filelist status=$? if (( status != 0 )); then exitcode=6 if [[ "$silent" != "true" ]]; then errormsg $exitcode "($progstr) Could not download filelist '$filelist'." "CURL could not establish a connection to server" fi filecheck -rm ${wdir}/$filelist return $exitcode else cmd="$(cat ${wdir}/$filelist | head -n 1 | cut -d$'\t' -f1)" if [[ "$cmd" != "cmd" ]]; then exitcode=6 errormsg $exitcode "($progstr) Corrupt filelist '$filelist'." "Download not successful" filecheck -rm ${wdir}/$filelist return $exitcode fi fi } # Install the templates needed by cloud tools function InstallTemplates() { # Create template folder if it doesn't exists if [[ ! -d "$templatesfolder" ]]; then # Create config folder mkdir -m 0755 -p "$templatesfolder" printf "Created folder '$templatesfolder'.\n" fi # Download templates list rfile="${templatesname}.txt" DownloadFileList $rfile "true" stat=$? # Check if we can download from internet - if not, try to download from Objectstorage if (( stat != 0 )); then baseurl="$storageurl" DownloadFileList $rfile stat=$? fi # Install every template in filelist if [[ -f "${wdir}/${templatesname}.txt" ]]; then echo "Installing 'templates'." if [[ "$param" != "download" ]]; then printf "%s\n" "template" > $templatesfile fi while IFS=$'\t' read -r cmd tfile; do if [[ "$cmd" != "" && "$tfile" != "" ]]; then # Create the workdir folders if [[ ! -d "${wdir}/${templatesname}/$cmd" ]]; then # Create templates folder mkdir -p "${wdir}/${templatesname}/$cmd" fi # Download the template transfer --quiet "${baseurl}/${templatesname}/${cmd}/$tfile" --export "${wdir}/${templatesname}/${cmd}/$tfile" status=$? if (( status != 0 )); then echo "Could not download template '${templatesname}/${cmd}/$tfile'." if [[ -f "${wdir}/${templatesname}/${cmd}/$tfile" ]]; then filecheck -rm "${wdir}/${templatesname}/${cmd}/$tfile" fi else # result=$(file "${wdir}/${templatesname}/${cmd}/$tfile" | grep "HTML document") # if [ "$result" != "" ]; then line="$(cat ${wdir}/${templatesname}/${cmd}/$tfile | head -n 1)" if [[ "$line" = "" ]]; then echo "Corrupt template '${templatesname}/${cmd}/$tfile'." filecheck -rm "${wdir}/${templatesname}/${cmd}/$tfile" fi fi # Install the template if [[ "$param" != "download" ]]; then if [[ -f "${wdir}/${templatesname}/${cmd}/$tfile" ]]; then # Create the config folders if [[ ! -d "${templatesfolder}/$cmd" ]]; then # Create templates folder mkdir -p "${templatesfolder}/$cmd" fi cp "${wdir}/${templatesname}/${cmd}/$tfile" "${templatesfolder}/${cmd}/$tfile" chmod 644 "${templatesfolder}/${cmd}/$tfile" printf "%s\n" "${templatesfolder}/${cmd}/$tfile" >> $templatesfile fi fi fi done < <(tailfromline2 "${wdir}/${templatesname}.txt" | StripComment) fi } # Update mandb with new manuals function UpdateWhatis() { # Create mandb case "$OS" in Darwin) makewhatis=$(filecheck -x "/usr/libexec/makewhatis") if [[ "$makewhatis" != "" ]]; then filecheck -rm "${manfolder}/whatis" $makewhatis "${manfolder}" >> $logfile 2>&1 fi ;; Linux) mandb=$(filecheck -x mandb) if [[ "$mandb" != "" ]]; then $mandb "${manfolder}" >> $logfile 2>&1 fi ;; SunOS) catman=$(filecheck -x catman) if [[ "$catman" != "" ]]; then $catman -M "${manfolder}" >> $logfile 2>&1 fi ;; esac } function InstallDarwin() { printf "\nInstalling Tools for %s.\n" "$name" printf "OS: %s\n" "$pretty_name" printf "ARCH: %s/%s\n\n" "$proc" "$bits" # Check if we have pkgutil and installer available # installer -pkg /path/to/package.pkg -target / # pkgutil --expand /Volumes/Prog/program.mpkg ~/Desktop/folder or pkgutil --packages pkgutil=$(filecheck -x pkgutil) installer=$(filecheck -x installer) } function InstallSunOS() { printf "\nInstalling Tools for %s.\n" "$name" printf "OS: %s\n" "$pretty_name" printf "ARCH: %s/%s\n\n" "$proc" "$bits" exitcode=5 errormsg $exitcode "($progstr) Unsupported platform." return $exitcode } function InstallSolarisIPS() { printf "\nInstalling Tools for %s.\n" "$name" printf "OS: %s\n" "$pretty_name" printf "ARCH: %s/%s\n\n" "$proc" "$bits" # Since Solaris 11 we are using IPS (Image Packaging System) # # Solaris Package Repository: http://pkg.oracle.com/solaris/release/en/catalog.shtml # # Package Management Task IPS Command Oracle Solaris 10 Equivalent # Install package. pkg install pkgadd -a # Display package state and version info. pkg list pkginfo # Verify package installation. pkg verify pkgchk -v # Display package information. pkg info pkginfo -v # Display the contents of a package. pkg contents pkgchk -l # Search for a package. pkg search pkgchk -l -p # Uninstall a package. pkg uninstall pkgrm # Install package updates. pkg update pkgadd # # Update all packages: pkg update -nv # Display publisher: pkg publisher # # Search for component in PKG and fix it if errors occur: # # pkg search -l /usr/bin/gcc # pkg verify developer/gcc # pkg fix developer/gcc # Check if we have pkg and pkgadd available # pkg install vim@latest # pkg search -r \ # pkg --accept install zip # pkg list -g file:///extract-directory/oracle-hmp-2.2.7-SunOS-5.11.p5p # pkg list *toolkit* # pkg set-publisher -g /net/repo_server2/sol_11_repo/ # pkg set-publisher --disable # pkg set-publisher --enable # pkg update -nv # pkgadd -d device_name pkgid # pkgchk -v pkgid # /usr/sbin/pkgadd -d /cdrom/sol_8_sparc/Solaris_8/Product SUNWaudio # pkgrm pkgid pkg=$(filecheck -x pkg) pkgadd=$(filecheck -x pkgadd) if [[ "$pkg" = "" && "$pkgadd" = "" ]]; then exitcode=5 errormsg $exitcode "($progstr) No 'pkg' or 'pkgadd' in '$PATH'. Can't install tools." return $exitcode else if [[ "$pkgadd" = "" ]]; then echo "Installing 'pkgadd'." >> $logfile echo "Installing 'pkgadd'." else echo "Updating 'pkgadd'." >> $logfile echo "Updating 'pkgadd'." fi $pkg install --accept SUNWpkgcmds >> $logfile 2>&1 stat=$? # Check if we could install pkgadd if (( stat == 1 )); then if [[ ! -d /var/pkg/ssl ]]; then mkdir -m 0755 -p /var/pkg/ssl fi transfer --quiet ${baseurl}/pack/certs/pkg.oracle.com.key.pem > /var/pkg/ssl/pkg.oracle.com.key.pem transfer --quiet ${baseurl}/pack/certs/pkg.oracle.com.certificate.pem > /var/pkg/ssl/pkg.oracle.com.certificate.pem # Configure repository $pkg set-publisher \ -k /var/pkg/ssl/pkg.oracle.com.key.pem \ -c /var/pkg/ssl/pkg.oracle.com.certificate.pem \ -G "*" -g https://pkg.oracle.com/solaris/support/ solaris # Enable developer components are being installed $pkg change-facet facet.devel=true >> $logfile 2>&1 $pkg install --accept SUNWpkgcmds >> $logfile 2>&1 stat=$? # Check if pkgadd was installed pkgadd=$(filecheck -x pkgadd) fi if [[ $stat -eq 1 || "$pkgadd" = "" ]]; then exitcode=5 errormsg $exitcode "($progstr) Unknown error while installing tool 'SUNWpkgcmds' (pkgadd). Is publisher working?" $pkg publisher return $exitcode else # Install pkgutil (Software will be installed in /opt/csw/bin) yes | $pkgadd -d http://get.opencsw.org/now all >> $logfile 2>&1 /opt/csw/bin/pkgutil -U >> $logfile 2>&1 fi # Install java separate if [[ "$instjava" = "true" ]]; then cmd="java" apply="jdk-8" tool=$(filecheck -x $cmd) if [[ "$tool" = "" ]]; then echo "Installing '$cmd'." >> $logfile echo "Installing '$cmd'." else echo "Updating '$cmd'." >> $logfile echo "Updating '$cmd'." fi $pkg install --accept $apply >> $logfile 2>&1 fi # Download pkg-list rfile="pkg.txt" DownloadFileList $rfile stat=$? # Install each pkg in file if [[ $stat -eq 0 && -f ${wdir}/$rfile ]]; then while IFS=$'\t' read -r cmd apply; do if [[ "$cmd" != "" && "$apply" != "" ]]; then tool=$(filecheck -x $cmd) if [[ "$tool" = "" ]]; then echo "Installing '$cmd'." >> $logfile echo "Installing '$cmd'." else echo "Updating '$cmd'." >> $logfile echo "Updating '$cmd'." fi $pkg install --accept $apply >> $logfile 2>&1 fi done < <(tailfromline2 "${wdir}/$rfile" | StripComment) fi fi } function InstallSuse() { printf "\nInstalling Tools for Linux (SUSE Linux Enterprise Server or openSUSE Linux).\n" printf "OS: %s\n" "$pretty_name" printf "ARCH: %s/%s\n\n" "$proc" "$bits" # Check if we have zypper available zypper=$(filecheck -x zypper) exitcode=5 errormsg $exitcode "($progstr) Unsupported platform." return $exitcode } function InstallAlpine() { printf "\nInstalling Tools for Linux (Alpine).\n" printf "OS: %s\n" "$pretty_name" printf "ARCH: %s/%s\n\n" "$proc" "$bits" # Check if we have apk available apk=$(filecheck -x apk) if [[ "$apk" != "" ]]; then $apk update # Update the index of available packages # apk add python2-dev # for python2.x installs # apk add python3-dev # for python3.x installs # apk add libc-dev fi exitcode=5 errormsg $exitcode "($progstr) Unsupported platform." return $exitcode } function InstallFedora() { printf "\nInstalling Tools for Linux (Fedora).\n" printf "OS: %s\n" "$pretty_name" printf "ARCH: %s/%s\n\n" "$proc" "$bits" # Check if we have dnf available yum=$(filecheck -x yum) dnf=$(filecheck -x dnf) if [[ "$dnf" = "" ]]; then $yum install -y dnf dnf=$(filecheck -x dnf) fi if [[ "$dnf" != "" ]]; then # dnf install python2-devel # for python2.x installs # dnf install python3-devel # for python3.x installs echo "More to come." fi exitcode=5 errormsg $exitcode "($progstr) Unsupported platform." return $exitcode } function CheckRepolist() { local toolsrepo=${1} local status=1 while (( status != 0 )); do if [[ -f "${toolsrepo}.osms-backup" ]]; then mv -f "${toolsrepo}.osms-backup" "${toolsrepo}" fi $yum repolist all >> $logfile status=$? done } # ToDO: Not ready for download, yet function ApplyRPM() { local cmd=${1} local apply=${2} local result="" $rpm -q $apply > /dev/null 2>&1 status=$? if (( status != 0 )); then result=$(filecheck -x $cmd) if [[ "$result" = "" ]]; then echo "Installing RPM: $apply" else echo "Updating RPM: $apply" fi $yum install -y $apply >/dev/null 2>&1 status=$? if (( status == 0 )); then pkg=$($rpm -q $apply) echo "$apply installed. Package: $pkg" >> $logfile else echo "$apply not installed." >> $logfile fi fi } function InstallRedHat() { printf "\nInstalling Tools for Linux (Oracle Linux, Red Hat Enterprise Server or CentOS).\n" printf "OS: %s\n" "$pretty_name" printf "ARCH: %s/%s\n\n" "$proc" "$bits" if [[ "$yum" = "" || "$rpm" = "" ]]; then exitcode=5 errormsg $exitcode "($progstr) No 'yum' or 'rpm' in '$PATH'." return $exitcode else osname="$pretty_name" plat="el$version_main" SAVEDLANG="$LANG" export LANG="C" # "C.UTF-8" # Check repolist # $yum makecache fast >> $logfile 2>&1 # CheckRepolist echo "Creating cache for yum." $yum makecache >> $logfile 2>&1 # Only test this on Oracle Enterprise Linux oa="" if [[ "$name" = "Oracle Linux Server" ]]; then # Check if we have autonomous linux installed $rpm -q alx-utils > /dev/null 2>&1 # al-config status=$? if (( status != 0 )); then # Check with rpm if release manager is already installed $rpm -q oraclelinux-release-$plat > /dev/null 2>&1 status=$? if (( status != 0 )); then exitcode=6 errormsg $exitcode "($progstr) Oracle Release Manager not installed. Try 'yum install oraclelinux-release-$plat'." return $exitcode fi else # Autonomous linux found oa="auto" fi fi # First install if [[ ! -f $toolsfile ]]; then case "$version_main" in 6 | 7) # Applying deltarpm and others (if it can be found) # Default: OL7, OL8: Python36, OL9: Python39, OL10: Python312 ApplyRPM "makedeltarpm" "deltarpm" ApplyRPM "ansible" "ansible" python3=$(check-version python3.9) status=$? if (( status != 0 )); then ApplyRPM "python3" "rh-python38" fi ;; 8 | 9 | 10) ApplyRPM "python3" "python39" ApplyRPM "python3" "python312" ;; esac # # Update the OS # echo "Will update the OS now. This takes a couple of minutes." # echo "This will only be done if script stated the first time." # echo "Please do not stop the script." # $yum -y update --security | tee --append $logfile # echo "OS update completed." # # if [ -f /etc/system-release ]; then # osname="$(tail -n 1 /etc/system-release)" # if [ "$oa" != "" ]; then # osname=$(echo $osname | sed 's|Oracle Linux|Oracle Autonomous Linux|') # fi # echo "OS Name: '$osname'." # fi # # # Move new repo files # repofiles=$(ls ${repodir}/*.repo 2>/dev/null) # rpmnewfiles=$(ls ${repodir}/*.rpmnew 2>/dev/null) # # if [ "$rpmnewfiles" != "" ]; then # if [ ! -d ${repodir}/old ]; then # mkdir ${repodir}/old # fi # fi # # for rfile in $repofiles; do # if [ -f ${rfile}.rpmnew ]; then # mv $rfile ${repodir}/old # mv ${rfile}.rpmnew $rfile # echo "Old repo file '$rfile' moved to '${repodir}/old'." # fi # done # V 3.2.2 # # Download tools repofile # if [ "$bits" = "32" ]; then # repofile="tools32.repo" # else # repofile="tools64.repo" # fi # # if [ ! -f ${repodir}/$repofile ]; then # echo "Downloading '$repofile' file." # transfer --quiet ${baseurl}/pack/rpm/$repofile --export ${repodir}/$repofile # status=$? # # if [ $status -ne 0 ]; then # filecheck -rm ${repodir}/$repofile # echo "WARNING: Coud not create repofile '${repodir}/$repofile'." >> $logfile # else # if [ -f ${repodir}/tools.repo ]; then # line="$(cat ${repodir}/$repofile | head -n 1)" # if [ "$line" != "[oracle_tools]" ]; then # filecheck -rm ${repodir}/$repofile # echo "WARNING: Corrupt repofile '${repodir}/$repofile'." >> $logfile # else # echo "Created repo '${repodir}/$repofile'." >> $logfile # fi # fi # fi # fi # # Remove old jq library if installed # apply="libjq1" # $rpm -q $apply > /dev/null 2>&1 # status=$? # # if [ $status -eq 0 ]; then # # Check if we are on Oracle Automomous Linux # if [ "$oa" != "" -a -f ${repodir}/al-al${version_main}.repo ]; then # cp ${repodir}/al-al${version_main}.repo ${repodir}/al-al${version_main}.repo.saved # fi # # $yum remove -y $apply >> $logfile 2>&1 # echo "Removed obsolete jq library. Package: $apply" # # if [ "$oa" != "" -a -f ${repodir}/al-al${version_main}.repo.saved ]; then # mv ${repodir}/al-al${version_main}.repo.saved ${repodir}/al-al${version_main}.repo # fi # # if [ "$oa" != "" ]; then # $yum install -y al-config >> $logfile 2>&1 # fi # fi # # # Check repolist # CheckRepolist "${repodir}/$repofile" # V 3.2.2 # # Install latest jq # apply="jq" # $yum install -q -y $apply >> $logfile 2>&1 # status=$? # # if [ $status -eq 0 ]; then # pkg=$($rpm -q $apply) # echo "JQ installed. Package: $apply" # else # echo "WARNING: JQ could not be installed." # fi # # Download latest Oracle Linux for OCI repo if it does not exists # if [ "$oa" != "" ]; then # repofile="oracle-oci-ol${version_main}.repo" # if [ ! -f ${repodir}/$repofile ]; then # echo "Downloading '$repofile' file." # transfer --quiet ${baseurl}/lists/$repofile --export ${repodir}/$repofile # status=$? # # if [ $status -ne 0 ]; then # filecheck -rm ${repodir}/$repofile # echo "WARNING: Coud not create repofile '${repodir}/$repofile'." >> $logfile # else # if [ -f ${repodir}/$repofile ]; then # line="$(cat ${repodir}/$repofile | head -n 1)" # if [ "$line" != "[ol${version_main}_latest]" ]; then # filecheck -rm ${repodir}/$repofile # echo "WARNING: Corrupt repofile '${repodir}/$repofile'." >> $logfile # else # echo "Created repo '${repodir}/$repofile'." >> $logfile # fi # fi # fi # fi # fi # Check repolist # CheckRepolist "${repodir}/$repofile" # Install Java - Oracle Java if it can be downloaded (on OCI) else OpenJDK if [[ "$instjava" = "true" ]]; then cmd="java" apply="jdk1.8" # apply="graalvm22-ee-17-jdk" java=$(filecheck -x $cmd) if [[ "$java" = "" ]]; then # Java isn't installed yet $yum install -y $apply --nogpgcheck >> $logfile 2>&1 status=$? if (( status != 0 )); then apply="java-1.8.0-openjdk" $yum install -y $apply >> $logfile 2>&1 status=$? fi if (( status == 0 )); then pkg=$($rpm -q $apply) echo "Java installed. Package: $apply" else echo "WARNING: Java could not be installed." fi fi fi else if [[ "$instjava" = "true" ]]; then # Update java pkg=$($rpm -q "java-1.8.0-openjdk") status=$? if (( status == 0 )); then pkg="java-1.8.0-openjdk" else pkg="jdk1.8" fi fi for apply in $pkg; do echo "Updating RPM: $apply" $yum install -y $apply --nogpgcheck >> $logfile 2>&1 status=$? done fi # Download rpm-list rfile="rpm.txt" DownloadFileList $rfile stat=$? # Install every rpm in filelist if [[ -f ${wdir}/$rfile ]]; then while IFS=$'\t' read -r cmd apply; do if [[ "$cmd" != "" && "$apply" != "" ]]; then # Check repolist # CheckRepolist "${repodir}/$repofile" if [[ "$myip" != "" ]]; then if [[ "$param" = "download" ]]; then echo "Downloading: $apply" # Try yumdownloader with option --resolve instead? yumdownloader --destdir ${wdir}/rpm $apply >> $logfile 2>&1 else tool=$(filecheck -x $cmd) if [[ "$tool" != "" ]]; then echo "Updating RPM: $apply" else echo "Installing RPM: $apply" fi $yum install -q -y $apply >> $logfile 2>&1 fi else if [[ "$param" != "download" ]]; then # Local install rpmfiles="" for rfile in $apply; do rpmfiles="$(echo "$rpmfiles" ${wdir}/rpm/$rfile-*)" done echo "Installing / Updating from local: $apply" $yum install -q -y $rpmfiles >> $logfile 2>&1 fi fi fi done < <(tailfromline2 "${wdir}/$rfile" | StripComment) fi export LANG="$SAVEDLANG" fi } function InstallDebian() { printf "\nInstalling Tools for Linux (Debian or Ubuntu).\n" printf "OS: %s\n" "$pretty_name" printf "ARCH: %s/%s\n\n" "$proc" "$bits" # Check if we have apt and dpkg available # dpkg -l # apt-get install alien # alien -i package_file.rpm (install rpm package with alien) # dpkg -i package_file.deb aptget=$(filecheck -x apt-get) apt=$(filecheck -x apt) dpkg=$(filecheck -x dpkg) if [[ "$aptget" = "" ]]; then exitcode=5 errormsg $exitcode "($progstr) No 'apt-get' in '$PATH'." return $exitcode else echo "" # Update sources.list srclist="/etc/apt/sources.list" if [[ -f "$srclist" ]]; then grepres=$(grep "$baseurl" "$srclist") if [[ "$grepres" = "" ]]; then printf "\n# Get Updates from STANDBY.CLOUD\n" >> "$srclist" if [[ "$bits" = "32" ]]; then printf "deb [trusted=yes] https://standby.cloud/download/pack/deb/i386 /\n" >> "$srclist" else printf "deb [trusted=yes] https://standby.cloud/download/pack/deb/amd64 /\n" >> "$srclist" fi fi fi # Update the packages list $aptget -y update | tee --append $logfile # First install if [[ ! -f $toolsfile ]]; then # # Update the OS # echo "Will update the OS now. This takes a couple of minutes." # echo "This will only be done if script stated the first time." # echo "Please do not stop the script." # $aptget -s dist-upgrade | grep "^Inst" | grep -i securi | awk -F " " {'print $2'} | xargs $aptget install -q -y | tee --append $logfile # echo "OS update completed." # Install Open JDK 8 if [[ "$instjava" = "true" ]]; then cmd="java" apply="openjdk-8-jdk" java=$(filecheck -x $cmd) if [[ "$java" = "" ]]; then # Java isn't installed yet $aptget -y install $apply >> $logfile 2>&1 java=$(filecheck -x $cmd) if [[ "$java" != "" ]]; then echo "Java installed. Package: $apply" else echo "WARNING: Java could not be installed." fi fi fi fi # Download deb-list rfile="deb.txt" DownloadFileList $rfile stat=$? # Install every rpm in filelist if [[ -f ${wdir}/$rfile ]]; then while IFS=$'\t' read -r cmd apply; do if [[ "$cmd" != "" && "$apply" != "" ]]; then if [[ "$myip" != "" ]]; then if [[ "$param" = "download" ]]; then echo "Downloading: $apply" # Try yumdownloader with option --resolve instead? # yumdownloader --destdir ${wdir}/rpm $apply >> $logfile 2>&1 $aptget install -d -y $apply >> $logfile 2>&1 else tool=$(filecheck -x $cmd) if [[ "$tool" != "" ]]; then echo "Updating DEB: $apply" else echo "Installing DEB: $apply" fi $aptget install -q -y $apply >> $logfile 2>&1 fi else if [[ "$param" != "download" ]]; then # Local install debfiles="" for rfile in $apply; do rpmfiles="$(echo "$debfiles" ${wdir}/deb/$rfile-*)" done echo "Installing / Updating from local: $apply" $aptget install -q -y $debfiles >> $logfile 2>&1 fi fi fi done < <(tailfromline2 "${wdir}/$rfile" | StripComment) fi fi } # We are root and can install rpm or pkg function RootInstall() { # get-cloud --output json > $cloudfile if [[ "$myip" = "" ]]; then baseurl="$storageurl" transfer --quiet "${baseurl}/lists/${templatesname}.txt" > "$scratchfile" stat=$? if (( stat != 0 )); then exitcode=4 errormsg $exitcode "($progstr) No Internet Access." exit $exitcode fi else # Create working directory and sub directory if it does not exists for folder in rpm; do if [[ ! -d ${wdir}/$folder ]]; then mkdir -m 0755 -p ${wdir}/$folder fi done # Install tools for different OS case "$OS" in Darwin) InstallDarwin ;; SunOS) if (( version_main >= 11 )); then # Solaris 11 or newer InstallSolarisIPS else InstallSunOS fi ;; Linux) case "$id_like" in fedora) if [[ "$id" = "rhel" || "$id" = "ol" || "$id" = "centos" ]]; then InstallRedHat else InstallFedora fi ;; debian) InstallDebian ;; suse) InstallSuse ;; alpine) InstallAlpine ;; *) exitcode=5 errormsg $exitcode "($progstr) Can't install tools for Linux Type '$id_like'." esac ;; *) exitcode=5 errormsg $exitcode "($progstr) Can't install tools for OS '$OS'." esac # Activate OCID Service (oci-utils: https://docs.oracle.com/en-us/iaas/oracle-linux/oci-utils/index.htm) if [[ "$rpm" != "" ]]; then $rpm -q oci-utils > /dev/null 2>&1 stat=$? if (( stat == 0 )); then service ocid status > /dev/null 2>&1 stat=$? if (( stat != 0 )); then systemctl enable --now ocid.service >> $logfile 2>&1 fi fi fi # Create toolsfile echo "cmd" > $toolsfile # Upgrade pip and easy_install (ToDo: Has to be reviewd) if [[ "$OS" = "SunOS" ]]; then pip2=$(ls /bin/pip-2.* /usr/local/bin/pip-2.* 2>/dev/null | tail -n 1) pip3=$(ls /bin/pip-3.* /usr/local/bin/pip-3.* 2>/dev/null | tail -n 1) if [[ "$pip3" != "" ]]; then $pip3 install --upgrade pip >> $logfile 2>&1 $pip3 install --upgrade setuptools >> $logfile 2>&1 wheel=$(filecheck -x wheel) if [[ "$wheel" = "" ]]; then pyvers=$(check-version python3 | cut -d' ' -f2) if [[ "$pyvers" != "not" ]]; then result=$(compare-version "3.5" "$pyvers") if [[ "$result" = "same" || "$result" = "newer" ]]; then # Installing wheel needs python 3.5 or newer $pip3 install wheel >> $logfile 2>&1 fi fi fi fi if [[ "$pip2" != "" ]]; then $pip2 install --upgrade pip >> $logfile 2>&1 $pip2 install --upgrade setuptools >> $logfile 2>&1 virtualenv=$(filecheck -x virtualenv) if [[ "$virtualenv" = "" ]]; then $pip2 install virtualenv >> $logfile 2>&1 fi fi fi # Check if we have all python links and if nescessary create them for rlink in easy_install-2 easy_install-3; do ei1=$(filecheck -x $rlink) ei2=$(ls /bin/${rlink}.* /usr/local/bin/${rlink}.* 2>/dev/null | tail -n 1) if [[ "$ei2" != "" ]]; then eib=$(basename $ei2) eid=$(dirname $ei2) # eib="$ei2" # eid="$destfolder" # Create the link if it doesn't exists if [[ "$ei1" = "" && "$ei2" != "" ]]; then ln -s $eib ${eid}/$rlink 2>/dev/null stat=$? if (( stat == 0 )); then echo "Symbolic link created for '${eid}/$rlink'." >> $logfile echo "Symbolic link created for '${eid}/$rlink'." echo "${eid}/$rlink" >> $toolsfile else echo "Symbolic link not created for '${eid}/$rlink'." >> $logfile fi fi fi done fi } function Install() { local location="" # Create working directory and sub directory if it does not exists for folder in cmd zip templates; do if [[ ! -d ${wdir}/$folder ]]; then mkdir -m 0755 -p ${wdir}/$folder fi done # We create some folder if they don't exist for destfolder in $binfolder $libfolder ${manfolder}/man1 $infofolder $appfolder $templatesfolder; do if [[ ! -d "$destfolder" ]]; then mkdir -m 0755 -p "$destfolder" printf "Created folder '$destfolder'.\n" fi done # Create toolsfile, zipsfile, libsfile and manfile2 echo "cmd version" > $toolsfile echo "cmd version" > $zipsfile echo "man1 version" > $manfile2 echo "libraries" > $libsfile # Install template files InstallTemplates # Download cmd-list if [[ "$proc" = "i386" ]]; then rfile="cmd${bits}.txt" else rfile="arm${bits}.txt" fi DownloadFileList $rfile stat=$? # Install additional tools for OS if [[ $stat -eq 0 && -f ${wdir}/$rfile ]]; then # Find version for current os grep -w "$OS" "${wdir}/$rfile" | StripComment > "$scratchfile" if [[ -f "$scratchfile" ]]; then while IFS=$'\t' read -r cmd vers tos tfolder; do if [[ "$cmd" != "" && "$vers" != "" && "$tos" != "" ]]; then result=$(check-version "$cmd") stat=$? if (( stat == 0 )); then tool=$(echo "$result" | cut -d' ' -f1) tvers=$(echo "$result" | cut -d' ' -f2) else tool="$cmd" tvers="" fi if [[ "$tvers" != "" ]]; then result=$(compare-version $tvers $vers 2>/dev/null) if [[ "$result" = "newer" || "$result" = "" ]]; then # If we have an newer version available than installed - install it tvers="" fi fi if [[ "$tvers" = "" ]]; then echo "Installing '$cmd'." >> $logfile echo "Installing '$cmd'." if [[ "$tfolder" != "" ]]; then # Donwload library if it exists if [[ "$baseurl" != "$storageurl" ]]; then transfer --quiet ${baseurl}/cmd/${proc}/${bits}/${tfolder}/${vers}/${tos}/lib.zip --export ${wdir}/cmd/${cmd}-lib.zip status=$? else transfer --quiet ${baseurl}/cmd/${proc}/${bits}/${tfolder}/lib.zip --export ${wdir}/cmd/${cmd}-lib.zip status=$? fi if [[ $status -eq 0 && -f ${wdir}/cmd/${cmd}-lib.zip ]]; then # Delete the file if it is not a valid zip file # result=$(file "${wdir}/cmd/${cmd}-lib.zip" | grep "Zip archive data") result=$(filecheck -z "${wdir}/cmd/${cmd}-lib.zip") if [[ "$result" = "" ]]; then filecheck -rm "${wdir}/cmd/${cmd}-lib.zip" fi fi cmdstr="${tfolder}" else cmdstr="${cmd}" fi # Distinct between download from internet and from Objectstorage if [[ "$baseurl" != "$storageurl" ]]; then location="${cmdstr}/${vers}/$tos" else location="$cmdstr" fi # Try if we have an zip in archive transfer --quiet "${baseurl}/cmd/${proc}/${bits}/${location}/${cmd}.zip" --export "${wdir}/cmd/${cmd}.zip" status=$? if [[ $status -eq 0 && -f "${wdir}/cmd/${cmd}.zip" ]]; then # result=$(file "${wdir}/cmd/${cmd}.zip" | grep "Zip archive data") result=$(filecheck -z "${wdir}/cmd/${cmd}.zip") if [[ "$result" = "" ]]; then # Try to download plain cmd transfer --quiet "${baseurl}/cmd/${proc}/${bits}/${location}/$cmd" --export "${wdir}/cmd/$cmd" status=$? else # Valid zip - unzip unzip -q "${wdir}/cmd/${cmd}.zip" -d "${wdir}/cmd" status=$? if (( status > 0 )); then # Unzip failed - delete the file filecheck -rm "${wdir}/cmd/${cmd}" fi fi else transfer --quiet "${baseurl}/cmd/${proc}/${bits}/${location}/$cmd" --export "${wdir}/cmd/$cmd" status=$? fi # Delete the zip (if we have one) filecheck -rm "${wdir}/cmd/${cmd}.zip" # Check if cmd is not a html file if [[ -f "${wdir}/cmd/$cmd" ]]; then grepres=$(grep '^' "${wdir}/cmd/$cmd" 2>/dev/null | cut -d '>' -f1) else grepres="" fi if [[ $status -ne 0 || "$grepres" = "/dev/null 2>&1 status=$? if (( status == 0 )); then cp ${wdir}/cmd/$cmd $binfolder echo "${binfolder}/$cmd $vers" >> $toolsfile # Check if there are man pages if [[ "$baseurl" = "$storageurl" ]]; then transfer --quiet ${baseurl}/man/${cmd}.1 --export ${wdir}/cmd/${cmd}.1 status=$? else if [[ "$tfolder" != "" ]]; then transfer --quiet ${baseurl}/man/${tfolder}/${vers}/${cmd}.1 --export ${wdir}/cmd/${cmd}.1 status=$? else transfer --quiet ${baseurl}/man/${cmd}/${vers}/${cmd}.1 --export ${wdir}/cmd/${cmd}.1 status=$? fi fi if [[ -f "${wdir}/cmd/${cmd}.1" ]]; then grepres=$(grep '^' "${wdir}/cmd/${cmd}.1" | cut -d '>' -f1) else grepres="" fi # Delete the file if it is HTML or if we got an error if [[ $status -ne 0 || "$grepres" = "> $libsfile done rm -fR "${wdir}/cmd/lib" fi if [[ "$gzip" != "" && "$OS" != "SunOS" ]]; then filecheck -rm "${manfolder}/man1/${cmd}.1.gz" $gzip "${manfolder}/man1/${cmd}.1" chmod 644 "${manfolder}/man1/${cmd}.1.gz" echo "${manfolder}/man1/${cmd}.1.gz $vers" >> $manfile2 else chmod 644 "${manfolder}/man1/${cmd}.1" echo "${manfolder}/man1/${cmd}.1 $vers" >> $manfile2 fi fi else filecheck -rm ${wdir}/cmd/$cmd echo "Could not install '$cmd'." >> $logfile fi else filecheck -rm ${wdir}/cmd/$cmd echo "Could not download '$cmd'." >> $logfile fi fi fi done < "$scratchfile" # Create mandb UpdateWhatis fi else echo "Could not download '$rfile'." >> $logfile fi # Check if python39 is available # Default: OL7, OL8: Python36, OL9: Python39, OL10: Python312 python3=$(check-version python3.9) stat=$? if (( stat != 0 )); then python3=$(check-version /opt/rh/rh-python38/root/usr/bin/python3.8) stat=$? if (( stat != 0 )); then python3=$(check-version python3) fi fi pvers=$(echo "$python3" | cut -d' ' -f 2) if [[ "$pvers" != "not" ]]; then python3=$(echo "$python3" | cut -d' ' -f 1) pvers=$(echo "$pvers" | cut -d'.' -f -2) else python3="" pvers="" fi # We need python3 to install zip files and internet access if [[ "$python3" != "" ]]; then # Install Zip files rfile="zip.txt" DownloadFileList $rfile stat=$? # Install additional cloud tools packed in zip (oci and psm) if [[ $stat -eq 0 && -f ${wdir}/$rfile ]]; then pipopt="" # if [ "$OS" = "SunOS" ]; then # pipopt="--ignore-installed" # fi # Download newer version of pip if we have to use Objectstorage if [[ "$baseurl" = "$storageurl" ]]; then transfer --quiet "${storageurl}/zip/pip.zip" > ${wdir}/zip/pip.zip stat=$? if (( stat == 0 )); then unzip -q -d ${wdir}/zip ${wdir}/zip/pip.zip fi fi while IFS=$'\t' read -r cmd zvers zname; do if [[ "$cmd" != "" && "$zvers" != "" && "$zname" != "" ]]; then result=$(check-version "$cmd") curvers=$(echo "$result" | cut -d' ' -f2) if [[ "$curvers" = "not" ]]; then result="newer" else result=$(compare-version "$curvers" "$zvers") fi if [[ "$result" = "newer" ]]; then # echo "Found newer version (Installed: $curvers - Found: $zvers)." if [[ "$param" = "download" ]]; then echo "Downloading '$cmd' - Zip '${zname}-${zvers}.zip'." fi # dlurl="https://github.com/oracle/oci-cli/releases/download/v${zvers}/${zname}-${zvers}.zip" if [[ "$baseurl" != "$storageurl" ]]; then if [[ "$cmd" = "ansible" || "$cmd" = "sdk" ]]; then # We don't need to download ansible or oci sdk dlurl="" else dlurl="${baseurl}/zip/${zname}-${zvers}.zip" fi else dlurl="${baseurl}/zip/${zname}.zip" fi if [[ "$dlurl" != "" ]]; then transfer --quiet $dlurl > ${wdir}/zip/${zname}-${zvers}.zip else touch ${wdir}/zip/${zname}-${zvers}.zip fi # echo "zname: '${zname}'" # echo "zvers: '${zvers}'" # echo "cmd: '${cmd}'" # echo "Downloaded '${zname}-${zvers}.zip'." # Install tool if we do more then just download it if [[ "$param" != "download" ]]; then # Check if we already installed tool - then delete it first if [[ -d "${appfolder}/$zname" ]]; then # Backup old version if [[ -d "${appfolder}/old-$zname" ]]; then rm -fR "${appfolder}/old-$zname" else mv -f "${appfolder}/$zname" "${appfolder}/old-$zname" fi fi # We use virtualenv result=$(compare-version "3.6" "$pvers") if [[ "$result" = "older" ]]; then virtualenv=$(filecheck -x virtualenv) if [[ "$virtualenv" != "" ]]; then $virtualenv --python=$python3 "${appfolder}/$zname" >> $logfile 2>&1 else exitcode=5 errormsg $exitcode "($progstr) No 'virtualenv' in '$PATH'. Please install first." exit $exitcode fi else $python3 -m venv "${appfolder}/$zname" >> $logfile 2>&1 fi # Use virtualenv and update pip if [[ -f "${appfolder}/${zname}/bin/activate" ]]; then source "${appfolder}/${zname}/bin/activate" # Upgrading pip if [[ "$baseurl" != "$storageurl" ]]; then # ToDo: psm-cli needs pip < 25.2.3 or pyproject.toml # pip3 install --upgrade pip >> $logfile 2>&1 pip3 install --upgrade "pip<=25.1.0" >> $logfile 2>&1 else ${wdir}/zip/pip/pip-install >> $logfile 2>&1 fi fi if [[ -f ${wdir}/zip/${zname}-${zvers}.zip ]]; then echo "Installing '${zname}'." if [[ "$baseurl" = "$storageurl" ]]; then unzip -q -d ${wdir}/zip ${wdir}/zip/${zname}-${zvers}.zip fi if [[ "$cmd" = "oci" || "$cmd" = "ansible" || "$cmd" = "sdk" ]]; then if [[ "$cmd" = "oci" && "$baseurl" != "$storageurl" ]]; then unzip -q -d ${wdir}/zip ${wdir}/zip/${zname}-${zvers}.zip fi if [[ "$OS" = "SunOS" ]]; then # We need to compile some libraries export PKG_CONFIG_PATH=/usr/lib/64/pkgconfig export CFLAGS=$(pkg-config --cflags libffi) fi if [[ "$cmd" = "ansible" ]]; then if [[ "$baseurl" = "$storageurl" ]]; then ${wdir}/zip/${zname}/pip-install >> $logfile 2>&1 stat=$? else pip3 install $pipopt "${zname}==${zvers}" >> $logfile 2>&1 stat=$? fi else if [[ "$cmd" = "sdk" ]]; then if [[ "$baseurl" = "$storageurl" ]]; then ${wdir}/zip/${zname}/pip-install >> $logfile 2>&1 stat=$? # Move destroy folder mv -f "${wdir}/zip/${zname}/destroy" "${appfolder}/${zname}" else pip3 install $pipopt "oci==${zvers}" >> $logfile 2>&1 stat=$? fi else # Install oci cli # Optional-Features db was intrduced in 2.5.6. Current versions (since 2.17.0) doesn't contain this feature # pip3 install $pipopt 'oci-cli[db]' ${wdir}/zip/${zname}/oci_cli*.whl >> $logfile 2>&1 if [[ "$baseurl" = "$storageurl" ]]; then ${wdir}/zip/${zname}/pip-install >> $logfile 2>&1 stat=$? else pip3 install $pipopt ${wdir}/zip/${zname}/oci_cli*.whl >> $logfile 2>&1 stat=$? fi fi fi # Remove unpacked files if [[ -d "${wdir}/zip/${zname}" ]]; then rm -fR "${wdir}/zip/${zname}" fi result=$(FunctionExists deactivate) if [[ "$result" = "true" ]]; then deactivate fi else if [[ "$cmd" = "psm" ]]; then if [[ "$baseurl" != "$storageurl" ]]; then # Install older versions of wheel and setuptools - needed by psm-cli pip3 install $pipopt "wheel==0.45.1" >> $logfile 2>&1 pip3 install $pipopt "setuptools==53.0.0" >> $logfile 2>&1 pip3 install $pipopt ${wdir}/zip/${zname}-${zvers}.zip >> $logfile 2>&1 stat=$? else ${wdir}/zip/${zname}/pip-install >> $logfile 2>&1 stat=$? fi result=$(FunctionExists deactivate) if [[ "$result" = "true" ]]; then deactivate fi # Delete not needed windows script # if [ -f ${appfolder}/${zname}/psm.cmd ]; then # rm -f ${appfolder}/${zname}/psm.cmd # fi else # Don't know to install zip echo "Don't know to install cmd '$cmd' in zip '${zname}-${zvers}.zip'" fi fi if [[ "$cmd" = "sdk" ]]; then myname="${appfolder}/${zname}/bin/$cmd" printf '#!/bin/bash\n\n' > "$myname" printf 'if [[ "$0" = "/bin/bash" || "$0" = "-bash" ]]; then\n' >> "$myname" printf ' printf "\\nOCI-Python-SDK '${zvers}'\\n"\n' >> "$myname" printf ' printf "Enter to exit.\\n"\n' >> "$myname" printf ' source "'${appfolder}/${zname}/bin/activate'"\n' >> "$myname" printf 'else\n' >> "$myname" printf ' echo "OCI-Python-SDK '${zvers}'"\n' >> "$myname" printf ' echo "Call this script with "\n' >> "$myname" printf 'fi\n' >> "$myname" chmod 755 "$myname" myname="${appfolder}/${zname}/bin/destroy" printf '#!/bin/bash\n\n' > "$myname" printf 'cid=${1}\n\n' >> "$myname" printf 'if [[ "$cid" = "" ]]; then\n' >> "$myname" printf ' echo "Destroy all resources in compartment or tenancy. Origin: https://github.com/AnykeyNL/OCI-SuperDelete"\n' >> "$myname" printf ' errormsg 1 "Please specify a compartment id."\n' >> "$myname" printf 'else\n' >> "$myname" printf ' cd "'${appfolder}/${zname}/destroy'"\n' >> "$myname" printf ' stat=$?\n\n' >> "$myname" printf ' if (( stat == 0 )); then\n' >> "$myname" printf ' source "'${REALHOME}/.admintools'"\n' >> "$myname" printf ' "'${appfolder}/${zname}/bin/python3'" delete.py -force -c "$cid" -cp "$OCI_CONFIG_PROFILE"\n' >> "$myname" printf ' else\n' >> "$myname" printf ' errormsg 2 "Folder ('${appfolder}/${zname}/destroy') not found."\n' >> "$myname" printf ' fi\n' >> "$myname" printf 'fi\n' >> "$myname" chmod 755 "$myname" # Download SuperDelete if [[ "$baseurl" != "$storageurl" ]]; then mkdir "${appfolder}/${zname}/destroy" SAVEDLANG="$LANG" # LANG="en_US.UTF-8" export LANG="C" # "C.UTF-8" git clone https://github.com/AnykeyNL/OCI-SuperDelete.git "${appfolder}/${zname}/destroy" 2>/dev/null touch "${appfolder}/${zname}/destroy/log.txt" 2>/dev/null chmod 666 "${appfolder}/${zname}/destroy/log.txt" 2>/dev/null export LANG="$SAVEDLANG" fi fi # Check if site-package exists case "$zname" in psm-cli) result=$(filecheck -d "${appfolder}/${zname}/lib/python${pvers}/site-packages/opaascli") ;; oci-cli) result=$(filecheck -d "${appfolder}/${zname}/lib/python${pvers}/site-packages/oci_cli") ;; oci-sdk) result=$(filecheck -d "${appfolder}/${zname}/lib/python${pvers}/site-packages/oci") ;; ansible-base) result=$(filecheck -d "${appfolder}/${zname}/lib/python${pvers}/site-packages/ansible") ;; *) result="" esac if [[ "$result" = "" ]]; then echo "Unable to install python package '$zname'." >> $logfile if [[ -d "${appfolder}/old-$zname" ]]; then echo "Restoring '$zname'." rm -fR "${appfolder}/${zname}" mv -f "${appfolder}/old-$zname" "${appfolder}/$zname" else echo "Deleting '$zname'." rm -fR "${appfolder}/${zname}" fi fi tool=$(filecheck -x "${appfolder}/${zname}/bin/$cmd") if [[ "$tool" != "" ]]; then instvers=$(check-version "$tool" | cut -d' ' -f2) # Create link in PATH and write version to zipsfile ln -s "$tool" "${binfolder}/$cmd" 2>/dev/null echo "${appfolder}/${zname} ${zvers}" >> $zipsfile echo "${binfolder}/$cmd installed. Version: $instvers" >> $logfile echo "${binfolder}/$cmd $instvers" >> $toolsfile else echo "$cmd not installed." >> $logfile fi fi # Don't need the backup anymore if [[ -d "${appfolder}/old-$zname" ]]; then rm -fR "${appfolder}/old-${zname}" fi fi fi fi done < <(tailfromline2 "${wdir}/$rfile" | StripComment) # Remove unzipped pip dir if [[ "$baseurl" = "$storageurl" ]]; then rm -fR ${wdir}/zip/pip fi else echo "Could not download '$rfile'." >> $logfile fi else echo "No python3 to install zip files." >> $logfile fi } # Preset param="" # Check parameters: Loop until all parameters are used up while [[ "$1" != "" ]]; do pname=${1} case "$pname" in -v | --version) shift showversion=true ;; -h | --help) shift showhelp=true ;; *) shift if [[ "$pname" == -* ]]; then # Options begin with '-' errstr="Unknown option '$pname'." else if [[ "$param" = "" ]]; then param="$(ToLower "$pname")" else errstr="Unknown parameter: '$1'." fi fi esac done # Display help or error message DisplayHelp # Check if he have curl and gzip available curl=$(filecheck -x curl) gzip=$(filecheck -x gzip) rpm=$(filecheck -x rpm) yum=$(filecheck -x yum) if [[ "$curl" = "" ]]; then exitcode=3 errormsg $exitcode "($progstr) No 'curl' in '$PATH'. Please install first e.g. 'yum -y install curl'." exit $exitcode else printf "\nScript '$progstr' started.\n" # Check if he have internet access and get platform infos myip=$(get-ip ip) result=$(get-platform --output keys) id=$(GrepKey "$result" "id") # vers=$(GrepKey "$result" "version_main") id_like=$(GrepKey "$result" "id_like") name=$(GrepKey "$result" "name") # codename=$(GrepKey "$result" "codename") # version_id=$(GrepKey "$result" "version_id") version_main=$(GrepKey "$result" "version_main") pretty_name=$(GrepKey "$result" "pretty_name") proc=$(GrepKey "$result" "processor") # Infos about the processor type (e.g. i386, sparc, arm) bits=$(GrepKey "$result" "bit") # 32 or 64 # gateway=$(GrepKey "$result" "gateway") # iface=$(GrepKey "$result" "interface") # ifup=$(GrepKey "$result" "up") # lip=$(GrepKey "$result" "ip_v4") # cloud_id=$(GrepKey "$result" "cloud_id") # asn_id=$(GrepKey "$result" "asn_id") if [[ "$myip" = "" ]]; then # Local install echo "Local Install" else # Download if [[ "$param" = "download" ]]; then echo "ToDo: Download" fi fi echo "Architecture: '${proc}-$bits'." # Create the logfile touch $logfile # chown "${REALUSER}:$REALGROUP" "$logfile" echo "----------------------------------------------------------------------------------------------------" >> $logfile echo "$curdate '$progstr' started." >> $logfile printf "Logfile: '$logfile'.\n" # Check if we previously installed templates if [[ -f "$templatesfile" ]]; then while IFS=$'\t' read -r cmd; do if [[ "$cmd" != "" ]]; then echo "Deleting '$cmd'." >> $logfile echo "Deleting '$cmd'." filecheck -rm $cmd fi done < <(tailfromline2 "$templatesfile" | StripComment) fi # Check if we previously installed links or tools if [[ -f "$toolsfile" ]]; then while IFS=$'\t' read -r cmd vers; do if [[ "$cmd" != "" ]]; then echo "Deleting '$cmd'." >> $logfile echo "Deleting '$cmd'." # filecheck -rm $cmd # This won't remove links rm -f $cmd fi done < <(tailfromline2 "$toolsfile" | StripComment) fi # Check if we previously installed manuals if [[ -f "$manfile2" ]]; then while IFS=$'\t' read -r cmd vers; do if [[ "$cmd" != "" ]]; then echo "Deleting '$cmd'." >> $logfile echo "Deleting '$cmd'." filecheck -rm $cmd fi done < <(tailfromline2 "$manfile2" | StripComment) fi # Check if we previously zips if [[ -f "$zipsfile" ]]; then while IFS=$'\t' read -r cmd vers; do if [[ "$cmd" != "" ]]; then echo "Deleting '$cmd'." >> $logfile echo "Deleting '$cmd'." filecheck -rm $cmd fi done < <(tailfromline2 "$zipsfile" | StripComment) fi if [[ "$USER" = "root" ]]; then RootInstall fi Install fi # Cleanup and exit Cleanup exit $exitcode # Create repo if we downloaded rpm if [[ "$param" = "download" ]]; then echo "Creating repo." createrepo ${wdir}/rpm >> $logfile 2>&1 cd /tmp zip -q -r ${HOME}/tools.zip tools echo "Zip file '${HOME}/tools.zip' created." fi # Delete working directory rm -fR $wdir