Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create a shell script that verifies its own integrity

Dude!May 23 2018 — edited May 23 2018

I wondering what options exist to write a shell script that verifies itself to make sure it's not corrupt or has been modified.

For example:

c=( $(\cksum ${BASH_SOURCE[0]}) )

[ ${c[1]} -ne 18028 ]  && echo problem

The above simply verifies the amount of characters, but I would prefer to use a CRC checksum. I can calculate the checksum, but the problem is that I cannot add the checksum to the script without changing the result and thereby invalidating the checksum.

Thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 20 2018
Added on May 23 2018
7 comments
552 views