#!/bin/bash # # Author: Georg Voell - georg.voell@standby.cloud # Version: @(#)install-tools 3.2.0 11.09.2024 (c)2024 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. # An additional repo 'tools.repo' will be installed in /etc/yum.repos.d # 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 and Oracle Linux Server 8.x # Oracle Autonomous Linux Server 7.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/latest/install-tools | bash # # or download the script and make it executable e.g.: # # curl --silent https://standby.cloud/download/latest/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 # # 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=`which lib.bash 2>/dev/null | sed 's|^no 'lib.bash' in .*||'` 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 baseurl="https://standby.cloud/download" cdir=`pwd` # Current working directory wdir="/tmp/tools" # Working directory param=`echo $1 | tr "[:upper:]" "[:lower:]"` 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 logfile="${REALHOME}/${progstr}.log" if [ "$USER" = "root" ]; then if [ -d "/var/log" ]; then logfile="/var/log/${progstr}.log" fi 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} transfer --quiet ${baseurl}/lists/$filelist > ${wdir}/$filelist status=$? if [ $status -ne 0 ]; then exitcode=6 errormsg $exitcode "($progstr) Could not download filelist '$filelist'." "CURL could not establish a connection to server" 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 cmd-list rfile="${templatesname}.txt" DownloadFileList $rfile stat=$? # 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" != "" -a "$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 -ne 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 < <(cat "${wdir}/${templatesname}.txt" | tailfromline2 | 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" = "" -a "$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 -eq 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 -o "$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 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 # Download pkg-list rfile="pkg.txt" DownloadFileList $rfile stat=$? # Install each pkg in file if [ $stat -eq 0 -a -f ${wdir}/$rfile ]; then while IFS=$'\t' read -r cmd apply; do if [ "$cmd" != "" -a "$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 < <(cat "${wdir}/$rfile" | tailfromline2 | 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 -ne 0 ]; do if [ -f "${toolsrepo}.osms-backup" ]; then mv -f "${toolsrepo}.osms-backup" "${toolsrepo}" fi $yum repolist all >> $logfile status=$? done } 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" # Check if we have yum and rpm available yum=`filecheck -x yum` rpm=`filecheck -x rpm` if [ "$yum" = "" -o "$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 # 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 -ne 0 ]; then # Check with rpm if release manager is already installed $rpm -q oraclelinux-release-$plat > /dev/null 2>&1 status=$? if [ $status -ne 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 # Applying deltarpm (if it can be found) apply="deltarpm" $rpm -q $apply > /dev/null 2>&1 status=$? if [ $status -ne 0 ]; then $yum install -y $apply >/dev/null 2>&1 status=$? if [ $status -eq 0 ]; then # pkg=`yum install -y $rpm | grep '^Package' | cut -d' ' -f2 | cut -d':' -f2 | tr '\n' ' '` pkg=`$rpm -q $apply` echo "$apply installed. Package: $pkg" >> $logfile else echo "$apply not installed." >> $logfile fi fi # # 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 # 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" # 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 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 -ne 0 ]; then apply="java-1.8.0-openjdk" $yum install -y $apply >> $logfile 2>&1 status=$? fi if [ $status -eq 0 ]; then pkg=`$rpm -q $apply` echo "Java installed. Package: $apply" else echo "WARNING: Java could not be installed." fi fi # # Install oci cli # cmd="oci" # apply="python36-oci-cli java-oci-sdk python36-oci-sdk" # oci=`filecheck -x $cmd` # if [ "$oci" = "" ]; then # # oci cli isn't installed yet # $yum install -y $apply >> $logfile 2>&1 # status=$? # # if [ $status -eq 0 ]; then # pkg=`$rpm -q $apply` # echo "oci cli and sdk installed. Package: $apply" # else # echo "WARNING: oci cli and sdk could not be installed." # fi # fi else # Update java, jq pkg=`$rpm -q "java-1.8.0-openjdk"` status=$? if [ $status -eq 0 ]; then pkg="java-1.8.0-openjdk" else pkg="jdk1.8" fi for apply in $pkg jq; 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" != "" -a "$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 < <(cat "${wdir}/$rfile" | tailfromline2 | 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 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 # 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" != "" -a "$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 < <(cat "${wdir}/$rfile" | tailfromline2 | stripcomment) fi fi } # We are root and can install rpm or pkg function RootInstall() { get-cloud --output json > $cloudfile if [ "$myip" = "" ]; then exitcode=4 errormsg $exitcode "($progstr) No Internet Access." exit $exitcode 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 -ge 11 ]; then # Solaris 11 or newer InstallSolarisIPS else InstallSunOS fi ;; Linux) case "$id_like" in fedora) if [ "$id" = "rhel" -o "$id" = "ol" -o "$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 service ocid status > /dev/null 2>&1 stat=$? if [ $stat -ne 0 ]; then systemctl enable --now ocid.service >> $logfile 2>&1 fi # Create toolsfile echo "cmd" > $toolsfile # Upgrade pip and easy_install 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" -o "$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" = "" -a "$ei2" != "" ]; then ln -s $eib ${eid}/$rlink stat=$? if [ $stat -eq 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() { # 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 [ "$bits" = "64" ]; then rfile="cmd64.txt" else rfile="cmd32.txt" fi DownloadFileList $rfile stat=$? # Install additional tools for OS if [ $stat -eq 0 -a -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" != "" -a "$vers" != "" -a "$tos" != "" ]; then result=`check-version "$cmd"` stat=$? if [ $stat -eq 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" -o "$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 transfer --quiet ${baseurl}/cmd/${proc}/${bits}/${tfolder}/${vers}/${tos}/lib.zip --export ${wdir}/cmd/${cmd}-lib.zip status=$? if [ $status -eq 0 -a -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 # Try if we have an zip in archive transfer --quiet "${baseurl}/cmd/${proc}/${bits}/${cmdstr}/${vers}/${tos}/${cmd}.zip" --export "${wdir}/cmd/${cmd}.zip" status=$? if [ $status -eq 0 -a -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}/${cmdstr}/${vers}/${tos}/$cmd" --export "${wdir}/cmd/$cmd" status=$? else # Valid zip - unzip unzip -q "${wdir}/cmd/${cmd}.zip" -d "${wdir}/cmd" status=$? if [ $status -gt 0 ]; then # Unzip failed - delete the file filecheck -rm "${wdir}/cmd/${cmd}" fi fi else transfer --quiet "${baseurl}/cmd/${proc}/${bits}/${cmdstr}/${vers}/${tos}/$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 -o "$grepres" = "> $toolsfile # Check if there are man pages 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 # Delete the file if it is HTML or if we got an error # result=`file "${wdir}/cmd/${cmd}.1" | grep "HTML document"` # if [ $status -ne 0 -o "$result" != "" ]; then if [ -f "${wdir}/cmd/${cmd}.1" ]; then grepres=`grep '^' "${wdir}/cmd/${cmd}.1" | cut -d '>' -f1` else grepres="" fi if [ $status -ne 0 -o "$grepres" = "> $libsfile done rm -fR "${wdir}/cmd/lib" fi if [ "$gzip" != "" -a "$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 download '$cmd'." >> $logfile fi fi fi done < $scratchfile # Create mandb UpdateWhatis fi else echo "Could not download '$rfile'." >> $logfile fi # Get version of python if [ -x "/usr/bin/python3.9" ]; then # Linux 8 und 9 support python3="/usr/bin/python3.9" python3=`check-version $python3` else if [ -x "/opt/rh/rh-python38/root/usr/bin/python3.8" ]; then # Linux 7 support python3="/opt/rh/rh-python38/root/usr/bin/python3.8" python3=`check-version $python3` else if [ -x "/opt/rh/rh-python36/root/usr/bin/python3.6" ]; then # Linux 6 support python3="/opt/rh/rh-python36/root/usr/bin/python3.6" python3=`check-version $python3` else python3=`check-version python3` fi 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 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 -a -f ${wdir}/$rfile ]; then pipopt="" # if [ "$OS" = "SunOS" ]; then # pipopt="--ignore-installed" # fi while IFS=$'\t' read -r cmd zvers zname; do if [ "$cmd" != "" -a "$zvers" != "" -a "$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 [ "$cmd" = "ansible" -o "$cmd" = "sdk" ]; then # We don't need to download ansible touch ${wdir}/zip/${zname}-${zvers}.zip else 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" dlurl="${baseurl}/zip/${zname}-${zvers}.zip" transfer --quiet $dlurl > ${wdir}/zip/${zname}-${zvers}.zip fi # tool=`filecheck -x $cmd` if [ "$param" != "download" ]; then # -a "$tool" = "" ### Don't install tool if it is already installed # Check if we already installed tool - then delete it first if [ -d "${appfolder}/$zname" ]; then # echo "Deleting old folder (Folder: ${appfolder}/$zname)." rm -fR "${appfolder}/$zname" 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" result=`compare-version "3.8" "$pvers"` if [ "$result" = "older" ]; then pip3 install --upgrade pip >> $logfile 2>&1 fi fi if [ -f ${wdir}/zip/${zname}-${zvers}.zip ]; then echo "Installing '${zname}'." if [ "$cmd" = "oci" -o "$cmd" = "ansible" -o "$cmd" = "sdk" ]; then if [ "$cmd" = "oci" ]; 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 pip3 install $pipopt "${zname}==${zvers}" >> $logfile 2>&1 stat=$? else if [ "$cmd" = "sdk" ]; then pip3 install $pipopt "oci==${zvers}" >> $logfile 2>&1 stat=$? else # 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 pip3 install $pipopt ${wdir}/zip/${zname}/oci_cli*.whl >> $logfile 2>&1 stat=$? # Remove unpacked files rm -fR ${wdir}/zip/${zname} fi fi result=`FunctionExists deactivate` if [ "$result" = "true" ]; then deactivate fi # sp="${appfolder}/${zname}/lib/python${pvers}/site-packages" # if [ -d ${sp}/__pycache__ -a -d "${binfolder}/__pycache__" ]; then # mv ${binfolder}/__pycache__/* ${sp}/__pycache__ # rmdir ${binfolder}/__pycache__ # fi else if [ "$cmd" = "psm" ]; then # cd /bin # sudo cp /opt/rh/rh-python38/root/usr/bin/python3.8 . # sudo rm -f /bin/python3 # sudo ln -s python3.8 /bin/python3 # sudo cp /opt/rh/rh-python38/root/usr/bin/easy_install-3.8 . # sudo rm -f easy_install-3 # sudo ln -s easy_install-3.8 /bin/easy_install-3 # sudo cp /opt/rh/rh-python38/root/usr/bin/pip3.8 . # sudo rm -f pip3 # sudo ln -s pip3.8 /bin/pip3 # sudo cp /opt/rh/rh-python38/root/usr/bin/pydoc3.8 . # sudo rm -f pydoc3 # sudo ln -s pydoc3.8 /bin/pydoc3 pip3 install $pipopt ${wdir}/zip/${zname}-${zvers}.zip >> $logfile 2>&1 stat=$? 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 # echo '#!/bin/bash' > ${binfolder}/$cmd # printf "\nsource ${appfolder}/${zname}/bin/activate\n" >> ${binfolder}/$cmd # echo "$tool" '$*' >> ${binfolder}/$cmd # echo "deactivate" >> ${binfolder}/$cmd # chmod 755 ${binfolder}/$cmd # cp -f $tool ${binfolder}/$cmd if [ "$cmd" = "sdk" ]; then myname="${appfolder}/${zname}/bin/$cmd" printf '#!/bin/bash\n\n' > "$myname" printf 'if [ "$0" = "/bin/bash" -o "$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 -eq 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 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 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" 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 fi fi fi done < <(cat "${wdir}/$rfile" | tailfromline2 | stripcomment) 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 paramck=`echo "$pname" | grep '^-'` # Keys don't begin with '-' if [ "$paramck" != "" ]; then errstr="Unknown option '$pname'." else if [ "$param" = "" ]; then param=`echo "$pname" | tolower` 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` 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` get-platform --output keys > $scratchfile id="`grep '^id:' $scratchfile | cut -d':' -f2-`" id_like="`grep '^id_like:' $scratchfile | cut -d':' -f2-`" name="`grep '^name:' $scratchfile | cut -d':' -f2-`" # codename="`grep '^codename:' $scratchfile | cut -d':' -f2-`" # version_id="`grep '^version_id:' $scratchfile | cut -d':' -f2-`" version_main="`grep '^version_main:' $scratchfile | cut -d':' -f2-`" pretty_name="`grep '^pretty_name:' $scratchfile | cut -d':' -f2-`" proc="`grep '^processor:' $scratchfile | cut -d':' -f2-`" # Infos about the processor type (e.g. i386, sparc, arm) bits="`grep '^bit:' $scratchfile | cut -d':' -f2-`" # 32 or 64 # cloud_id="`grep '^cloud_id:' $scratchfile | cut -d':' -f2-`" # asn_id="`grep '^asn_id:' $scratchfile | cut -d':' -f2-`" filecheck -rm $scratchfile if [ "$myip" = "" ]; then # Local install echo "Local Install" else # Download if [ "$param" = "download" ]; then echo "ToDo: Download" fi fi # Create the logfile touch $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 < <(cat "$templatesfile" | tailfromline2 | 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 < <(cat "$toolsfile" | tailfromline2 | 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 < <(cat "$manfile2" | tailfromline2 | 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 < <(cat "$zipsfile" | tailfromline2 | 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