#!/bin/bash # # Author: Georg Voell - georg.voell@standby.cloud # Version: @(#)install-scripts 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 useful UNIX scripts and installs them. #@ If scripts are already installed, it tries to update them. #@ #@Usage: install-scripts [action] #@ Action: optional #@ download : Just download the scripts - don't install them. #@ basic : Just install basic scripts (subset of all available scripts e.g. errormsg and confirm). #@ management: Install basic scripts and management scripts (subset of all available scripts e.g. key-management). #@ remove : Removes all installed scripts. # # Exit codes: # 01: Unknown or wrong parameter. # 02: Unknown OS. # 03: Need root privileges. # 04: **curl** not found. This script needs **curl** to perform. # 05: Error while downloading. # 06: Downloaded file corrupted. # # Supported platforms: # # Darwin (Mac OS X), SunOS (Solaris), Linux (OEL, Red Hat, CentOS, Ubuntu) # # Usage: # # # Install for all users # curl -skL https://standby.cloud/download/latest/install-scripts | sudo bash # # # Install for one user # curl -skL https://standby.cloud/download/latest/install-scripts | bash # # # Dont't install - just download all scripts (beta version) # curl -skL https://standby.cloud/download/beta/install-scripts | bash -s download # # # Install just basic scripts # curl -skL https://standby.cloud/download/latest/install-scripts | sudo bash -s basic # # # Install just management scripts # curl -skL https://standby.cloud/download/latest/install-scripts | sudo bash -s management # # ToDo: # - Local install with download # # Update history: # # V 3.0.0 18.04.2020 New version # V 3.0.1 16.09.2020 Use new download URL: https://standby.cloud/download # V 3.0.2 18.09.2020 Set PATH for login_shell corrected # V 3.0.3 30.09.2020 Beta Test included # V 3.0.4 09.10.2020 Download / Delete obsolete script # V 3.1.0 05.06.2023 New copyright # V 3.2.0 11.09.2024 New minor version: Install basic scripts # # Get the REALUSER if [ "$REALUSER" = "" ]; then export USER=`whoami` # Current user export OS=`uname -s` # Infos about the host os (e.g. Darwin, SunOS, Linux) # Try to get HOME if it is not set if [ "$HOME" = "" -o "$HOME" = "/" ]; then export HOME=$(eval echo ~${USER}) if [ "$HOME" = "" ]; then export HOME="/" fi fi # Check if re run with 'sudo' if [ "$SUDO_USER" != "" ]; then export REALUSER="$SUDO_USER" export REALGROUP=`id -gn $SUDO_USER` export REALHOME=$(eval echo ~${SUDO_USER}) export HOME=$(eval echo ~${USER}) else export REALUSER="$USER" export REALGROUP=`id -gn $USER` export REALHOME="$HOME" fi fi ### #myinfo="/tmp/myinfo.txt" #echo "REALUSER: '$REALUSER'." > $myinfo #echo "REALGROUP: '$REALGROUP'." >> $myinfo #echo "REALHOME: '$REALHOME'." >> $myinfo #echo "HOME: '$HOME'." >> $myinfo #echo "SUDO_USER: '$SUDO_USER'." >> $myinfo #echo "USER: '$USER'." >> $myinfo #echo "HOME: '$HOME'." >> $myinfo #echo "OS: '$OS'." >> $myinfo # Define helpful alias shopt -s expand_aliases unalias -a alias stripcomment="sed 's|#.*$||g'" # Ignore all comments alias tolower="tr '[:upper:]' '[:lower:]'" # Lowercase string alias toupper="tr '[:lower:]' '[:upper:]'" # Uppercase string if [ "$OS" = "SunOS" ]; then # If we are runnung on Solaris, tail had to be handled different if [ -x "/usr/gnu/bin/tail" ]; then alias tailfromline2="/usr/gnu/bin/tail -n +2" alias taillastline="/usr/gnu/bin/tail -n 1" else alias tailfromline2="/usr/bin/tail +2" alias taillastline="/usr/bin/tail -1" fi else alias tailfromline2="tail -n +2" alias taillastline="tail -n 1" fi # Define WORKPATH if [ "$WORKPATH" = "" ]; then stdpath="/usr/local/sbin:/usr/local/bin:/usr/gnu/bin:/sbin:/bin:/usr/sbin:/usr/bin" if [ "$HOME" = "/" ]; then export WORKPATH="${stdpath}:$PATH" else if [ "$REALHOME" != "$HOME" ]; then export WORKPATH="${HOME}/.local/bin:${HOME}/bin:${REALHOME}/.local/bin:${REALHOME}/bin:${stdpath}:$PATH" else export WORKPATH="${REALHOME}/.local/bin:${REALHOME}/bin:${stdpath}:$PATH" fi fi fi # Saving original PATH if [ "$SUDO_USER" != "" ]; then # This script started using sudo USERENV=`su - "$SUDO_USER" -c 'env'` ORGPATH=`echo "$USERENV" | grep '^PATH=' | cut -d '=' -f2` USERSHELL=`echo "$USERENV" | grep '^SHELL=' | cut -d '=' -f2` LIB_PATH=`echo "$USERENV" | grep '^LD_LIBRARY_PATH=' | cut -d '=' -f2` # ORGPATH=`sudo -Hiu "$SUDO_USER" env | grep '^PATH=' | cut -d '=' -f2` # USERSHELL=`sudo -Hiu "$SUDO_USER" env | grep '^SHELL=' | cut -d '=' -f2` else ORGPATH="$PATH" USERSHELL="$SHELL" LIB_PATH="$LD_LIBRARY_PATH" # ORGPATH=`env | grep '^PATH=' | cut -d '=' -f2` # USERSHELL=`env | grep '^SHELL=' | cut -d '=' -f2` fi ### #echo "USERENV: '$USERENV'." >> $myinfo #echo "ORGPATH: '$ORGPATH'." >> $myinfo #echo "USERSHELL: '$USERSHELL'." >> $myinfo #echo "LIB_PATH: '$LIB_PATH'." >> $myinfo if [ "$USERSHELL" != "" ]; then USERSHELL=`basename "$USERSHELL"` case "$USERSHELL" in bash) USTYPE="sh" if [ -r "${REALHOME}/.bash_profile" ]; then LOGIN_PROFILE="${REALHOME}/.bash_profile" else LOGIN_PROFILE="${REALHOME}/.profile" fi PROFILE="${REALHOME}/.bashrc" ;; sh | ksh | mksh) USTYPE="sh" LOGIN_PROFILE="${REALHOME}/.profile" PROFILE="" ;; csh | tcsh) USTYPE="csh" LOGIN_PROFILE="${REALHOME}/.profile" if [ -r "${REALHOME}/.tcshrc" ]; then PROFILE="${REALHOME}/.tcshrc" else PROFILE="${REALHOME}/.cshrc" fi ;; *) USTYPE="" LOGIN_PROFILE="" PROFILE="" ;; esac fi # Set PATH to something useful PATH="$WORKPATH" ### #echo "USTYPE: '$USTYPE'." >> $myinfo #echo "LOGIN_PROFILE: '$LOGIN_PROFILE'." >> $myinfo #echo "PROFILE: '$PROFILE'." >> $myinfo #echo "WORKPATH: '$WORKPATH'." >> $myinfo function Cleanup() { # Delete working directory and exit if [ "$param" != "download" -a "$wdir" != "" ]; then rm -fR $wdir 2>/dev/null fi filecheck -rm $scratchfile } function errormsg() { normal='\033[0m' redcol='\033[0;91m' # Highlighted red number=${1} # Error Number errmsg=${2} # Error Message errrsn=${3} # Error Reason if [ "$errrsn" = "" ]; then printf "${redcol}ERROR(%02d): ${errmsg}${normal}\n" $number > /dev/stderr else printf "${redcol}ERROR(%02d): ${errmsg} (${errrsn})${normal}\n" $number > /dev/stderr fi } function filecheck() { option=${1} filnam=${2} case "$option" in -x) if [ -f "$filnam" -a -x "$filnam" ]; then # We have to check if it is a file first - otherwise it may is a directory dname=`dirname "$filnam"` if [ "$dname" = "." ]; then dname=`pwd` bname=`basename "$filnam"` echo "${dname}/$bname" else echo "$filnam" fi else # '2>/dev/null' needed for Linux, sed needed for Solaris 10 resstr=`which "$filnam" 2>/dev/null | sed 's|^no '$filnam' in .*||'` if [ "$resstr" != "" ]; then echo "$resstr" fi fi ;; -z) if [ -f "$filnam" ]; then unzip=`which unzip 2>/dev/null | sed 's|^no '$filnam' in .*||'` if [ "$unzip" != "" ]; then $unzip -t "$filnam" >/dev/null 2>&1 stat=$? if [ $stat -eq 0 ]; then echo "$filnam" fi fi fi ;; -s) if [ -f "$filnam" ]; then fresult=`cat "$filnam" | wc -c` if [ $fresult -gt 0 ]; then echo "$filnam" fi fi ;; -sl) if [ -f "$filnam" ]; then fresult=`cat "$filnam" | wc -l` if [ $fresult -gt 1 ]; then echo "$filnam" fi fi ;; -rm) if [ -f "$filnam" ]; then rm -f "$filnam" fi ;; *) echo "Invalid option '$option'." exit 1 ;; esac } # 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}" > /dev/null 2>&1 fi ;; Linux) mandb=`filecheck -x mandb` if [ "$mandb" != "" ]; then $mandb "${manfolder}" > /dev/null 2>&1 fi ;; SunOS) catman=`filecheck -x catman` if [ "$catman" != "" ]; then $catman -M "${manfolder}" > /dev/null 2>&1 fi ;; esac if [ "$needchown" = true ]; then chown -fR ${REALUSER}:$REALGROUP $manfolder fi } function UpdateProfile() { profilefile=${1} infotext=${2} if [ "$USTYPE" = "sh" ]; then if [ "$ORGPATH" = "" ]; then echo 'export PATH="$HOME/.local/bin:$HOME/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin"' >> $profilefile else echo 'export PATH="$HOME/.local/bin:$HOME/bin:/usr/local/bin:$PATH"' >> $profilefile fi else if [ "$ORGPATH" = "" ]; then echo 'setenv PATH "$HOME/.local/bin:$HOME/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin"' >> $profilefile else echo 'setenv PATH "$HOME/.local/bin:$HOME/bin:/usr/local/bin:$PATH"' >> $profilefile fi fi if [ "$userhome" = "${REALHOME}/.local" ]; then if [ "$LIB_PATH" = "" ]; then if [ "$USTYPE" = "sh" ]; then echo 'export LD_LIBRARY_PATH="$HOME/.local/lib"' >> $profilefile else echo 'setenv LD_LIBRARY_PATH "$HOME/.local/lib"' >> $profilefile fi else if [ "$USTYPE" = "sh" ]; then echo 'export LD_LIBRARY_PATH="$HOME/.local/lib:$LD_LIBRARY_PATH"' >> $profilefile else echo 'setenv LD_LIBRARY_PATH "$HOME/.local/lib:$LD_LIBRARY_PATH"' >> $profilefile fi fi fi printf "\nExpanded PATH in '$profilefile' with '$binfolder' - $infotext.\n" if [ "$userhome" = "${REALHOME}/.local" ]; then printf "Also extended LD_LIBRARY_PATH with '$HOME/.local/lib'.\n" fi printf "To use the new PATH, execute 'source $profilefile' in shell or re-login.\n" } # Check if this script was called direct or whithin a pipe script=${0} # Name of this script progstr=`basename "$script"` # Basename of the script progdir=`dirname "$script"` # Dirname of the script if [ "$progstr" = "bash" ]; then progstr="install-scripts" # Need a name for logfiles or scratchfile # script=`filecheck -x $progstr` # Location of the script fi # Repository where we load scripts from downloadurl="https://standby.cloud/download" scriptsurl="${downloadurl}/latest" havebeta=`basename "$scriptsurl"` # Define default variables exitcode=0 # Default exit code firsttime=false # If script is called the first time, set this to true needchown=false # Need to change filerights # showhelp=false # false = don't show help / true = show help # showversion=false # false = don't show version / true = show version errstr="" # Default error message pid="$$" # Get the process id from current shell tmpdir="/tmp" # Temporary directory timestamp=`date '+%y%m%d%H%M%S'` # Extension String with current date and time scratchfile="${tmpdir}/${progstr}.${timestamp}.${pid}.tmp" # Temporary file toolsname="tools" # Unused scriptsname="scripts" templatesname="templates" # Unused setupname="lib.bash" # Check where the scripts are set up / installed # Check if we laready installed the scripts result=`filecheck -x /usr/local/bin/$setupname` if [ "$result" != "" ]; then userhome="/usr/local" if [ "$USER" != "root" ]; then exitcode=3 errormsg $exitcode "Root privileges needed to alter scripts." exit $exitcode fi else result=`filecheck -x ${REALHOME}/.local/bin/$setupname` if [ "$result" != "" ]; then userhome="${REALHOME}/.local" if [ "$USER" = "root" ]; then needchown=true fi else # We install the first time firsttime=true if [ "$USER" = "root" ]; then userhome="/usr/local" else userhome="${REALHOME}/.local" fi fi fi binfolder="${userhome}/bin" libfolder="${userhome}/lib" # lib64 manfolder="${userhome}/share/man" infofolder="${userhome}/share/info" appfolder="${userhome}/share/applications" templatesfolder="${userhome}/share/$templatesname" scriptsfile="${infofolder}/installed-${scriptsname}.txt" manfile="${infofolder}/installed-manuals.txt" manfile2="${infofolder}/installed-cmd-manuals.txt" templatesfile="${infofolder}/installed-${templatesname}.txt" sshdfolder="/etc/ssh" getauthkeys="get-authkeys" curdate=`date "+%Y-%m-%d %T"` # For use in logfiles, etc. wdir="${tmpdir}/$scriptsname" # That where the scripts are downloaded to cdir=`pwd` # Current working directory param=`echo "$1" | tolower` # First papameter # Script only works on UNIX like systems if [ "$OS" != "Linux" -a "$OS" != "SunOS" -a "$OS" != "Darwin" ]; then exitcode=2 errormsg $exitcode "This script only works UNIX like systems." exit $exitcode fi # Check if we have curl and gzip available curl=`filecheck -x curl` gzip=`filecheck -x gzip` myip="" if [ "$curl" = "" ]; then exitcode=4 errormsg $exitcode "No 'curl' in PATH '$PATH'. Please install first e.g. 'sudo yum -y install curl'." exit $exitcode else # Check if we have insternet access $curl -k -L -m 10 -s $downloadurl >/dev/null 2>&1 status=$? if [ $status -eq 0 ]; then # Display the result printf "\n$progstr\n" myip="unknown" # Create working directory and sub directory if it does not exists if [ ! -d ${wdir}/$scriptsname ]; then mkdir -p ${wdir}/$scriptsname fi else # No internet access? Check for local install # echo "Local install" exitcode=5 errormsg $exitcode "No Internet Access." exit $exitcode fi fi if [ "$param" = "" ]; then if [ "$firsttime" = true ]; then param="install" else param="update" fi fi if [ "$param" != "download" ]; then # We create some folder if they don't exist for destfolder in $binfolder ${manfolder}/man1 $infofolder; do if [ ! -d "$destfolder" ]; then mkdir -m 0755 -p "$destfolder" printf "Created folder '$destfolder'.\n" fi done fi # Add bin to path if it is not already in path (only the first call) if [ "$firsttime" = true ]; then if [ "$OCI_CLI_CLOUD_SHELL" = "True" ]; then profilefile="$PROFILE" else profilefile="$LOGIN_PROFILE" fi if [ -r "$profilefile" ]; then grepres=`grep 'PATH=' "$profilefile" | tail -1` else grepres="" fi if [ -r "$profilefile" ]; then if [ "$grepres" = "" ]; then # No 'PATH' set # Save old profile cp -f "$profilefile" "${profilefile}.old" UpdateProfile "$profilefile" "old profile was saved" if [ "$SUDO_USER" != "" ]; then chown ${REALUSER}:$REALGROUP "$profilefile" "${profilefile}.old" fi else # Found 'PATH' oldpath=`echo $grepres | tr -d '"' | cut -d'=' -f2-` mypath=$(eval echo $oldpath) grepres2=`echo "$mypath" | grep "$binfolder"` if [ "$grepres2" = "" ]; then cat "$profilefile" | sed 's|'"$oldpath"'|'"${binfolder}"':'"${oldpath}"'|' > $scratchfile if [ -f "$scratchfile" ]; then mv -f "$profilefile" "${profilefile}.old" mv -f $scratchfile "$profilefile" if [ "$SUDO_USER" != "" ]; then chown ${REALUSER}:$REALGROUP "$profilefile" "${profilefile}.old" fi printf "\nExpanded PATH in '$profilefile' with '$binfolder' - old profile was saved.\n" printf "To use the new PATH, execute 'source $profilefile' in shell or re-login.\n" fi fi fi else # Create profile if [ "$USTYPE" != "" ]; then touch "$profilefile" stat=$? if [ $stat -eq 0 ]; then UpdateProfile "$profilefile" "new profile was created" if [ "$SUDO_USER" != "" ]; then chown ${REALUSER}:$REALGROUP "$profilefile" fi else printf "\nCould not create '$profilefile'. Please expand PATH in your profile with '$binfolder'.\n" fi else printf "\nPlease expand PATH in your profile with '$binfolder'.\n" fi fi # # Check if PYTHONWARNINGS is set # pythonopt=`grep "PYTHONWARNINGS" "$profilefile"` # if [ "$pythonopt" = "" ]; then # if [ "$USTYPE" = "sh" ]; then # echo 'export PYTHONWARNINGS="ignore"' >> $profilefile # else # echo 'setenv PYTHONWARNINGS "ignore"' >> $profilefile # fi # # printf "\nPYTHONWARNINGS will be ignored.\n" # fi fi # Display the os name printf "\n%9s: %s\n" "Action" "$param" printf "%9s: %s\n" "OS" "$OS" printf "%9s: %s\n" "User" "$USER" if [ "$SUDO_USER" != "" ]; then printf "%9s: %s\n" "Real User" "$SUDO_USER" fi if [ "$param" != "download" ]; then printf "%9s: %s\n" "User bin" "$binfolder" printf "%9s: %s\n" "Man pages" "$manfolder" printf "%9s: %s\n" "Origin" "$scriptsurl" fi printf "%9s: %s\n\n" "Download" "$wdir" # Download filelist if [ "$myip" != "" ]; then rfile="${scriptsname}.txt" if [ "$havebeta" = "latest" ]; then # Download stable version dfile="$rfile" else # Download Beta Test version dfile="beta.txt" fi $curl -k -s -m 10 "${downloadurl}/lists/$dfile" -o "${wdir}/$rfile" status=$? if [ $status -ne 0 ]; then exitcode=5 errormsg $exitcode "Could not download filelist '$dfile'." "CURL could not establish a connection to server" filecheck -rm "${wdir}/${rfile}" exit $exitcode else if [ -f ${wdir}/$rfile ]; then cmd="`cat ${wdir}/$rfile | head -n 1 | cut -d$'\t' -f1`" if [ "$cmd" != "cmd" ]; then exitcode=6 errormsg $exitcode "Corrupt filelist '$dfile'." "Download not successful" filecheck -rm "${wdir}/${rfile}" exit $exitcode fi fi fi fi # Deinstall previously installed scripts and manuals if [ "$param" != "download" ]; then if [ -f "${wdir}/${scriptsname}.txt" ]; then if [ -f $scriptsfile ]; then while IFS=$'\t' read -r sname svers; do # Browse through all installed scripts if [ "$sname" != "" -a "$svers" != "" ]; then cmd=`basename "$sname"` if [ "$cmd" != "" ]; then grepres=`grep "^$cmd " "${wdir}/${scriptsname}.txt"` if [ "$grepres" = "" -o "$param" = "remove" ]; then # Script not found in download list or needs to be removes printf "%s\t%s\n" "$cmd" "$sname" >> $scratchfile fi fi fi done < <(cat $scriptsfile | tailfromline2 | stripcomment) fi if [ -f "$scratchfile" ]; then printf "Deleting prviously installed scripts and manuals:\n\n" while IFS=$'\t' read -r cmd sname; do if [ -f "$sname" ]; then # Tool exists - check if it has a version instvers=`head -n 10 $sname | grep '^# Version: @(#' | cut -d' ' -f4` if [ "$instvers" != "" ]; then echo "Deleting script '$cmd'." filecheck -rm "$sname" if [ -f "$manfile" ]; then mname=`grep "/${cmd}.1" "$manfile" | cut -d$'\t' -f1` if [ -f "$mname" ]; then echo "Deleting manual '$cmd'." filecheck -rm "$mname" fi fi else echo "Script '$cmd' not deleted. Alternative version found." fi fi done < $scratchfile if [ "$param" != "remove" ]; then printf "\n" filecheck -rm $scratchfile else filecheck -rm $scriptsfile filecheck -rm $manfile Cleanup exit $exitcode fi fi fi fi if [ "$param" != "remove" ]; then # Install every script in filelist if [ -f ${wdir}/${scriptsname}.txt ]; then if [ "$param" != "download" ]; then # Create an empty list of installed scripts echo "script version" > $scriptsfile echo "man1 version" > $manfile fi while IFS=$'\t' read -r cmd svers basic; do if [ "$cmd" != "" -a "$svers" != "" ]; then if [ "$param" = "basic" -o "$param" = "management" ]; then ok=$basic if [ "$ok" = false -a "$param" = "management" ]; then result=`echo "$cmd" | grep '\-management$'` if [ "$result" != "" ]; then ok=true fi fi else ok=true fi # We can only download something if we have an internet connection if [ "$myip" != "" -a "$ok" = true ]; then # Download the script if [ "$param" = "download" ]; then echo "Downloading script: '$cmd'." fi # $curl -s -m 10 "${downloadurl}/${scriptsname}/${cmd}/${svers}/${cmd}" -o "${wdir}/${scriptsname}/${cmd}-$svers" $curl -k -s -m 20 "${scriptsurl}/${cmd}" -o "${wdir}/${scriptsname}/${cmd}-$svers" status=$? if [ $status -ne 0 ]; then echo "Could not download script '$cmd'." filecheck -rm "${wdir}/${scriptsname}/${cmd}-$svers" else if [ -r "${wdir}/${scriptsname}/${cmd}-$svers" ]; then grepres=`grep '^' "${wdir}/${scriptsname}/${cmd}-$svers"` if [ "$grepres" != "" ]; then echo "Corrupt script '$cmd'." filecheck -rm "${wdir}/${scriptsname}/${cmd}-$svers" fi fi fi # Download man1 page if we could download the script if [ "$havebeta" = "latest" ]; then if [ -f "${wdir}/${scriptsname}/${cmd}-$svers" ]; then $curl -k -s -m 20 "${downloadurl}/man/${cmd}/${svers}/${cmd}.1" -o "${wdir}/${scriptsname}/${cmd}-$svers-man1" status=$? # Delete the file if it is HTML or if we got an error if [ -r "${wdir}/${scriptsname}/${cmd}-$svers-man1" ]; then grepres=`grep '^' "${wdir}/${scriptsname}/${cmd}-$svers-man1"` if [ $status -ne 0 -o "$grepres" != "" ]; then filecheck -rm "${wdir}/${scriptsname}/${cmd}-$svers-man1" fi fi fi fi fi tool="${binfolder}/$cmd" if [ -f "$tool" ]; then # Tool already exists - check if it has a version instvers=`head -n 10 $tool | grep '^# Version: @(#' | cut -d' ' -f4` else tool="" instvers="" fi if [ "$param" != "download" ]; then if [ -f "${wdir}/${scriptsname}/${cmd}-$svers" ]; then # Install the script if [ "$tool" = "" -o "$instvers" != "" ]; then if [ "$tool" = "" ]; then printf "Installing script '$cmd': " else printf "Updating script '$cmd': " fi cp -f "${wdir}/${scriptsname}/${cmd}-$svers" "${binfolder}/$cmd" chmod 755 "${binfolder}/$cmd" # if [ "${cmd:0:4}" != "lib." ]; then # chmod 755 "${binfolder}/$cmd" # fi if [ "$needchown" = true ]; then chown ${REALUSER}:$REALGROUP "${binfolder}/$cmd" fi echo "${binfolder}/$cmd installed. Version: '$svers'." # Write entry to list of installed scripts echo "${binfolder}/$cmd $svers" >> $scriptsfile # Copy man page if it exists if [ -f "${wdir}/${scriptsname}/${cmd}-$svers-man1" ]; then filecheck -rm "${manfolder}/man1/${cmd}.1.gz" cp "${wdir}/${scriptsname}/${cmd}-$svers-man1" "${manfolder}/man1/${cmd}.1" if [ "$gzip" != "" -a "$OS" != "SunOS" ]; then $gzip "${manfolder}/man1/${cmd}.1" chmod 644 "${manfolder}/man1/${cmd}.1.gz" if [ "$needchown" = true ]; then chown ${REALUSER}:$REALGROUP "${binfolder}/$cmd" fi echo "${manfolder}/man1/${cmd}.1.gz $svers" >> $manfile else chmod 644 "${manfolder}/man1/${cmd}.1" if [ "$needchown" = true ]; then chown ${REALUSER}:$REALGROUP "${binfolder}/$cmd" fi # echo "${manfolder}/man1/${cmd}.1 installed. Version: '$svers'." # Write entry to list of installed man pages echo "${manfolder}/man1/${cmd}.1 $svers" >> $manfile fi fi else echo "Script '$cmd' not installed. Alternative version found at '$tool'." fi fi fi fi done < <(cat "${wdir}/${scriptsname}.txt" | tailfromline2 | stripcomment) # Download the install script if [ "$param" = "download" ]; then if [ "$myip" != "" ]; then for cmd in install-scripts install-tools get-authkeys; do echo "Downloading script: '$cmd'." $curl -k -s -m 20 "${scriptsurl}/${cmd}" -o "${wdir}/${cmd}" status=$? if [ $status -ne 0 ]; then echo "Could not download script '$cmd'." filecheck -rm "${wdir}/${cmd}" else if [ -r "${wdir}/${cmd}" ]; then grepres=`grep '^' "${wdir}/${cmd}"` if [ "$grepres" != "" ]; then echo "Corrupt script '$cmd'." filecheck -rm "${wdir}/${cmd}" else chmod 755 "${wdir}/${cmd}" fi fi fi done fi else if [ "$needchown" = true ]; then chown ${REALUSER}:$REALGROUP $scriptsfile chown ${REALUSER}:$REALGROUP $manfile fi # Create mandb UpdateWhatis fi fi fi # Cleanup and exit Cleanup exit $exitcode