Generative AI on Enterprise Cloud with NiFi and Milvus
Cpsh sh
1. #!/bin/bash
die()
{
error=$1
[ -n "$*" ] && printf "%sn" "$*" >&2
exit "$error"
}
install_script()
{
filename=${1%$devel_suffix} ## Command name, without suffix
filename=${filename##*/} ## Remove path; use file name
alone
dest=( $InstalDir/$filename$bin_suffix ## Path to installed file
$WebDir/$filename$devel_suffix ## Web site
)
source=$ScriptDir/$filename$devel_suffix ## Path to development file
_uniqfile $BackupDir/$filename ## Increment backup filename
bak=$_UNIQFILE ## ...and store in $bak
## Check that source file exists
[ -f "$source" ] || die 2 No source file
# [ -x "$source" ] || chmod +x "$source"
## Create destination file to check permissions
[ -f "$dest" ] || touch "$dest" || die 5 Could not touch destination file
chmod u+rwx "$source" "$dest"
if cmp "$source" "$dest" >/dev/null
then ## The files are identical; do nothing
echo "$source and $dest are the same" >&2
elif [ $diff -ge 1 ]
then
diff -c "$source" "$dest"
else
## Copy the production file to the backup directory
[ -s "$dest" ] && cp -p "$dest" "$bak"
## Copy the development script to the production directory/ies
for d in "${dest[@]}"
do
cp -p "$source" "$d"
done
## Remove write permissions
chmod 755 "$dest"
fi
}
install_bash_script()
{
filename=${1%-bash} ## Command name, without suffix
filename=${filename##*/} ## Remove path; use file name
alone
dest=$InstalDir/$filename$bin_suffix ## Path to installed file
source=$ScriptDir/$filename$devel_suffix ## Path to development file
_uniqfile $BackupDir/$filename ## Increment backup filename
bak=$_UNIQFILE ## ...and store in $bak
## Check that source file exists
[ -f "$source" ] || return 2
# [ -x "$source" ] || chmod +x "$source"
2. ## Create destination file to check permissions
[ -f "$dest" ] || touch "$dest" || exit 5
chmod u+rwx "$source" "$dest"
if cmp "$source" "$dest" >/dev/null
then ## The files are identical; do nothing
echo "$source and $dest are the same" >&2
elif [ $diff -ge 1 ]
then
diff -c "$source" "$dest"
else
## Copy the production file to the backup directory
[ -s "$dest" ] && cp -p "$dest" "$bak"
## Copy the development script to the production directory
cp -p "$source" "$dest"
## Remove write permissions
chmod 755 "$dest"
fi
}
progname=${0##*/}
case $progname in
*-sh) shx=-sh ;;
*) shx= ;;
esac
. standard-funcs$shx ## load standard functions
## Use the script-setup configuration file
configfile=$HOME/.config/script-setup.cfg
## If the config file doesn't exist, run script-setup
[ -f $configfile ] || script-setup || exit 5
## Source config file
. $configfile
diff=0
## Parse command-line options
while getopts dc: arg; do
case $arg in
c) configfile=$OPTARG
[ -f "$configfile" ] && . "$configfile"
;;
d) diff=1 ;;
*) exit 1 ;;
esac
done
shift "$(( $OPTIND - 1 ))"
## This is only necessary when a hand-rolled config file is used
#checkdirs $HOME/.config "$ScriptDir" "$BinDir" "$BackupDir" ||
# die $? "Could not create $dir"
## Install all commands given on the command line
for script
do
install_script "$script"
done