diff --git a/contrib/.gitignore b/contrib/.gitignore index a0e6fd4..959ced0 100644 --- a/contrib/.gitignore +++ b/contrib/.gitignore @@ -1,6 +1,7 @@ fakeroot/ -sshfail2kml_*_all.deb -sshfail2kml_*_amd64.changes +sshfail2kml-*.rpm +sshfail2kml_*.deb +sshfail2kml_*.changes sshfail2kml_*.dsc sshfail2kml_*.tar.gz diff --git a/contrib/fpm-createPackages.sh b/contrib/fpm-createPackages.sh index 5e31905..c983505 100755 --- a/contrib/fpm-createPackages.sh +++ b/contrib/fpm-createPackages.sh @@ -1,3 +1,16 @@ +#!/bin/bash + +# this is a fast way to create packages with the fpm tool: https://github.com/jordansissel/fpm/wiki + +DIR="$$/" # lets make a random temp dir as a fakeroot +NAME="sshfail2kml" +DESC="SSH failed login attempts logged and GeoIP info acquired for Google Map KML display in an HTML page. Complete with JSON results and SQLite indexed database for a log rotation friendly setup." +URI="https://github.com/BIAndrews/sshfail2kml" +LIC="GPLv3" +PROV="sshfail2kml" +EMAIL="bryanandrews@gmail.com" + +################################################################################################# # # PREFLIGHT CHECK FOR REQUIRED TOOLS # @@ -29,18 +42,17 @@ if [ $? -ne 0 ];then fi +# juuussttt in case +if [ "$DIR" == "/" ]; then + echo "ERROR: the fakeroot temp dir can't be / or really really bad things will happen." + exit 255; +fi + +######################################################################################## # # LETS GO # -DIR="fakeroot/" -NAME="sshfail2kml" -DESC="SSH failed login attempts logged and GeoIP info acquired for Google Map KML display in an HTML page. Complete with JSON results and SQLite indexed database for a log rotation friendly setup." -URI="https://github.com/BIAndrews/sshfail2kml" -LIC="GPLv3" -PROV="sshfail2kml" -EMAIL="bryanandrews@gmail.com" - if [ ! -f "${PWD}/version.sh" ];then echo "Unable to find the version.sh file." pwd @@ -55,6 +67,10 @@ if [ $? -ne 0 ];then exit 1 fi +# +# Lets automatically create the package release number for jenkin/ci automation, resets on a new version/tag +# + if [ -f "${PWD}/.release-${VER}" ];then . "${PWD}/.release-${VER}" RELEASE=$((RELEASE+1)) @@ -63,7 +79,12 @@ RELEASE="0" fi echo "RELEASE=$RELEASE" > "${PWD}/.release-${VER}" -echo "Building packages for ${VER}-${RELEASE}" +############################################################### +# +# Create and populate the fakeroot directory to be packaged +# + +echo "Building package fakeroot dir for ${VER}-${RELEASE}" install -d $DIR/var/lib/sshfail2kml $DIR/etc/cron.d $DIR/usr/bin cp -f ../sshfail2kml $DIR/usr/bin @@ -75,14 +96,24 @@ chmod o-rwx $DIR/etc/sshfail2kml.conf echo "DIR: $DIR" cd $DIR +################################## +# # CREATE THE REDHAT PACKAGE +# +# todo - when fpm can make srpms add that + + fpm \ --url $URI --license $LIC --provides $PROV -p "../$NAME-$VER-$RELEASE.noarch.rpm" \ -m $EMAIL --no-rpm-sign -v $VER --iteration $RELEASE -a noarch \ -s dir -t rpm -n $NAME -d php-cli -d php-pdo --verbose --config-files /etc/sshfail2kml.conf --directories /var/lib/sshfail2kml --description "$DESC" \ * +################################## +# # CREATE THE DEBIAN PACKAGE +# + fpm \ --url $URI --license $LIC --provides $PROV -p "../$NAME-$VER-${RELEASE}_all.deb" \ -m $EMAIL -v $VER --iteration $RELEASE -a all \ @@ -90,20 +121,29 @@ fpm \ * cd .. + if [ -f "$NAME-$VER-$RELEASE.noarch.rpm" ];then -rpm -qpil $NAME-$VER-$RELEASE.noarch.rpm -echo "Successfully created redhat package." + + rpm -qpil $NAME-$VER-$RELEASE.noarch.rpm + echo "Successfully created redhat package." + else -echo "FAILED TO CREATE RPM PACKAGE" -exit 1 + + echo "FAILED TO CREATE RPM PACKAGE" + exit 1 + fi if [ -f "$NAME-$VER-${RELEASE}_all.deb" ];then -echo "Successfully created debian package." + + echo "Successfully created debian package." + else -echo "FAILED TO CREATE DEBIAN PACKAGE" -exit 1 + + echo "FAILED TO CREATE DEBIAN PACKAGE" + exit 1 + fi -#clean up +#clean up, this is a good example of why we never run someone elses code as root rm -rf $DIR diff --git a/contrib/version.sh b/contrib/version.sh index ba74234..0ec4927 100644 --- a/contrib/version.sh +++ b/contrib/version.sh @@ -1,2 +1,2 @@ # example, external file to work better with CI/CD -VER="1.3.5" +VER="1.3.10"