i've tried to figure our , what wrong with my script , i tried using the below syntax for function fucntion name{ } , and also example(){} , both results creates errors , please advise what's wrong with my script
# Objective : automation script for createing rpm package
usage(){
echo "in order to use this script you need to add the filename which"
echo "contain the script. for Example"
echo "s scriptname.sh"
break
}
check(){
# check if package exists , if not install it.
chk1=$(yum list installed | grep rpmdevtools)
chk2=$(yum list installed | grep rpmbuild)
chk3=$(yum list installed | grep rpmdev)
if [[ ! -z ${chk1} ]] && [[ ! -z ${chk2} ]] && [[ ! -z ${chk3} ]];then
echo "package doesn't exist, installing packages"
sleep 5
sudo yum install wget -y
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/rpmdevtools-8.3-5.el7.noarch.rpm
sudo yum install rpmdevtools-8.3-5.el7.noarch.rpm -y
rpmcreate
else
echo "package exists .."
sleep 5
rpmcreate
fi
}
rpmcreate()
{
# creating rpmtree
cd $HOME
rpmdev-setuptree
starti
}
while getopts s:h arg; do
case "$arg" in
h)
usage
;;
s)myarg=${OPTARG}
check
;;
:)usage
;;
\?)usage
;;
esac
done
# creating script file
starti(){
# move the script to SOURCE
mydir=$(echo $myarg | awk -F'.' '{print $1}')
mkdir $mydir-0.0.1
mv $myydir.sh $mydir-0.0.1
tar --create --file $mydir-0.0.1.tar.gz $mydir-0.0.1
sudo mv $mydir-0.0.1.tar.gz ~/rpmbuild/SOURCES
# create a spec file
rpmdev-newspec $mydir
# move the file to SPECS Folder
mv ./$mydir.spec ~/rpmbuild/SPECS
cd ~/rpmbuild/SPECS
sed '2d','4d','7,8d','20,22d','25,27d','31d' $mydir.spec
sed 's/Version:/0.0.1/;s/Summary:/Summary:Sample/;s/License:/License:GPL/;s/Source0:
/Source0:% {name}-%{version}.tar.gz/;s/BuildArch:/BuildArch:noarch/;s/Requires:
/Requires:bash/;s/%description/%description\nSample\;
s/rm -rf $RPM_BUILD_ROOT/rm -rf ${buildroot}\nmkdir -p %{buildroot}/tmp\ncp %{name}.sh
%{buildroot}/tmp/;s/%files/%files\n/tmp/%{name}.sh/;s/%changelog/'
# checking the spec file on error
check=$(rpmlint ~/rpmbuild/SPECS/$mydir.spec | awk '/checked/ {print $7}')
if [ "$check" = "0" ];then
echo "you did a good work lad!"
else
echo $check
echo "problem with your SPECS file fix it F.I.A.T !!! (Fix it again $USER)"
fi
rpmbuild -bs ~/rpmbuild/SPECS/$mydir.spec
}
this is where it fails: ./rpmrevised.sh: line 41: starti: command not found i'm really tring to figure this out , but with no luck