Skip to content

Commit

Permalink
Merge pull request #2 from sap-linuxlab/dev
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
berndfinger authored Aug 4, 2023
2 parents a2b34ec + eeca0c6 commit 40817c2
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions sapfile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -o errexit
set -o nounset
Expand All @@ -23,23 +24,40 @@ usage () {
echo "Usage: sapfile [OPTION...] [FILE...]"
echo "Determine type of SAP FILEs, optionally followed by type of FILEs."
echo " -h, --help display this help and exit"
echo " -i also display the output of the plain file command for this FILE"
echo " -l long listing: also display the output of the plain file command for this FILE"
echo ""
echo "Requires:"
echo "- lsar (contained in the unar package from the EPEL RHEL repo)"
echo "- zipinfo (contained in the unzip RHEL package)"
echo "- sapcar (SAP program to handle sapcar files; typical filename: SAPCAR_1115-70006178.EXE)"
}

if [[ $# == 0 || ${1}. == "-h." || ${1}. == "--help." ]]; then
usage
exit 1
fi
if [[ ${1}. == "-i." ]]; then
_RUN_FILE_COMMAND="y"
shift 1
else
_RUN_FILE_COMMAND="n"
fi
_RUN_FILE_COMMAND="n"

while getopts ":lh" opt; do
case ${opt} in
l)
_RUN_FILE_COMMAND="y"
;;
h)
usage
exit 1
;;
\?)
echo "Invalid option -$OPTARG"
usage
exit 1
;;
esac
done
shift "$((OPTIND-1))"

for _FILE in "$@"; do
if [[ ${_RUN_FILE_COMMAND}. = "y." ]]; then
_FILE_OUTPUT=$(file "${_FILE}" | sed 's,'"${_FILE}"': ,,')
if [[ ${_FILE_OUTPUT}. == "data." ]] && [[ (${_FILE##*.} = "SAR" || ${_FILE##*.} = "sar") ]]; then
_FILE_OUTPUT="SAPCAR archive data - from file extension"
fi
else
_FILE_OUTPUT=""
fi
Expand All @@ -57,15 +75,16 @@ for _FILE in "$@"; do
_FILE_TYPE=$(echo "${_FILE}" | awk '
BEGIN{_sap_file_type="look_inside"}
/SAPCAR/&&/\.EXE/{_sap_file_type="sapcar"}
/IMDB/&&/\.SAR/{_sap_file_type="sap_hana"}
!/IMDB_SERVER/&&!/IMDB_CLIENT/&&/IMDB/&&/\.SAR/{_sap_file_type="sap_db_hana_other"}
/IMDB_SERVER/&&/\.SAR/{_sap_file_type="sap_db_hana"}
/IMDB_CLIENT/&&/\.SAR/{_sap_file_type="sap_db_hana_client"}
/SWPM/&&/\.SAR/{_sap_file_type="sap_swpm"}
/SAPHOSTAGENT/&&/\.SAR/{_sap_file_type="sap_hostagent"}
/igsexe/||/igshelper/{_sap_file_type="sap_igs"}
/SAPEXE_/||/SAPEXEDB_/{_sap_file_type="sap_kernel"}
/SAPWEBDISP_/{_sap_file_type="sap_webdisp"}
/SAPJVM/{_sap_file_type="sap_jvm"}
/ASEBC/{_sap_file_type="sap_db_ase"}
/DBATL/{_sap_file_type="sap_db_oracle"}
/ASEBC/{_sap_file_type="sap_db_ase_client"}
/COMPLETE/{_sap_file_type="sap_hana_backup"}
/S4/&&/HANA/&&/LANG/{_sap_file_type="sap_s4hana_lang"}
/S4/&&/EXPORT/{_sap_file_type="sap_s4hana_export"}
Expand Down Expand Up @@ -96,9 +115,13 @@ for _FILE in "$@"; do
_SAP_FILE_TYPE=$(eval "${_list_content}" "${_FILE}" | awk '
BEGIN{_sap_file_type="sap_unknown"}
/BD_SYBASE_ASE/{_sap_file_type="sap_db_ase"}
/ASEBC/{_sap_file_type="sap_db_ase_client"}
/MaxDB_7.9/{_sap_file_type="sap_db_maxdb"}
/19cinstall.sh/||/OCL_LINUX_X86_64/{_sap_file_type="sap_db_oracle"}
/db2setup/||/db6_update_client.sh/||/db2aese_c.lic/{_sap_file_type="sap_db_db2"}
/19cinstall.sh/{_sap_file_type="sap_db_oracle"}
/OCL_LINUX_X86_64/{_sap_file_type="sap_db_oracle_client"}
/db2setup/{_sap_file_type="sap_db_db2"}
/db6_update_client.sh/{_sap_file_type="sap_db_db2_client"}
/db2aese_c.lic/{_sap_file_type="sap_db_db2_license"}
/DATA_UNITS\/EXPORT/{_sap_file_type="sap_ecc_export"}
/EXP[0-9]/{_sap_file_type="sap_ecc_ides_export"}
/DATA_UNITS\/EXP[0-9]/{_sap_file_type="sap_nwas_abap_export"}
Expand Down

0 comments on commit 40817c2

Please sign in to comment.