Chris:/* wrote: » Why do you want to do this in an RPM instead of creating a tar that allows you to unpack it as required with any user account and location?
NightShade03 wrote: » For a simple RPM like you could do the following: Create the required directories # mkdir -p /usr/src/redhat/{BUILD,RPMS,SOURCES,SPEC,SRPMS,tmp} Install the required packages: # yum install -y rpm-build Create the BASH file (mine is blank for this example): # mkdir /usr/src/redhat/SOURCES/sample # touch /usr/src/redhat/SOURCES/sample/hello.sh Create a SOURCES file that will actually only hold your single BASH script: # tar cvf sample.tar.gz /usr/src/redhat/SOURCES/sample # mv sample.tar.gz /usr/src/redhat/SOURCES Create a sample.spec file in the /usr/src/redhat/SPEC directory using the following as a template: ##### Sample SPEC File ##### Summary: This package is a sample for the Red Hat exams. Name: sample Version: 1.0 Release: 0 License: GPL Packager: Joe Tester Group: Development/Tools Source: %{name}.tar.gz BuildRoot: /usr/src/redhat/tmp/%{name}-%{version} %description This package is just a sample for the Red Hat exams. # The %prep and %setup untar your SOURCES .tar.gz file and enter into that directory to perform the required actions. %prep %setup -n sample # Moves the hello.sh file into the /opt directory (only under our build root). %install mkdir -p "$RPM_BUILD_ROOT/opt/" cp -R * "$RPM_BUILD_ROOT/opt/" # All files you want in your RPM package must be listed here. # Listed directories contain every file and sub-directory within them. %files /opt/ %clean rm -rf "$RPM_BUILD_ROOT" %post chown user01:user01 -R /opt/hello.sh chmod 775 -R /opt/ ##### End SPEC File ##### Once your SPEC file is in place and your sample.tar.gz is in place execute the following command to create the new RPM package: # rpmbuild -v -bb /usr/src/redhat/SPEC/sample.spec If there are any errors you will see them here and they should be easy enough to fix. If there are no errors you should now have a new RPM package in your /usr/src/redhat/RPMS directory. Run the following to test: # rpm -ivh sample.rpm Which in turn should install the hello.sh script into the /opt directory with the 775 permissions and owned by user01 and group user01. This should be everything that you need. If you get stuck or have any questions let me know.