How to make hotfix packages - shell script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make hotfix packages - shell script

Hans
Administrator
This post was updated on .
Hi guys

first of all I am not a script guru - but I love google, openwrt and similar pages on how to build scripts.
Here is how I am making the hotfix packages:

The difficulty with this script was to find an automatic way to add files to a tgz file since the version of tar does not allow for ADDING files after creation.

I have 3 files in the tmp folder:
1) make_hotfix.lst = list of files to include in the hotfix
2) make_hotfix.txt  = list of changes made to the files listed
3) make_hotfix.sh  = actual script to make the tgz file - code listed below.

when I run "sh /tmp/make_hotfix.sh VERSIONA" then it creates three files adding "VERSIONA" to the file names:
1) hotfix-VERSIONA.tgz = the tar ball with all the files in it
2) hotfix-VERSIONA.md5 = the md5sum of the tar ball.
3) hotfix-VERSIONA.txt = copy of make_hotfix.txt

but it will proceed only if the script can find all the files in make_hotfix_list

make_hotfix.sh

#!/bin/sh

clear

FILE_LIST='/tmp/make_hotfix.lst'       # list of files to tar
FILE_INFO='/tmp/make_hotfix.txt'        # list of changes made
FILE_ARCHIVE="/tmp/hotfix$1.tgz"        # target output
FILE_ARCHMD5="/tmp/hotfix$1.md5"    # MD5SUM of the archive
#
# Check if all files are present and aborts if a file is not present
#

if [ ! -r "$FILE_LIST" ]; then
        {
        echo "Unable to open $FILE_LIST, aborting"
        exit 1
        }
fi

echo ""
echo "HOTFIX creation script"
echo ""
echo "Archive $FILE_ARCHIVE based on files listed in $FILE_LIST"
echo ""

while IFS= read -r var
do
        if [ ! -r "$var" ]; then
        {
                echo "ERROR: file $var was not found, aborting"
                exit 1
        }
        fi
done < "$FILE_LIST"

echo "OK - all files found"
echo ""
echo "Creating archive $FILE_ARCHIVE now"

# remove previous created archive
if [ -r "$FILE_ARCHIVE" ]; then
        {
        echo "Deleting previous archive"
        rm "$FILE_ARCHIVE"
        }
fi

date > /.hf_date

tar -czvf $FILE_ARCHIVE -T $FILE_LIST

cp $FILE_INFO "/tmp/hotfix$1.txt"

echo ""
echo "Calculating MD5SUM of the archive"
echo ""
md5sum "$FILE_ARCHIVE" > $FILE_ARCHMD5
cat $FILE_ARCHMD5

echo ""
echo "Done making hotfix patches ......"
echo ""

make_hotfix.lst is nothing more than a list of files:
/tmp/make_hotfix.txt
/sbin/fw_upgrade
/etc/init.d/dnsmasq
/etc/itus/update_blacklist.sh
/etc/itus/write-categories.sh
....

I am intentionally NOT including the ITUS hotfix (http://itus.accessinnov.com/Hotfix-160210-td8.html) in this fix.
That particular hotfix also replaces active config files (like network and dhcp) from my Shield. So if I use this script, I risk sharing my own bridge mode setups
Using Shield Pro v1, Chaos Calmer, FW 1.51 SP1, Bridge Mode

2nd Shield as Sandbox, Chaos Calmer, FW 1.51 SP1 + hotfixes
Reply | Threaded
Open this post in threaded view
|

Re: How to make hotfix packages - shell script

user8446
Administrator
What do you use/recommend for this work environment? A real nix machine, VM?
Running in bridge mode, 1.51 SP1 fw
Reply | Threaded
Open this post in threaded view
|

Re: How to make hotfix packages - shell script

Hans
Administrator
I have not gotten a Shield representative VM working so i am using my 2nd shield (in router mode).
Using Shield Pro v1, Chaos Calmer, FW 1.51 SP1, Bridge Mode

2nd Shield as Sandbox, Chaos Calmer, FW 1.51 SP1 + hotfixes